noop.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2021 the Kilo authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package encapsulation
  15. import (
  16. "net"
  17. "github.com/squat/kilo/pkg/iptables"
  18. )
  19. // Noop is an encapsulation that does nothing.
  20. type Noop Strategy
  21. // CleanUp will also do nothing.
  22. func (n Noop) CleanUp() error {
  23. return nil
  24. }
  25. // Gw will also do nothing.
  26. func (n Noop) Gw(_, _, _ net.IP, _ *net.IPNet) net.IP {
  27. return nil
  28. }
  29. // CNICompatibilityIP will also do nothing.
  30. func (n Noop) CNICompatibilityIP() *net.IPNet {
  31. return nil
  32. }
  33. // Index will also do nothing.
  34. func (n Noop) Index() int {
  35. return 0
  36. }
  37. // Init will also do nothing.
  38. func (n Noop) Init(_ int) error {
  39. return nil
  40. }
  41. // Rules will also do nothing.
  42. func (n Noop) Rules(_ []*net.IPNet) iptables.RuleSet {
  43. return iptables.RuleSet{}
  44. }
  45. // Set will also do nothing.
  46. func (n Noop) Set(_ *net.IPNet) error {
  47. return nil
  48. }
  49. // Strategy will finally do nothing.
  50. func (n Noop) Strategy() Strategy {
  51. return Strategy(n)
  52. }