Skip to content

Commit

Permalink
Merge pull request #433 from nkryuchkov/fix/sudph-bug
Browse files Browse the repository at this point in the history
Fix SUDPH bug

Former-commit-id: 5ad7ef5
  • Loading branch information
nkryuchkov committed Jul 8, 2020
2 parents a6a2620 + 39b1e63 commit 3bc4e25
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/snet/arclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import (
)

const (
// sudphPriority is used to set an order how connection filters apply.
sudphPriority = 1
stcprBindPath = "/bind/stcpr"
addrChSize = 1024
udpKeepAliveInterval = 10 * time.Second
udpKeepAliveMessage = "keepalive"
// sudphPriority is used to set an order how connection filters apply.
sudphPriority = 1
defaultUDPPort = "30178"
)

var (
Expand Down Expand Up @@ -91,16 +92,23 @@ func NewHTTP(remoteAddr string, pk cipher.PubKey, sk cipher.SecKey) (APIClient,
return nil, fmt.Errorf("parse URL: %w", err)
}

remoteUDP := remoteURL.Host
if _, _, err := net.SplitHostPort(remoteUDP); err != nil {
remoteUDP = net.JoinHostPort(remoteUDP, defaultUDPPort)
}

client := &httpClient{
log: logging.MustGetLogger("address-resolver"),
pk: pk,
sk: sk,
remoteHTTPAddr: remoteAddr,
remoteUDPAddr: remoteURL.Host,
remoteUDPAddr: remoteUDP,
ready: make(chan struct{}),
closed: make(chan struct{}),
}

client.log.Infof("Remote UDP server: %q", remoteUDP)

go client.initHTTPClient()

return client, nil
Expand Down

0 comments on commit 3bc4e25

Please sign in to comment.