Skip to content

Commit 508e0be

Browse files
authored
Merge pull request #662 from qk-santi/ports-and-transfers
define ports by amount, not individually - v2
2 parents f874e30 + e164440 commit 508e0be

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/cli/cli.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ func Run() (err error) {
7272
&cli.BoolFlag{Name: "no-local", Usage: "disable local relay when sending"},
7373
&cli.BoolFlag{Name: "no-multi", Usage: "disable multiplexing"},
7474
&cli.BoolFlag{Name: "git", Usage: "enable .gitignore respect / don't send ignored files"},
75-
&cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013", Usage: "ports of the local relay (optional)"},
75+
&cli.IntFlag{Name: "port", Value: 9009, Usage: "base port for the relay"},
76+
&cli.IntFlag{Name: "transfers", Value: 4, Usage: "number of ports to use for transfers"},
7677
},
7778
HelpName: "croc send",
7879
Action: send,
@@ -174,10 +175,21 @@ func send(c *cli.Context) (err error) {
174175
setDebugLevel(c)
175176
comm.Socks5Proxy = c.String("socks5")
176177
comm.HttpProxy = c.String("connect")
177-
portsString := c.String("ports")
178-
if portsString == "" {
179-
portsString = "9009,9010,9011,9012,9013"
178+
179+
portParam := c.Int("port")
180+
if portParam == 0 {
181+
portParam = 9009
182+
}
183+
transfersParam := c.Int("transfers")
184+
if transfersParam == 0 {
185+
transfersParam = 4
180186
}
187+
188+
ports := make([]string, transfersParam+1)
189+
for i := 0; i <= transfersParam; i++ {
190+
ports[i] = strconv.Itoa(portParam + i)
191+
}
192+
181193
crocOptions := croc.Options{
182194
SharedSecret: c.String("code"),
183195
IsSender: true,
@@ -189,7 +201,7 @@ func send(c *cli.Context) (err error) {
189201
DisableLocal: c.Bool("no-local"),
190202
OnlyLocal: c.Bool("local"),
191203
IgnoreStdin: c.Bool("ignore-stdin"),
192-
RelayPorts: strings.Split(portsString, ","),
204+
RelayPorts: ports,
193205
Ask: c.Bool("ask"),
194206
NoMultiplexing: c.Bool("no-multi"),
195207
RelayPassword: determinePass(c),

0 commit comments

Comments
 (0)