@@ -107,6 +107,11 @@ func New(cfg *config.Config, configPath string) *Server {
107107 if err := securityManager .InitNginxConfigs (nginxConfigPath ); err != nil {
108108 log .Printf ("Warning: Failed to initialize security nginx configs: %v" , err )
109109 }
110+ // Add Docker gateway IP to whitelist
111+ gatewayIP := infraManager .GetDockerHostIP ()
112+ if err := securityManager .AddDockerGatewayToWhitelist (gatewayIP ); err != nil {
113+ log .Printf ("Warning: Failed to add Docker gateway to whitelist: %v" , err )
114+ }
110115 }
111116 }
112117
@@ -284,6 +289,9 @@ func (s *Server) setupRoutes() {
284289 protected .POST ("/security/protected-routes" , s .addProtectedRoute )
285290 protected .PUT ("/security/protected-routes/:id" , s .updateProtectedRoute )
286291 protected .DELETE ("/security/protected-routes/:id" , s .deleteProtectedRoute )
292+ protected .GET ("/security/whitelist" , s .listWhitelist )
293+ protected .POST ("/security/whitelist" , s .addWhitelistEntry )
294+ protected .DELETE ("/security/whitelist/:id" , s .removeWhitelistEntry )
287295 protected .GET ("/security/realtime-capture" , s .getRealtimeCaptureStatus )
288296 protected .PUT ("/security/realtime-capture" , s .setRealtimeCaptureStatus )
289297 protected .GET ("/security/health" , s .getSecurityHealth )
@@ -295,6 +303,7 @@ func (s *Server) setupRoutes() {
295303 // Traffic endpoints
296304 protected .GET ("/traffic/logs" , s .getTrafficLogs )
297305 protected .GET ("/traffic/stats" , s .getTrafficStats )
306+ protected .GET ("/traffic/unknown-domains" , s .getUnknownDomainStats )
298307 protected .POST ("/traffic/cleanup" , s .cleanupTrafficLogs )
299308 protected .GET ("/deployments/:name/traffic" , s .getDeploymentTrafficStats )
300309 }
@@ -303,8 +312,9 @@ func (s *Server) setupRoutes() {
303312 api .POST ("/security/events/ingest" , s .ingestSecurityEvent )
304313 api .POST ("/traffic/ingest" , s .ingestTrafficLog )
305314
306- // Internal nginx endpoint - token-authenticated for blocked IPs
315+ // Internal nginx endpoints - token-authenticated
307316 api .GET ("/_internal/blocked-ips" , s .listBlockedIPsInternal )
317+ api .GET ("/_internal/whitelist" , s .listWhitelistInternal )
308318 }
309319}
310320
@@ -1185,12 +1195,13 @@ func (s *Server) getSettings(c *gin.Context) {
11851195 "subdomain_style" : s .config .Domain .SubdomainStyle ,
11861196 },
11871197 "nginx" : gin.H {
1188- "enabled" : s .config .Nginx .Enabled ,
1189- "image" : s .config .Nginx .Image ,
1190- "container_name" : s .config .Nginx .ContainerName ,
1191- "config_path" : s .config .Nginx .ConfigPath ,
1192- "reload_command" : s .config .Nginx .ReloadCommand ,
1193- "external" : s .config .Nginx .External ,
1198+ "enabled" : s .config .Nginx .Enabled ,
1199+ "image" : s .config .Nginx .Image ,
1200+ "container_name" : s .config .Nginx .ContainerName ,
1201+ "config_path" : s .config .Nginx .ConfigPath ,
1202+ "reload_command" : s .config .Nginx .ReloadCommand ,
1203+ "external" : s .config .Nginx .External ,
1204+ "reject_unknown_domains" : s .config .Nginx .RejectUnknownDomains ,
11941205 },
11951206 "certbot" : gin.H {
11961207 "enabled" : s .config .Certbot .Enabled ,
@@ -1241,12 +1252,13 @@ func (s *Server) updateSettings(c *gin.Context) {
12411252 SubdomainStyle string `json:"subdomain_style"`
12421253 } `json:"domain,omitempty"`
12431254 Nginx * struct {
1244- Enabled bool `json:"enabled"`
1245- Image string `json:"image"`
1246- ContainerName string `json:"container_name"`
1247- ConfigPath string `json:"config_path"`
1248- ReloadCommand string `json:"reload_command"`
1249- External bool `json:"external"`
1255+ Enabled bool `json:"enabled"`
1256+ Image string `json:"image"`
1257+ ContainerName string `json:"container_name"`
1258+ ConfigPath string `json:"config_path"`
1259+ ReloadCommand string `json:"reload_command"`
1260+ External bool `json:"external"`
1261+ RejectUnknownDomains * bool `json:"reject_unknown_domains"`
12501262 } `json:"nginx,omitempty"`
12511263 Certbot * struct {
12521264 Enabled bool `json:"enabled"`
@@ -1318,6 +1330,9 @@ func (s *Server) updateSettings(c *gin.Context) {
13181330 if req .Nginx .ReloadCommand != "" {
13191331 s .config .Nginx .ReloadCommand = req .Nginx .ReloadCommand
13201332 }
1333+ if req .Nginx .RejectUnknownDomains != nil {
1334+ s .config .Nginx .RejectUnknownDomains = * req .Nginx .RejectUnknownDomains
1335+ }
13211336 }
13221337
13231338 if req .Certbot != nil {
@@ -1426,12 +1441,13 @@ func (s *Server) updateSettings(c *gin.Context) {
14261441 "subdomain_style" : s .config .Domain .SubdomainStyle ,
14271442 },
14281443 "nginx" : gin.H {
1429- "enabled" : s .config .Nginx .Enabled ,
1430- "image" : s .config .Nginx .Image ,
1431- "container_name" : s .config .Nginx .ContainerName ,
1432- "config_path" : s .config .Nginx .ConfigPath ,
1433- "reload_command" : s .config .Nginx .ReloadCommand ,
1434- "external" : s .config .Nginx .External ,
1444+ "enabled" : s .config .Nginx .Enabled ,
1445+ "image" : s .config .Nginx .Image ,
1446+ "container_name" : s .config .Nginx .ContainerName ,
1447+ "config_path" : s .config .Nginx .ConfigPath ,
1448+ "reload_command" : s .config .Nginx .ReloadCommand ,
1449+ "external" : s .config .Nginx .External ,
1450+ "reject_unknown_domains" : s .config .Nginx .RejectUnknownDomains ,
14351451 },
14361452 "certbot" : gin.H {
14371453 "enabled" : s .config .Certbot .Enabled ,
@@ -2793,13 +2809,25 @@ func (s *Server) getSystemStats(c *gin.Context) {
27932809 imageStats , _ := s .networksManager .GetImageStats ()
27942810 volumeStats , _ := s .networksManager .GetVolumeStats ()
27952811
2812+ var networkCount , portCount int
2813+ if networks , err := s .networksManager .ListNetworks (); err == nil {
2814+ networkCount = len (networks )
2815+ }
2816+ if containers , err := s .networksManager .ListContainers (); err == nil {
2817+ for _ , container := range containers {
2818+ portCount += len (container .Ports )
2819+ }
2820+ }
2821+
27962822 systemStats , _ := system .GetSystemStats ()
27972823
27982824 c .JSON (http .StatusOK , gin.H {
27992825 "deployments" : stats ,
28002826 "containers" : containerStats ,
28012827 "images" : imageStats ,
28022828 "volumes" : volumeStats ,
2829+ "networks" : gin.H {"total" : networkCount },
2830+ "ports" : gin.H {"total" : portCount },
28032831 "system" : systemStats ,
28042832 })
28052833}
0 commit comments