options_linux.go 763 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package sandbox
  2. import "net"
  3. func (i *nwIface) processInterfaceOptions(options ...IfaceOption) {
  4. for _, opt := range options {
  5. if opt != nil {
  6. opt(i)
  7. }
  8. }
  9. }
  10. func (n *networkNamespace) Bridge(isBridge bool) IfaceOption {
  11. return func(i *nwIface) {
  12. i.bridge = isBridge
  13. }
  14. }
  15. func (n *networkNamespace) Master(name string) IfaceOption {
  16. return func(i *nwIface) {
  17. i.master = name
  18. }
  19. }
  20. func (n *networkNamespace) Address(addr *net.IPNet) IfaceOption {
  21. return func(i *nwIface) {
  22. i.address = addr
  23. }
  24. }
  25. func (n *networkNamespace) AddressIPv6(addr *net.IPNet) IfaceOption {
  26. return func(i *nwIface) {
  27. i.addressIPv6 = addr
  28. }
  29. }
  30. func (n *networkNamespace) Routes(routes []*net.IPNet) IfaceOption {
  31. return func(i *nwIface) {
  32. i.routes = routes
  33. }
  34. }