noop.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.IP, _ *net.IPNet) net.IP {
  27. return nil
  28. }
  29. // Index will also do nothing.
  30. func (n Noop) Index() int {
  31. return 0
  32. }
  33. // Init will also do nothing.
  34. func (n Noop) Init(_ int) error {
  35. return nil
  36. }
  37. // Rules will also do nothing.
  38. func (n Noop) Rules(_ []*net.IPNet) iptables.RuleSet {
  39. return iptables.RuleSet{}
  40. }
  41. // Set will also do nothing.
  42. func (n Noop) Set(_ *net.IPNet) error {
  43. return nil
  44. }
  45. // Strategy will finally do nothing.
  46. func (n Noop) Strategy() Strategy {
  47. return Strategy(n)
  48. }