github.com/sagernet/sing-box@v1.9.0-rc.20/transport/wireguard/endpoint.go (about)

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