mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-27 14:20:27 +08:00
feat(p2p): add ICMP backend support
This commit is contained in:
26
gold/p2p/icmp/init.go
Normal file
26
gold/p2p/icmp/init.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Package icmp for non-privileged datagram-oriented ICMP endpoints,
|
||||
// currently only Darwin and Linux support this.
|
||||
package icmp
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
|
||||
"github.com/fumiama/WireGold/gold/p2p"
|
||||
"github.com/fumiama/WireGold/internal/file"
|
||||
)
|
||||
|
||||
func NewEndpoint(endpoint string, _ ...any) (p2p.EndPoint, error) {
|
||||
addr, err := netip.ParseAddr(endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return (*EndPoint)(&addr), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
name := file.FolderName()
|
||||
_, hasexist := p2p.Register(name, NewEndpoint)
|
||||
if hasexist {
|
||||
panic("network " + name + " has been registered")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user