From 8b178881cff9bc91cd776b284897d0d6245692dd Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 17 Jul 2019 14:12:48 -0600 Subject: [PATCH] display relay in UI if not using default Fixes #143 --- src/cli/cli.go | 3 ++- src/croc/croc.go | 6 +++++- src/models/constants.go | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cli/cli.go b/src/cli/cli.go index 5ddc1d58..073be839 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -13,6 +13,7 @@ import ( "time" "github.com/schollz/croc/v6/src/croc" + "github.com/schollz/croc/v6/src/models" "github.com/schollz/croc/v6/src/tcp" "github.com/schollz/croc/v6/src/utils" "github.com/urfave/cli" @@ -66,7 +67,7 @@ func Run() (err error) { cli.BoolFlag{Name: "debug", Usage: "increase verbosity (a lot)"}, cli.BoolFlag{Name: "yes", Usage: "automatically agree to all prompts"}, cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"}, - cli.StringFlag{Name: "relay", Value: "142.93.177.120:9009", Usage: "address of the relay"}, + cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay"}, cli.StringFlag{Name: "out", Value: ".", Usage: "specify an output folder to receive the file"}, } app.EnableBashCompletion = true diff --git a/src/croc/croc.go b/src/croc/croc.go index fdbc326e..d05af884 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -215,7 +215,11 @@ func (c *Client) Send(options TransferOptions) (err error) { } fmt.Fprintf(os.Stderr, "Sending %s (%s)\n", fname, utils.ByteCountDecimal(totalFilesSize)) - fmt.Fprintf(os.Stderr, "Code is: %s\nOn the other computer run\n\ncroc %s\n", c.Options.SharedSecret, c.Options.SharedSecret) + otherRelay := "" + if c.Options.RelayAddress != models.DEFAULT_RELAY { + otherRelay = "--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) // // c.spinner.Suffix = " waiting for recipient..." // c.spinner.Start() // create channel for quitting diff --git a/src/models/constants.go b/src/models/constants.go index f1b11e6e..acb20a7b 100644 --- a/src/models/constants.go +++ b/src/models/constants.go @@ -1,3 +1,4 @@ package models const TCP_BUFFER_SIZE = 1024 * 64 +const DEFAULT_RELAY = "142.93.177.120:9009"