none.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2019 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. type none Strategy
  20. // NewNone returns an new encapsulator that does not encapsulate.
  21. func NewNone(strategy Strategy) Encapsulator {
  22. return none(strategy)
  23. }
  24. // CleanUp is a no-op.
  25. func (n none) CleanUp() error {
  26. return nil
  27. }
  28. // Gw always returns nil.
  29. func (n none) Gw(_, _ net.IP, _ *net.IPNet) net.IP {
  30. return nil
  31. }
  32. // Index always returns 0.
  33. func (n none) Index() int {
  34. return 0
  35. }
  36. // Init is a no-op.
  37. func (n none) Init(base int) error {
  38. return nil
  39. }
  40. // Rules always returns an empty list.
  41. func (n none) Rules(_ []*net.IPNet) []iptables.Rule {
  42. return nil
  43. }
  44. // Set is a no-op.
  45. func (n none) Set(_ *net.IPNet) error {
  46. return nil
  47. }
  48. // Strategy returns the configured strategy for encapsulation.
  49. func (n none) Strategy() Strategy {
  50. return Strategy(n)
  51. }