expandServices returns a list of services that have been expanded from the vserver configuration.
()
| 299 | // expandServices returns a list of services that have been expanded from the |
| 300 | // vserver configuration. |
| 301 | func (v *vserver) expandServices() map[serviceKey]*service { |
| 302 | if v.config.UseFWM { |
| 303 | return v.expandFWMServices() |
| 304 | } |
| 305 | |
| 306 | svcs := make(map[serviceKey]*service) |
| 307 | for _, af := range seesaw.AFs() { |
| 308 | var ip net.IP |
| 309 | switch af { |
| 310 | case seesaw.IPv4: |
| 311 | ip = v.config.Host.IPv4Addr |
| 312 | case seesaw.IPv6: |
| 313 | ip = v.config.Host.IPv6Addr |
| 314 | } |
| 315 | if ip == nil { |
| 316 | continue |
| 317 | } |
| 318 | for _, entry := range v.config.Entries { |
| 319 | svc := &service{ |
| 320 | serviceKey: serviceKey{ |
| 321 | af: af, |
| 322 | proto: entry.Proto, |
| 323 | port: entry.Port, |
| 324 | }, |
| 325 | ip: seesaw.NewIP(ip), |
| 326 | ventry: entry, |
| 327 | vserver: v, |
| 328 | dests: make(map[destinationKey]*destination, 0), |
| 329 | stats: &seesaw.ServiceStats{}, |
| 330 | } |
| 331 | svc.ipvsSvc = svc.ipvsService() |
| 332 | svcs[svc.serviceKey] = svc |
| 333 | } |
| 334 | } |
| 335 | return svcs |
| 336 | } |
| 337 | |
| 338 | // expandFWMServices returns a list of services that have been expanded from the |
| 339 | // vserver configuration for a firewall mark based vserver. |