Compare commits

...

1 Commits

Author SHA1 Message Date
Theodor Signeboen Midtlien
c228ce12e4 Add GetWgPort and return engine config port in grpc call 2026-05-15 12:25:02 +02:00
2 changed files with 16 additions and 1 deletions

View File

@@ -2318,6 +2318,11 @@ func (e *Engine) SetCapture(pc device.PacketCapture) error {
return nil
}
// GetWgPort returns the port currently configured for Wireguard.
func (e *Engine) GetWgPort() int {
return e.config.WgPort
}
// setForwarderCapture propagates capture to the USP filter's forwarder endpoint.
// This captures outbound response packets that bypass the FilteredDevice in netstack mode.
func (e *Engine) setForwarderCapture(pc device.PacketCapture) {

View File

@@ -1446,6 +1446,7 @@ func (s *Server) runProbes(waitForProbeResult bool) {
// GetConfig of the daemon.
func (s *Server) GetConfig(ctx context.Context, req *proto.GetConfigRequest) (*proto.GetConfigResponse, error) {
s.mutex.Lock()
connectClient := s.connectClient
defer s.mutex.Unlock()
if ctx.Err() != nil {
@@ -1522,12 +1523,21 @@ func (s *Server) GetConfig(ctx context.Context, req *proto.GetConfigRequest) (*p
sshJWTCacheTTL = int32(*cfg.SSHJWTCacheTTL)
}
wgPort := int64(cfg.WgPort)
// Get correct assigned port, could be random if cfg.WgPort is 0.
if connectClient != nil && wgPort == 0 {
engine := connectClient.Engine()
if engine != nil {
wgPort = int64(engine.GetWgPort())
}
}
return &proto.GetConfigResponse{
ManagementUrl: managementURL.String(),
PreSharedKey: preSharedKey,
AdminURL: adminURL.String(),
InterfaceName: cfg.WgIface,
WireguardPort: int64(cfg.WgPort),
WireguardPort: wgPort,
Mtu: int64(cfg.MTU),
DisableAutoConnect: cfg.DisableAutoConnect,
ServerSSHAllowed: *cfg.ServerSSHAllowed,