@@ -584,6 +584,13 @@ func (g *gatewayModule) SetNamedProxy(wlID string, config zos.GatewayNameProxy)
584584 return "" , errors .New ("node doesn't support name proxy (doesn't have a domain)" )
585585 }
586586
587+ // Get public config for node IP validation
588+ netStub := stubs .NewNetworkerLightStub (g .cl )
589+ pubConfig , err := netStub .LoadPublicConfig (ctx )
590+ if err != nil {
591+ return "" , errors .Wrap (err , "failed to load public config" )
592+ }
593+
587594 if err := g .validateNameContract (config .Name , twinID ); err != nil {
588595 return "" , errors .Wrap (err , "failed to verify name contract" )
589596 }
@@ -599,7 +606,7 @@ func (g *gatewayModule) SetNamedProxy(wlID string, config zos.GatewayNameProxy)
599606 },
600607 }
601608
602- if err := g .setupRouting (ctx , wlID , fqdn , gatewayTLSConfig , config .GatewayBase ); err != nil {
609+ if err := g .setupRouting (ctx , wlID , fqdn , gatewayTLSConfig , config .GatewayBase , pubConfig . IPv4 . IP , pubConfig . IPv6 . IP ); err != nil {
603610 return "" , err
604611 }
605612
@@ -618,6 +625,13 @@ func (g *gatewayModule) SetFQDNProxy(wlID string, config zos.GatewayFQDNProxy) e
618625 return err
619626 }
620627
628+ // Get public config for node IP validation
629+ netStub := stubs .NewNetworkerLightStub (g .cl )
630+ pubConfig , err := netStub .LoadPublicConfig (ctx )
631+ if err != nil {
632+ return errors .Wrap (err , "failed to load public config" )
633+ }
634+
621635 if domain != "" && strings .HasSuffix (config .FQDN , domain ) {
622636 return errors .New ("can't create a fqdn workload with a subdomain of the gateway's managed domain" )
623637 }
@@ -633,14 +647,14 @@ func (g *gatewayModule) SetFQDNProxy(wlID string, config zos.GatewayFQDNProxy) e
633647 },
634648 }
635649
636- return g .setupRouting (ctx , wlID , config .FQDN , gatewayTLSConfig , config .GatewayBase )
650+ return g .setupRouting (ctx , wlID , config .FQDN , gatewayTLSConfig , config .GatewayBase , pubConfig . IPv4 . IP , pubConfig . IPv6 . IP )
637651}
638652
639- func (g * gatewayModule ) setupRouting (ctx context.Context , wlID string , fqdn string , tlsConfig TlsConfig , config zos.GatewayBase ) error {
653+ func (g * gatewayModule ) setupRouting (ctx context.Context , wlID string , fqdn string , tlsConfig TlsConfig , config zos.GatewayBase , nodeIPs ... net. IP ) error {
640654 g .domainLock .Lock ()
641655 defer g .domainLock .Unlock ()
642656
643- if err := zos .ValidateBackends (config .Backends , config .TLSPassthrough ); err != nil {
657+ if err := zos .ValidateBackends (config .Backends , config .TLSPassthrough , nodeIPs ... ); err != nil {
644658 return err
645659 }
646660
0 commit comments