mirror of https://github.com/schollz/croc.git
have --local flag bypass public server
This commit is contained in:
parent
7f5e3f50a0
commit
90809a80a1
11
connect.go
11
connect.go
|
@ -72,6 +72,12 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
c.UseStdout = config.UseStdout
|
c.UseStdout = config.UseStdout
|
||||||
c.Yes = config.Yes
|
c.Yes = config.Yes
|
||||||
c.rate = config.Rate
|
c.rate = config.Rate
|
||||||
|
c.Local = config.Local
|
||||||
|
|
||||||
|
if c.Local {
|
||||||
|
c.Yes = true
|
||||||
|
c.DontEncrypt = true
|
||||||
|
}
|
||||||
|
|
||||||
stat, _ := os.Stdin.Stat()
|
stat, _ := os.Stdin.Stat()
|
||||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||||
|
@ -268,7 +274,9 @@ func (c *Connection) Run() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !c.Local {
|
||||||
go func() { runClientError <- c.runClient(c.Server) }()
|
go func() { runClientError <- c.runClient(c.Server) }()
|
||||||
|
}
|
||||||
return <-runClientError
|
return <-runClientError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,10 +312,11 @@ func (c *Connection) runClient(serverName string) error {
|
||||||
connection, err := net.Dial("tcp", serverName+":"+port)
|
connection, err := net.Dial("tcp", serverName+":"+port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if serverName == "cowyo.com" {
|
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 {
|
} else {
|
||||||
fmt.Fprintf(os.Stderr, "\nCould not connect to relay %s\n", serverName)
|
fmt.Fprintf(os.Stderr, "\nCould not connect to relay %s\n", serverName)
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(os.Stderr, "Use --local to run locally")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
|
|
1
main.go
1
main.go
|
@ -20,6 +20,7 @@ type AppConfig struct {
|
||||||
DontEncrypt bool `yaml:"no-encrypt" flagName:"no-encrypt" flagSName:"g" flagDescribe:"Turn off encryption" default:"false"`
|
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"`
|
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"`
|
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"`
|
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:""`
|
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:""`
|
Path string `yaml:"save" flagName:"save" flagSName:"p" flagDescribe:"Path to save to" default:""`
|
||||||
|
|
Loading…
Reference in New Issue