mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
connect in parallel
This commit is contained in:
parent
e54045ef5a
commit
4f20f3ce43
1 changed files with 17 additions and 12 deletions
|
@ -317,18 +317,24 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// connects to the other ports of the server for transfer
|
// connects to the other ports of the server for transfer
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(len(c.Options.RelayPorts) - 1)
|
||||||
for i := 1; i < len(c.Options.RelayPorts); i++ {
|
for i := 1; i < len(c.Options.RelayPorts); i++ {
|
||||||
c.conn[i], err = tcp.ConnectToTCPServer(
|
go func(j int) {
|
||||||
fmt.Sprintf("%s:%s", c.Options.RelayAddress, c.Options.RelayPorts[i]),
|
defer wg.Done()
|
||||||
fmt.Sprintf("%s-%d", utils.SHA256(c.Options.SharedSecret)[:7], i),
|
c.conn[j], err = tcp.ConnectToTCPServer(
|
||||||
)
|
fmt.Sprintf("%s:%s", c.Options.RelayAddress, c.Options.RelayPorts[j]),
|
||||||
if err != nil {
|
fmt.Sprintf("%s-%d", utils.SHA256(c.Options.SharedSecret)[:7], j),
|
||||||
return true, err
|
)
|
||||||
}
|
if err != nil {
|
||||||
if !c.Options.IsSender {
|
panic(err)
|
||||||
go c.receiveData(i)
|
}
|
||||||
}
|
if !c.Options.IsSender {
|
||||||
|
go c.receiveData(j)
|
||||||
|
}
|
||||||
|
}(i)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
c.Step1ChannelSecured = true
|
c.Step1ChannelSecured = true
|
||||||
}
|
}
|
||||||
case "error":
|
case "error":
|
||||||
|
@ -631,8 +637,7 @@ func (c *Client) sendData(i int) {
|
||||||
}
|
}
|
||||||
c.bar.Add(n)
|
c.bar.Add(n)
|
||||||
c.TotalSent += int64(n)
|
c.TotalSent += int64(n)
|
||||||
log.Debug(c.TotalSent)
|
// time.Sleep(100 * time.Millisecond)
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curi++
|
curi++
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue