2022-09-06 00:15:09 +08:00
|
|
|
package wireguard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/netip"
|
|
|
|
|
2022-11-07 16:35:15 +08:00
|
|
|
"github.com/sagernet/wireguard-go/conn"
|
2022-09-06 00:15:09 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ conn.Endpoint = (*Endpoint)(nil)
|
|
|
|
|
2023-12-20 20:00:00 +08:00
|
|
|
type Endpoint netip.AddrPort
|
2022-09-06 00:15:09 +08:00
|
|
|
|
|
|
|
func (e Endpoint) ClearSrc() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e Endpoint) SrcToString() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e Endpoint) DstToString() string {
|
2023-12-20 20:00:00 +08:00
|
|
|
return (netip.AddrPort)(e).String()
|
2022-09-06 00:15:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e Endpoint) DstToBytes() []byte {
|
2023-12-20 20:00:00 +08:00
|
|
|
b, _ := (netip.AddrPort)(e).MarshalBinary()
|
2022-09-06 00:15:09 +08:00
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e Endpoint) DstIP() netip.Addr {
|
2023-12-20 20:00:00 +08:00
|
|
|
return (netip.AddrPort)(e).Addr()
|
2022-09-06 00:15:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e Endpoint) SrcIP() netip.Addr {
|
|
|
|
return netip.Addr{}
|
|
|
|
}
|