mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Add ipv6 multiaddr support (#5199)
* Add ipv6 multiaddr support * allow ipv6 for discv5
This commit is contained in:
parent
e15d92df06
commit
48d4a8655a
@ -49,7 +49,7 @@ func createListener(ipAddr net.IP, privKey *ecdsa.PrivateKey, cfg *Config) *disc
|
||||
}
|
||||
if cfg.HostAddress != "" {
|
||||
hostIP := net.ParseIP(cfg.HostAddress)
|
||||
if hostIP.To4() == nil {
|
||||
if hostIP.To4() == nil && hostIP.To16() == nil {
|
||||
log.Errorf("Invalid host address given: %s", hostIP.String())
|
||||
} else {
|
||||
localNode.SetFallbackIP(hostIP)
|
||||
|
@ -42,7 +42,11 @@ func buildOptions(cfg *Config, ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt
|
||||
}
|
||||
if cfg.HostAddress != "" {
|
||||
options = append(options, libp2p.AddrsFactory(func(addrs []multiaddr.Multiaddr) []multiaddr.Multiaddr {
|
||||
external, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", cfg.HostAddress, cfg.TCPPort))
|
||||
protocol := "ip4"
|
||||
if ip := net.ParseIP(cfg.HostAddress); ip.To4() == nil {
|
||||
protocol = "ip6"
|
||||
}
|
||||
external, err := multiaddr.NewMultiaddr(fmt.Sprintf("/%s/%s/tcp/%d", protocol, cfg.HostAddress, cfg.TCPPort))
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Unable to create external multiaddress")
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user