mirror of https://github.com/schollz/croc.git
add testing
This commit is contained in:
parent
9e280d7f48
commit
63feece074
|
@ -95,6 +95,7 @@ func Run() (err error) {
|
|||
&cli.BoolFlag{Name: "local", Usage: "force to use only local connections"},
|
||||
&cli.BoolFlag{Name: "ignore-stdin", Usage: "ignore piped stdin"},
|
||||
&cli.BoolFlag{Name: "overwrite", Usage: "do not prompt to overwrite"},
|
||||
&cli.BoolFlag{Name: "testing", Usage: "flag for testing purposes"},
|
||||
&cli.StringFlag{Name: "curve", Value: "p256", Usage: "choose an encryption curve (" + strings.Join(pake.AvailableCurves(), ", ") + ")"},
|
||||
&cli.StringFlag{Name: "ip", Value: "", Usage: "set sender ip if known e.g. 10.0.0.1:9009, [::1]:9009"},
|
||||
&cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay", EnvVars: []string{"CROC_RELAY"}},
|
||||
|
@ -368,6 +369,7 @@ func receive(c *cli.Context) (err error) {
|
|||
IP: c.String("ip"),
|
||||
Overwrite: c.Bool("overwrite"),
|
||||
Curve: c.String("curve"),
|
||||
TestFlag: c.Bool("testing"),
|
||||
}
|
||||
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
||||
crocOptions.RelayAddress6 = ""
|
||||
|
|
|
@ -76,6 +76,7 @@ type Options struct {
|
|||
HashAlgorithm string
|
||||
ThrottleUpload string
|
||||
ZipFolder bool
|
||||
TestFlag bool
|
||||
}
|
||||
|
||||
// Client holds the state of the croc transfer
|
||||
|
@ -780,7 +781,10 @@ func (c *Client) Receive() (err error) {
|
|||
log.Debugf("receiver connection established: %+v", c.conn[0])
|
||||
log.Debugf("banner: %s", banner)
|
||||
|
||||
if !usingLocal && !c.Options.DisableLocal && !isIPset {
|
||||
if c.Options.TestFlag {
|
||||
log.Debugf("TEST FLAG ENABLED, TESTING LOCAL IPS")
|
||||
}
|
||||
if c.Options.TestFlag || (!usingLocal && !c.Options.DisableLocal && !isIPset) {
|
||||
// ask the sender for their local ips and port
|
||||
// and try to connect to them
|
||||
log.Debug("sending ips?")
|
||||
|
@ -807,8 +811,10 @@ func (c *Client) Receive() (err error) {
|
|||
haveLocalIP := false
|
||||
for _, localIP := range localIps {
|
||||
localIPparsed := net.ParseIP(localIP)
|
||||
log.Debugf("localIP: %+v, localIPparsed: %+v", localIP, localIPparsed)
|
||||
if ipv4Net.Contains(localIPparsed) {
|
||||
haveLocalIP = true
|
||||
log.Debugf("ip: %+v is a local IP", ip)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue