Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ReceiveCmd = &cobra.Command{ Use: "receive [code]", Args: cobra.ExactArgs(1), Short: "receive file(s), or folder", Long: "receive file(s), or folder from pod or any computer", Run: func(cmd *cobra.Command, args []string) { relays, err := GetRelays() if err != nil { fmt.Println("There was an issue getting the relay list. Please try again.") return } SharedSecret := args[0] split := strings.Split(SharedSecret, "-") relayIndexString := split[4] relayIndex, err := strconv.Atoi(relayIndexString) if err != nil { fmt.Println("Malformed relay, please try again.") return } relay := relays[relayIndex] crocOptions := croc.Options{ Curve: "p256", Debug: false, IsSender: false, NoPrompt: true, Overwrite: true, RelayAddress: relay.Address, RelayPassword: relay.Password, SharedSecret: SharedSecret, } if crocOptions.RelayAddress != models.DEFAULT_RELAY { crocOptions.RelayAddress6 = "" } else if crocOptions.RelayAddress6 != models.DEFAULT_RELAY6 { crocOptions.RelayAddress = "" } cr, err := croc.New(crocOptions) if err != nil { fmt.Println(err) return } if err = cr.Receive(); err != nil { fmt.Println(err) return } }, }
View Source
var SendCmd = &cobra.Command{ Use: "send [filename(s) or folder]", Args: cobra.ExactArgs(1), Short: "send file(s), or folder", Long: "send file(s), or folder to pod or any computer", Run: func(cmd *cobra.Command, args []string) { rand.Seed(time.Now().UnixNano()) res, err := http.Get(relayUrl) if err != nil { fmt.Println(err) return } defer res.Body.Close() // Decode the JSON response var response Response err = json.NewDecoder(res.Body).Decode(&response) if err != nil { fmt.Println(err) fmt.Println("Could not get list of relays. Please contact support for help!") return } randomIndex := rand.Intn(len(response.Relays)) relay := response.Relays[randomIndex] crocOptions := Options{ Curve: "p256", Debug: false, DisableLocal: true, HashAlgorithm: "xxhash", IsSender: true, NoPrompt: true, Overwrite: true, RelayAddress: relay.Address, RelayPassword: relay.Password, RelayPorts: strings.Split(relay.Ports, ","), SharedSecret: code, ZipFolder: true, } if crocOptions.RelayAddress != models.DEFAULT_RELAY { crocOptions.RelayAddress6 = "" } else if crocOptions.RelayAddress6 != models.DEFAULT_RELAY6 { crocOptions.RelayAddress = "" } fnames := args if len(fnames) == 0 { fmt.Println("must specify file: croc send [filename(s) or folder]") return } if len(crocOptions.SharedSecret) == 0 { crocOptions.SharedSecret = utils.GetRandomName() } crocOptions.SharedSecret = crocOptions.SharedSecret + "-" + strconv.Itoa(randomIndex) minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders, err := GetFilesInfo(fnames, crocOptions.ZipFolder) if err != nil { return } cr, err := New(crocOptions) if err != nil { fmt.Println(err) return } if err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders); err != nil { fmt.Println(err) } }, }
Functions ¶
Types ¶
type Client ¶
type Client struct { Options Options Pake *pake.Pake Key []byte ExternalIP, ExternalIPConnected string // steps involved in forming relationship Step1ChannelSecured bool Step2FileInfoTransferred bool Step3RecipientRequestFile bool Step4FileTransferred bool Step5CloseChannels bool SuccessfulTransfer bool // send / receive information of all files FilesToTransfer []FileInfo EmptyFoldersToTransfer []FileInfo TotalNumberOfContents int TotalNumberFolders int FilesToTransferCurrentNum int FilesHasFinished map[int]struct{} // send / receive information of current file CurrentFile *os.File CurrentFileChunkRanges []int64 CurrentFileChunks []int64 CurrentFileIsClosed bool LastFolder string TotalSent int64 TotalChunksTransferred int // contains filtered or unexported fields }
Client holds the state of the croc transfer
type FileInfo ¶
type FileInfo struct { Name string `json:"n,omitempty"` FolderRemote string `json:"fr,omitempty"` FolderSource string `json:"fs,omitempty"` Hash []byte `json:"h,omitempty"` Size int64 `json:"s,omitempty"` ModTime time.Time `json:"m,omitempty"` IsCompressed bool `json:"c,omitempty"` IsEncrypted bool `json:"e,omitempty"` Symlink string `json:"sy,omitempty"` Mode os.FileMode `json:"md,omitempty"` TempFile bool `json:"tf,omitempty"` }
FileInfo registers the information about the file
type Options ¶
type Options struct { IsSender bool Debug bool RelayAddress string RelayAddress6 string RelayPorts []string RelayPassword string Stdout bool NoPrompt bool NoMultiplexing bool DisableLocal bool OnlyLocal bool IgnoreStdin bool Ask bool SendingText bool NoCompress bool IP string Overwrite bool Curve string HashAlgorithm string ThrottleUpload string ZipFolder bool }
Options specifies user specific options
type Relay ¶
type RemoteFileRequest ¶
type RemoteFileRequest struct { CurrentFileChunkRanges []int64 FilesToTransferCurrentNum int MachineID string }
RemoteFileRequest requests specific bytes
type SenderInfo ¶
type SenderInfo struct { FilesToTransfer []FileInfo EmptyFoldersToTransfer []FileInfo TotalNumberFolders int MachineID string Ask bool SendingText bool NoCompress bool HashAlgorithm string }
SenderInfo lists the files to be transferred
type TransferOptions ¶
TransferOptions for sending
Click to show internal directories.
Click to hide internal directories.