Skip to content

Commit 90809a8

Browse files
committed
have --local flag bypass public server
1 parent 7f5e3f5 commit 90809a8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

connect.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ func NewConnection(config *AppConfig) (*Connection, error) {
7272
c.UseStdout = config.UseStdout
7373
c.Yes = config.Yes
7474
c.rate = config.Rate
75+
c.Local = config.Local
76+
77+
if c.Local {
78+
c.Yes = true
79+
c.DontEncrypt = true
80+
}
7581

7682
stat, _ := os.Stdin.Stat()
7783
if (stat.Mode() & os.ModeCharDevice) == 0 {
@@ -268,7 +274,9 @@ func (c *Connection) Run() error {
268274
}
269275
}
270276

271-
go func() { runClientError <- c.runClient(c.Server) }()
277+
if !c.Local {
278+
go func() { runClientError <- c.runClient(c.Server) }()
279+
}
272280
return <-runClientError
273281
}
274282

@@ -304,10 +312,11 @@ func (c *Connection) runClient(serverName string) error {
304312
connection, err := net.Dial("tcp", serverName+":"+port)
305313
if err != nil {
306314
if serverName == "cowyo.com" {
307-
fmt.Println("\nCheck http://bit.ly/croc-relay to see if the public server is down or contact the webmaster: @yakczar")
315+
fmt.Fprintf(os.Stderr, "\nCheck http://bit.ly/croc-relay to see if the public server is down or contact the webmaster: @yakczar")
308316
} else {
309317
fmt.Fprintf(os.Stderr, "\nCould not connect to relay %s\n", serverName)
310318
}
319+
fmt.Fprintf(os.Stderr, "Use --local to run locally")
311320
os.Exit(1)
312321
}
313322
defer connection.Close()

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type AppConfig struct {
2020
DontEncrypt bool `yaml:"no-encrypt" flagName:"no-encrypt" flagSName:"g" flagDescribe:"Turn off encryption" default:"false"`
2121
UseStdout bool `yaml:"stdout" flagName:"stdout" flagSName:"o" flagDescribe:"Use stdout" default:"false"`
2222
Yes bool `yaml:"yes" flagName:"yes" flagSName:"y" flagDescribe:"Automatically accept file" default:"false"`
23+
Local bool `yaml:"local" flagName:"local" flagSName:"lo" flagDescribe:"Use local relay when sending" default:"false"`
2324
Server string `yaml:"server" flagName:"server" flagSName:"l" flagDescribe:"Croc relay to use" default:"cowyo.com"`
2425
File string `yaml:"send" flagName:"send" flagSName:"s" flagDescribe:"File to send default:""`
2526
Path string `yaml:"save" flagName:"save" flagSName:"p" flagDescribe:"Path to save to" default:""`

0 commit comments

Comments
 (0)