redirection.go 599 B

123456789101112131415161718192021222324252627
  1. package firewall
  2. import "fmt"
  3. type Redirection struct {
  4. Interface string
  5. Protocol string
  6. SrcAddress string
  7. SrcPort int
  8. DstAddress string
  9. DstPort int
  10. }
  11. func NewRedirection(iface string, proto string, port_from int, addr_to string, port_to int) *Redirection {
  12. return &Redirection{
  13. Interface: iface,
  14. Protocol: proto,
  15. SrcAddress: "",
  16. SrcPort: port_from,
  17. DstAddress: addr_to,
  18. DstPort: port_to,
  19. }
  20. }
  21. func (r Redirection) String() string {
  22. return fmt.Sprintf("[%s] (%s) %s:%d -> %s:%d", r.Interface, r.Protocol, r.SrcAddress, r.SrcPort, r.DstAddress, r.DstPort)
  23. }