0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

fix sending

This commit is contained in:
Zack Scholl 2018-09-23 14:32:41 -07:00
parent fe38107c42
commit 73c33ebe02

View file

@ -92,14 +92,14 @@ func (c *Croc) Receive(codephrase string) (err error) {
client := http.Client{
Timeout: timeout,
}
resp, err := client.Get(fmt.Sprintf("http://%s:%s/", discovered[0].Address, discovered[0].Payload))
ports := strings.Split(string(discovered[0].Payload), "-")
if len(ports) != 2 {
return errors.New("bad payload")
}
resp, err := client.Get(fmt.Sprintf("http://%s:%s/", discovered[0].Address, ports[0]))
if err == nil {
if resp.StatusCode == http.StatusOK {
// we connected, so use this
ports := strings.Split(string(discovered[0].Payload), "-")
if len(ports) != 2 {
return errors.New("bad payload")
}
return c.sendReceive(discovered[0].Address, ports[0], ports[1], "", codephrase, false, true)
}
} else {