Skip to content

Commit da024c2

Browse files
authored
Merge pull request #3512 from gravitl/kwesi/net-2066-auto-apply-changes-on-desktop-app
fix: update extclient ingress endpoint/port with host changes
2 parents 4bc6f3d + 91c5fe0 commit da024c2

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

controllers/hosts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ func updateHost(w http.ResponseWriter, r *http.Request) {
308308
}
309309
}
310310
}()
311+
311312
logic.LogEvent(&models.Event{
312313
Action: models.Update,
313314
Source: models.Subject{

pro/controllers/users.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,12 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
13041304
if extClient.DNS == "" {
13051305
extClient.DNS = node.IngressDNS
13061306
}
1307+
1308+
extClient.IngressGatewayEndpoint = utils.GetExtClientEndpoint(
1309+
host.EndpointIP,
1310+
host.EndpointIPv6,
1311+
logic.GetPeerListenPort(host),
1312+
)
13071313
extClient.AllowedIPs = logic.GetExtclientAllowedIPs(extClient)
13081314
gws = append(gws, models.UserRemoteGws{
13091315
GwID: node.ID.String(),

utils/utils.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package utils
22

33
import (
4+
"fmt"
45
"log/slog"
6+
"net"
57
"runtime"
68
"strings"
79
"time"
@@ -75,3 +77,12 @@ func NoEmptyStringToCsv(strs ...string) string {
7577
}
7678
return sb.String()
7779
}
80+
81+
// GetExtClientEndpoint returns the external client endpoint in the format "host:port" or "[host]:port" for IPv6
82+
func GetExtClientEndpoint(hostIpv4Endpoint, hostIpv6Endpoint net.IP, hostListenPort int) string {
83+
if hostIpv4Endpoint.To4() == nil {
84+
return fmt.Sprintf("[%s]:%d", hostIpv6Endpoint.String(), hostListenPort)
85+
} else {
86+
return fmt.Sprintf("%s:%d", hostIpv4Endpoint.String(), hostListenPort)
87+
}
88+
}

0 commit comments

Comments
 (0)