Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SUDPH bug #433

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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