1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-18 00:40:25 +08:00
Files
WireGold/gold/p2p/udp/init.go
2024-07-14 22:26:44 +09:00

27 lines
443 B
Go

package udp
import (
"errors"
"net"
"net/netip"
"github.com/fumiama/WireGold/gold/p2p"
)
var (
ErrEndpointTypeMistatch = errors.New("endpoint type mismatch")
)
func NewEndpoint(endpoint string, _ ...any) p2p.EndPoint {
return (*EndPoint)(net.UDPAddrFromAddrPort(
netip.MustParseAddrPort(endpoint),
))
}
func init() {
_, hasexist := p2p.Register("udp", NewEndpoint)
if hasexist {
panic("network udp has been registered")
}
}