Skip to content

Commit

Permalink
update readme and cli
Browse files Browse the repository at this point in the history
  • Loading branch information
RCL98 committed Nov 7, 2023
1 parent c5ecc78 commit 6f8039b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Status"></a>
- provides **end-to-end encryption** (using PAKE)
- enables easy **cross-platform** transfers (Windows, Linux, Mac)
- allows **multiple file** transfers
- allows **multiple sequential** transfers
- allows **resuming transfers** that are interrupted
- local server or port-forwarding **not needed**
- **ipv6-first** with ipv4 fallback
Expand Down Expand Up @@ -134,6 +135,33 @@ The code phrase is used to establish password-authenticated key agreement ([PAKE

There are a number of configurable options (see `--help`). A set of options (like custom relay, ports, and code phrase) can be set using `--remember`.

### Transfer on LAN only

You can transfer files using only local connections.

```
crorc --local send [file(s)-or-folder]
```

### Allow multiple sequential transfers

By default, after a transfer was done the program stops.
You can allow more than one transfer to happen (one after another) by using the `--multuple` flag which requires a value >= 1.

```
croc send --multiple [nr-of-transfers] [file(s)-or-folder]
```

After all `[nr-of-transfers]` were done, the program will stop. To prevent keeping the program running forever if not all transfers
possibilities are used, a timeout is set on the connection with the relay. By default, this `timeout` is set to `30 seconds`, which is
likely not enough. If you want to keep the connection alive for more time you can use the `--timeout` flag like this:

```
croc send --timeout [nr-of-seconds] (--multiple [nr-of-transfers]) [file(s)-or-folder]
```

*NOTE*: You can't keep the connection alive for more than `1 hour`.

### Custom code phrase

You can send with your own code phrase (must be more than 6 characters).
Expand Down Expand Up @@ -213,7 +241,7 @@ The relay is needed to staple the parallel incoming and outgoing connections. By
croc relay
```

By default it uses TCP ports 9009-9013. Make sure to open those up. You can customize the ports (e.g. `croc relay --ports 1111,1112`), but you must have a minimum of **2** ports for the relay. The first port is for communication and the subsequent ports are used for the multiplexed data transfer.
By default it uses TCP ports 9009-9013. Make sure to open those up. You can customized the ports (e.g. `croc relay --ports 1111,1112`), but you must have a minimum of **2** ports for the relay. The first port is for communication and the subsequent ports are used for the multiplexed data transfer.

You can send files using your relay by entering `--relay` to change the relay that you are using if you want to custom host your own.

Expand Down
22 changes: 11 additions & 11 deletions src/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func Run() (err error) {
app.UsageText = `Send a file:
croc send file.txt
-git to respect your .gitignore
Send multiple files:
croc send file1.txt file2.txt file3.txt
or
Expand All @@ -66,14 +65,13 @@ func Run() (err error) {
ArgsUsage: "[filename(s) or folder]",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "zip", Usage: "zip folder before sending"},
&cli.IntFlag{Name: "timelimit", Value: 5, Usage: "timelimit in secods for sender to allow all transfers"},
&cli.IntFlag{Name: "timelimit", Value: 30, Usage: "timelimit in secods for sender to allow all transfers"},
&cli.IntFlag{Name: "multiple", Value: 1, Usage: "maximum number of transfers"},
&cli.StringFlag{Name: "code", Aliases: []string{"c"}, Usage: "codephrase used to connect to relay"},
&cli.StringFlag{Name: "hash", Value: "xxhash", Usage: "hash algorithm (xxhash, imohash, md5)"},
&cli.StringFlag{Name: "text", Aliases: []string{"t"}, Usage: "send some text"},
&cli.BoolFlag{Name: "no-local", Usage: "disable local relay when sending"},
&cli.BoolFlag{Name: "no-multi", Usage: "disable multiplexing"},
&cli.BoolFlag{Name: "git", Usage: "enable .gitignore respect / don't send ignored files"},
&cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"},
},
HelpName: "croc send",
Expand Down Expand Up @@ -204,20 +202,25 @@ func send(c *cli.Context) (err error) {
HashAlgorithm: c.String("hash"),
ThrottleUpload: c.String("throttleUpload"),
ZipFolder: c.Bool("zip"),
GitIgnore: c.Bool("git"),
}

if crocOptions.TimeLimit <= 0 {
fmt.Println("timelimit must be greater than 0. Defaulting to 360 seconds.")
crocOptions.TimeLimit = 5
fmt.Println("timelimit must be greater than 0. Defaulting to 30 seconds.")
crocOptions.TimeLimit = 30
} else if crocOptions.TimeLimit > 3600 {
fmt.Println("timelimit must be less than 3600. Defaulting to 30 seconds.")
crocOptions.TimeLimit = 5
crocOptions.TimeLimit = 30
}

if crocOptions.MaxTransfers <= 0 {
fmt.Println("multiple must be greater than 0. Defaulting to 1 transfers.")
crocOptions.MaxTransfers = 1
} else if crocOptions.MaxTransfers > 1 {
fmt.Println("Allowing multiple transfers.")
fmt.Println("The connection will stay open until all transfers are complete, or the timelimit is reached.")
fmt.Printf("The current timelimit is %d seconds.\n", crocOptions.TimeLimit)
}

if crocOptions.RelayAddress != models.DEFAULT_RELAY {
crocOptions.RelayAddress6 = ""
} else if crocOptions.RelayAddress6 != models.DEFAULT_RELAY6 {
Expand Down Expand Up @@ -263,9 +266,6 @@ func send(c *cli.Context) (err error) {
if !c.IsSet("hash") {
crocOptions.HashAlgorithm = rememberedOptions.HashAlgorithm
}
if !c.IsSet("git") {
crocOptions.GitIgnore = rememberedOptions.GitIgnore
}
}

var fnames []string
Expand Down Expand Up @@ -304,7 +304,7 @@ func send(c *cli.Context) (err error) {
// generate code phrase
crocOptions.SharedSecret = utils.GetRandomName()
}
minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders, err := croc.GetFilesInfo(fnames, crocOptions.ZipFolder, crocOptions.GitIgnore)
minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders, err := croc.GetFilesInfo(fnames, crocOptions.ZipFolder)

Check failure on line 307 in src/cli/cli.go

View workflow job for this annotation

GitHub Actions / Go unit tests

not enough arguments in call to croc.GetFilesInfo
if err != nil {
return
}
Expand Down

0 comments on commit 6f8039b

Please sign in to comment.