mirror of
https://github.com/schollz/croc.git
synced 2024-11-28 09:35:14 +03:00
Initial IPv6 fixes
This commit is contained in:
parent
0beeebc351
commit
827b5d3a86
@ -336,10 +336,16 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if !strings.Contains(c.Options.RelayAddress, ":") {
|
host, port, err := net.SplitHostPort(c.Options.RelayAddress)
|
||||||
// try the default port, 9009
|
if err != nil {
|
||||||
c.Options.RelayAddress += ":9009"
|
log.Errorf("bad relay address %s", c.Options.RelayAddress)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
// Default port to :9009
|
||||||
|
if port == "" {
|
||||||
|
port = "9009"
|
||||||
|
}
|
||||||
|
c.Options.RelayAddress = net.JoinHostPort(host, port)
|
||||||
log.Debugf("establishing connection to %s", c.Options.RelayAddress)
|
log.Debugf("establishing connection to %s", c.Options.RelayAddress)
|
||||||
var banner string
|
var banner string
|
||||||
conn, banner, ipaddr, err := tcp.ConnectToTCPServer(c.Options.RelayAddress, c.Options.RelayPassword, c.Options.SharedSecret[:3], 5*time.Second)
|
conn, banner, ipaddr, err := tcp.ConnectToTCPServer(c.Options.RelayAddress, c.Options.RelayPassword, c.Options.SharedSecret[:3], 5*time.Second)
|
||||||
@ -450,10 +456,16 @@ func (c *Client) Receive() (err error) {
|
|||||||
log.Debugf("discoveries: %+v", discoveries)
|
log.Debugf("discoveries: %+v", discoveries)
|
||||||
log.Debug("establishing connection")
|
log.Debug("establishing connection")
|
||||||
}
|
}
|
||||||
if !strings.Contains(c.Options.RelayAddress, ":") {
|
host, port, err := net.SplitHostPort(c.Options.RelayAddress)
|
||||||
// try the default port, 9009
|
if err != nil {
|
||||||
c.Options.RelayAddress += ":9009"
|
log.Errorf("bad relay address %s", c.Options.RelayAddress)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
// Default port to :9009
|
||||||
|
if port == "" {
|
||||||
|
port = "9009"
|
||||||
|
}
|
||||||
|
c.Options.RelayAddress = net.JoinHostPort(host, port)
|
||||||
log.Debugf("establishing receiver connection to %s", c.Options.RelayAddress)
|
log.Debugf("establishing receiver connection to %s", c.Options.RelayAddress)
|
||||||
var banner string
|
var banner string
|
||||||
c.conn[0], banner, c.ExternalIP, err = tcp.ConnectToTCPServer(c.Options.RelayAddress, c.Options.RelayPassword, c.Options.SharedSecret[:3])
|
c.conn[0], banner, c.ExternalIP, err = tcp.ConnectToTCPServer(c.Options.RelayAddress, c.Options.RelayPassword, c.Options.SharedSecret[:3])
|
||||||
@ -668,7 +680,12 @@ func (c *Client) procesMesssagePake(m message.Message) (err error) {
|
|||||||
log.Debugf("port: [%s]", c.Options.RelayPorts[i])
|
log.Debugf("port: [%s]", c.Options.RelayPorts[i])
|
||||||
go func(j int) {
|
go func(j int) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
server := fmt.Sprintf("%s:%s", strings.Split(c.Options.RelayAddress, ":")[0], c.Options.RelayPorts[j])
|
host, _, err := net.SplitHostPort(c.Options.RelayAddress)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("bad relay address %s", c.Options.RelayAddress)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
server := net.JoinHostPort(host, c.Options.RelayPorts[j])
|
||||||
log.Debugf("connecting to %s", server)
|
log.Debugf("connecting to %s", server)
|
||||||
c.conn[j+1], _, _, err = tcp.ConnectToTCPServer(
|
c.conn[j+1], _, _, err = tcp.ConnectToTCPServer(
|
||||||
server,
|
server,
|
||||||
|
Loading…
Reference in New Issue
Block a user