endpoint.go 563 B

1234567891011121314151617181920212223242526272829303132333435
  1. package wireguard
  2. import (
  3. "net/netip"
  4. "github.com/sagernet/wireguard-go/conn"
  5. )
  6. var _ conn.Endpoint = (*Endpoint)(nil)
  7. type Endpoint netip.AddrPort
  8. func (e Endpoint) ClearSrc() {
  9. }
  10. func (e Endpoint) SrcToString() string {
  11. return ""
  12. }
  13. func (e Endpoint) DstToString() string {
  14. return (netip.AddrPort)(e).String()
  15. }
  16. func (e Endpoint) DstToBytes() []byte {
  17. b, _ := (netip.AddrPort)(e).MarshalBinary()
  18. return b
  19. }
  20. func (e Endpoint) DstIP() netip.Addr {
  21. return (netip.AddrPort)(e).Addr()
  22. }
  23. func (e Endpoint) SrcIP() netip.Addr {
  24. return netip.Addr{}
  25. }