Skip to content

Commit

Permalink
[patch] ✨ Add DNS resolver to resolve Server IPs
Browse files Browse the repository at this point in the history
Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>
  • Loading branch information
rinx committed Mar 5, 2021
1 parent 893fb78 commit 62d7134
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/alvd/agent/service/tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ func (t *tunnel) Start(ctx context.Context) <-chan error {
}
return
case addr := <-t.connectCh:
host, port, err := net.SplitHostPort(addr)
if err == nil {
ips, err := net.DefaultResolver.LookupIPAddr(ctx, host)
if err == nil {
for _, ip := range ips {
t.connect(ctx, net.JoinHostPort(ip.String(), port))
}
continue
}
}

t.connect(ctx, addr)
case addr := <-t.disconnectCh:
t.disconnect(ctx, addr)
Expand Down

0 comments on commit 62d7134

Please sign in to comment.