diff --git a/src/cli/cli.go b/src/cli/cli.go index 4564d7b..76b2c58 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -88,7 +88,7 @@ func Run() (err error) { &cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay", EnvVars: []string{"CROC_RELAY"}}, &cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay", EnvVars: []string{"CROC_RELAY6"}}, &cli.StringFlag{Name: "out", Value: ".", Usage: "specify an output folder to receive the file"}, - &cli.StringFlag{Name: "pass", Value: "pass123", Usage: "password for the relay", EnvVars: []string{"CROC_PASS"}}, + &cli.StringFlag{Name: "pass", Value: models.DEFAULT_PASSPHRASE, Usage: "password for the relay", EnvVars: []string{"CROC_PASS"}}, &cli.StringFlag{Name: "socks5", Value: "", Usage: "add a socks5 proxy", EnvVars: []string{"SOCKS5_PROXY"}}, } app.EnableBashCompletion = true diff --git a/src/croc/croc.go b/src/croc/croc.go index d6046f7..b11e7e5 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -347,11 +347,14 @@ func (c *Client) Send(options TransferOptions) (err error) { if err != nil { return } - otherRelay := "" + flags := &strings.Builder{} if c.Options.RelayAddress != models.DEFAULT_RELAY { - otherRelay = "--relay " + c.Options.RelayAddress + " " + flags.WriteString("--relay " + c.Options.RelayAddress + " ") } - fmt.Fprintf(os.Stderr, "Code is: %s\nOn the other computer run\n\ncroc %s%s\n", c.Options.SharedSecret, otherRelay, c.Options.SharedSecret) + if c.Options.RelayPassword != models.DEFAULT_PASSPHRASE { + flags.WriteString("--pass " + c.Options.RelayPassword + " ") + } + fmt.Fprintf(os.Stderr, "Code is: %[1]s\nOn the other computer run\n\ncroc %[2]s%[1]s\n", c.Options.SharedSecret, flags.String()) if c.Options.Ask { machid, _ := machineid.ID() fmt.Fprintf(os.Stderr, "\rYour machine ID is '%s'\n", machid) diff --git a/src/models/constants.go b/src/models/constants.go index 283730b..1c41219 100644 --- a/src/models/constants.go +++ b/src/models/constants.go @@ -6,9 +6,12 @@ import "net" const TCP_BUFFER_SIZE = 1024 * 64 // DEFAULT_RELAY is the default relay used (can be set using --relay) -var DEFAULT_RELAY = "croc.schollz.com" -var DEFAULT_RELAY6 = "croc6.schollz.com" -var DEFAULT_PORT = "9009" +var ( + DEFAULT_RELAY = "croc.schollz.com" + DEFAULT_RELAY6 = "croc6.schollz.com" + DEFAULT_PORT = "9009" + DEFAULT_PASSPHRASE = "pass123" +) func init() { iprecords, _ := net.LookupIP(DEFAULT_RELAY)