Skip to content

Commit

Permalink
have --local flag bypass public server
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Apr 25, 2018
1 parent 7f5e3f5 commit 90809a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ func NewConnection(config *AppConfig) (*Connection, error) {
c.UseStdout = config.UseStdout
c.Yes = config.Yes
c.rate = config.Rate
c.Local = config.Local

if c.Local {
c.Yes = true
c.DontEncrypt = true
}

stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
Expand Down Expand Up @@ -268,7 +274,9 @@ func (c *Connection) Run() error {
}
}

go func() { runClientError <- c.runClient(c.Server) }()
if !c.Local {
go func() { runClientError <- c.runClient(c.Server) }()
}
return <-runClientError
}

Expand Down Expand Up @@ -304,10 +312,11 @@ func (c *Connection) runClient(serverName string) error {
connection, err := net.Dial("tcp", serverName+":"+port)
if err != nil {
if serverName == "cowyo.com" {
fmt.Println("\nCheck http://bit.ly/croc-relay to see if the public server is down or contact the webmaster: @yakczar")
fmt.Fprintf(os.Stderr, "\nCheck http://bit.ly/croc-relay to see if the public server is down or contact the webmaster: @yakczar")
} else {
fmt.Fprintf(os.Stderr, "\nCould not connect to relay %s\n", serverName)
}
fmt.Fprintf(os.Stderr, "Use --local to run locally")
os.Exit(1)
}
defer connection.Close()
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type AppConfig struct {
DontEncrypt bool `yaml:"no-encrypt" flagName:"no-encrypt" flagSName:"g" flagDescribe:"Turn off encryption" default:"false"`
UseStdout bool `yaml:"stdout" flagName:"stdout" flagSName:"o" flagDescribe:"Use stdout" default:"false"`
Yes bool `yaml:"yes" flagName:"yes" flagSName:"y" flagDescribe:"Automatically accept file" default:"false"`
Local bool `yaml:"local" flagName:"local" flagSName:"lo" flagDescribe:"Use local relay when sending" default:"false"`
Server string `yaml:"server" flagName:"server" flagSName:"l" flagDescribe:"Croc relay to use" default:"cowyo.com"`
File string `yaml:"send" flagName:"send" flagSName:"s" flagDescribe:"File to send default:""`
Path string `yaml:"save" flagName:"save" flagSName:"p" flagDescribe:"Path to save to" default:""`
Expand Down

0 comments on commit 90809a8

Please sign in to comment.