expandDests returns a list of destinations that have been expanded from the vserver configuration and a given service.
(svc *service)
| 386 | // expandDests returns a list of destinations that have been expanded from the |
| 387 | // vserver configuration and a given service. |
| 388 | func (v *vserver) expandDests(svc *service) map[destinationKey]*destination { |
| 389 | dsts := make(map[destinationKey]*destination, len(v.config.Backends)) |
| 390 | for _, backend := range v.config.Backends { |
| 391 | var ip net.IP |
| 392 | switch svc.af { |
| 393 | case seesaw.IPv4: |
| 394 | ip = backend.Host.IPv4Addr |
| 395 | case seesaw.IPv6: |
| 396 | ip = backend.Host.IPv6Addr |
| 397 | } |
| 398 | if ip == nil { |
| 399 | continue |
| 400 | } |
| 401 | dst := &destination{ |
| 402 | destinationKey: newDestinationKey(ip), |
| 403 | service: svc, |
| 404 | backend: backend, |
| 405 | weight: backend.Weight, |
| 406 | } |
| 407 | dst.ipvsDst = dst.ipvsDestination() |
| 408 | dst.stats = &seesaw.DestinationStats{} |
| 409 | dsts[dst.destinationKey] = dst |
| 410 | } |
| 411 | return dsts |
| 412 | } |
| 413 | |
| 414 | // expandChecks returns a list of checks that have been expanded from the |
| 415 | // vserver configuration. |