mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
sender should be able to connect to the port
This commit is contained in:
parent
4be02ad249
commit
883dff96b8
2 changed files with 8 additions and 8 deletions
|
@ -55,9 +55,6 @@ func Run() (err error) {
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return relay(c)
|
return relay(c)
|
||||||
},
|
},
|
||||||
Flags: []cli.Flag{
|
|
||||||
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013,9014,9015,9016,9017,9018", Usage: "ports of the relay"},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
|
@ -66,6 +63,7 @@ func Run() (err error) {
|
||||||
cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"},
|
cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"},
|
||||||
cli.StringFlag{Name: "relay", Value: "198.199.67.130:9009", Usage: "address of the relay"},
|
cli.StringFlag{Name: "relay", Value: "198.199.67.130:9009", Usage: "address of the relay"},
|
||||||
cli.StringFlag{Name: "out", Value: ".", Usage: "specify an output folder to receive the file"},
|
cli.StringFlag{Name: "out", Value: ".", Usage: "specify an output folder to receive the file"},
|
||||||
|
cli.StringFlag{Name: "ports", Value: "9009,9010,9011,9012,9013,9014,9015,9016,9017,9018", Usage: "ports of the relay"},
|
||||||
}
|
}
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.HideHelp = false
|
app.HideHelp = false
|
||||||
|
@ -166,6 +164,7 @@ func send(c *cli.Context) (err error) {
|
||||||
NoPrompt: c.GlobalBool("yes"),
|
NoPrompt: c.GlobalBool("yes"),
|
||||||
RelayAddress: c.GlobalString("relay"),
|
RelayAddress: c.GlobalString("relay"),
|
||||||
Stdout: c.GlobalBool("stdout"),
|
Stdout: c.GlobalBool("stdout"),
|
||||||
|
RelayPorts: strings.Split(c.GlobalString("ports"), ","),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -214,7 +213,7 @@ func relay(c *cli.Context) (err error) {
|
||||||
if c.GlobalBool("debug") {
|
if c.GlobalBool("debug") {
|
||||||
debugString = "debug"
|
debugString = "debug"
|
||||||
}
|
}
|
||||||
ports := strings.Split(c.String("ports"), ",")
|
ports := strings.Split(c.GlobalString("ports"), ",")
|
||||||
tcpPorts := strings.Join(ports[1:], ",")
|
tcpPorts := strings.Join(ports[1:], ",")
|
||||||
for i, port := range ports {
|
for i, port := range ports {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
|
@ -227,7 +226,7 @@ func relay(c *cli.Context) (err error) {
|
||||||
}
|
}
|
||||||
}(port)
|
}(port)
|
||||||
}
|
}
|
||||||
return tcp.Run(debugString, ports[0],tcpPorts)
|
return tcp.Run(debugString, ports[0], tcpPorts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func dirSize(path string) (int64, error) {
|
// func dirSize(path string) (int64, error) {
|
||||||
|
|
|
@ -231,12 +231,13 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
if !c.Options.DisableLocal {
|
if !c.Options.DisableLocal {
|
||||||
// setup the relay locally
|
// setup the relay locally
|
||||||
for _, port := range c.Options.RelayPorts {
|
for _, port := range c.Options.RelayPorts {
|
||||||
|
|
||||||
go func(portStr string) {
|
go func(portStr string) {
|
||||||
debugString := "warn"
|
debugString := "warn"
|
||||||
if c.Options.Debug {
|
if c.Options.Debug {
|
||||||
debugString = "debug"
|
debugString = "debug"
|
||||||
}
|
}
|
||||||
err = tcp.Run(debugString, portStr, strings.Join(c.Options.RelayPorts, ","))
|
err = tcp.Run(debugString, portStr, strings.Join(c.Options.RelayPorts[1:], ","))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -262,10 +263,10 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
log.Debug("establishing connection")
|
log.Debug("establishing connection")
|
||||||
var banner string
|
var banner string
|
||||||
conn, banner, err := tcp.ConnectToTCPServer("localhost:9001", c.Options.SharedSecret)
|
conn, banner, err := tcp.ConnectToTCPServer("localhost:"+c.Options.RelayPorts[0], c.Options.SharedSecret)
|
||||||
log.Debugf("banner: %s", banner)
|
log.Debugf("banner: %s", banner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, fmt.Sprintf("could not connect to %s", c.Options.RelayAddress))
|
err = errors.Wrap(err, fmt.Sprintf("could not connect to localhost:%s", c.Options.RelayPorts[0]))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debugf("connection established: %+v", conn)
|
log.Debugf("connection established: %+v", conn)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue