mirror of https://github.com/schollz/croc.git
fix linting
This commit is contained in:
parent
0277abe5d4
commit
31c1a37b38
|
@ -21,8 +21,10 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// Version specifies the version
|
||||
var Version string
|
||||
|
||||
// Run will run the command line proram
|
||||
func Run() (err error) {
|
||||
// use all of the processors
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -36,6 +36,7 @@ func init() {
|
|||
log.SetLevel("debug")
|
||||
}
|
||||
|
||||
// Debug toggles debug mode
|
||||
func Debug(debug bool) {
|
||||
if debug {
|
||||
log.SetLevel("debug")
|
||||
|
@ -44,6 +45,7 @@ func Debug(debug bool) {
|
|||
}
|
||||
}
|
||||
|
||||
// Options specifies user specific options
|
||||
type Options struct {
|
||||
IsSender bool
|
||||
SharedSecret string
|
||||
|
@ -55,6 +57,7 @@ type Options struct {
|
|||
DisableLocal bool
|
||||
}
|
||||
|
||||
// Client holds the state of the croc transfer
|
||||
type Client struct {
|
||||
Options Options
|
||||
Pake *pake.Pake
|
||||
|
@ -96,11 +99,14 @@ type Client struct {
|
|||
quit chan bool
|
||||
}
|
||||
|
||||
// Chunk contains information about the
|
||||
// needed bytes
|
||||
type Chunk struct {
|
||||
Bytes []byte `json:"b,omitempty"`
|
||||
Location int64 `json:"l,omitempty"`
|
||||
}
|
||||
|
||||
// FileInfo registers the information about the file
|
||||
type FileInfo struct {
|
||||
Name string `json:"n,omitempty"`
|
||||
FolderRemote string `json:"fr,omitempty"`
|
||||
|
@ -112,11 +118,13 @@ type FileInfo struct {
|
|||
IsEncrypted bool `json:"e,omitempty"`
|
||||
}
|
||||
|
||||
// RemoteFileRequest requests specific bytes
|
||||
type RemoteFileRequest struct {
|
||||
CurrentFileChunkRanges []int64
|
||||
FilesToTransferCurrentNum int
|
||||
}
|
||||
|
||||
// SenderInfo lists the files to be transfered
|
||||
type SenderInfo struct {
|
||||
FilesToTransfer []FileInfo
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
// Encryption is the basic type for storing
|
||||
// the key, passphrase and salt
|
||||
type Encryption struct {
|
||||
key []byte
|
||||
passphrase []byte
|
||||
|
@ -36,6 +38,7 @@ func New(passphrase []byte, salt []byte) (e Encryption, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Salt returns the salt bytes
|
||||
func (e Encryption) Salt() []byte {
|
||||
return e.salt
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
package models
|
||||
|
||||
// TCP_BUFFER_SIZE is the maximum packet size
|
||||
const TCP_BUFFER_SIZE = 1024 * 64
|
||||
|
||||
// DEFAULT_RELAY is the default relay used (can be set using --relay)
|
||||
const DEFAULT_RELAY = "142.93.177.120:9009"
|
||||
|
|
|
@ -251,6 +251,8 @@ func pipe(conn1 net.Conn, conn2 net.Conn) {
|
|||
}
|
||||
}
|
||||
|
||||
// ConnectToTCPServer will initiate a new connection
|
||||
// to the specified address, room with optional time limit
|
||||
func ConnectToTCPServer(address, room string, timelimit ...time.Duration) (c *comm.Comm, banner string, ipaddr string, err error) {
|
||||
if len(timelimit) > 0 {
|
||||
c, err = comm.NewConnection(address, timelimit[0])
|
||||
|
|
|
@ -44,6 +44,7 @@ func HashFile(fname string) (hash256 []byte, err error) {
|
|||
return IMOHashFile(fname)
|
||||
}
|
||||
|
||||
// MD5HashFile returns MD5 hash
|
||||
func MD5HashFile(fname string) (hash256 []byte, err error) {
|
||||
f, err := os.Open(fname)
|
||||
if err != nil {
|
||||
|
@ -91,6 +92,7 @@ func SHA256(s string) string {
|
|||
return fmt.Sprintf("%x", sha.Sum(nil))
|
||||
}
|
||||
|
||||
// PublicIP returns public ip address
|
||||
func PublicIP() (ip string, err error) {
|
||||
resp, err := http.Get("https://canhazip.com")
|
||||
if err != nil {
|
||||
|
@ -108,7 +110,7 @@ func PublicIP() (ip string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Get preferred outbound ip of this machine
|
||||
// LocalIP returns local ip address
|
||||
func LocalIP() string {
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err != nil {
|
||||
|
@ -121,6 +123,7 @@ func LocalIP() string {
|
|||
return localAddr.IP.String()
|
||||
}
|
||||
|
||||
// GetRandomName returns mnemoicoded random name
|
||||
func GetRandomName() string {
|
||||
result := []string{}
|
||||
bs := make([]byte, 4)
|
||||
|
@ -129,6 +132,7 @@ func GetRandomName() string {
|
|||
return strings.Join(result, "-")
|
||||
}
|
||||
|
||||
// ByteCountDecimal converts bytes to human readable byte string
|
||||
func ByteCountDecimal(b int64) string {
|
||||
const unit = 1000
|
||||
if b < unit {
|
||||
|
@ -196,6 +200,7 @@ func MissingChunks(fname string, fsize int64, chunkSize int) (chunkRanges []int6
|
|||
return
|
||||
}
|
||||
|
||||
// ChunkRangesToChunks converts chunk ranges to list
|
||||
func ChunkRangesToChunks(chunkRanges []int64) (chunks []int64) {
|
||||
if len(chunkRanges) == 0 {
|
||||
return
|
||||
|
@ -210,6 +215,7 @@ func ChunkRangesToChunks(chunkRanges []int64) (chunks []int64) {
|
|||
return
|
||||
}
|
||||
|
||||
// GetLocalIPs returns all local ips
|
||||
func GetLocalIPs() (ips []string, err error) {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue