bitmark-inc/bitmarkd

IPV4, IPV6 Mapping Issue on Different OS

Closed this issue · 0 comments

Original Problem Description

In Bitmarkd configuration, if we want to listen on all address of IPV4 and IPV6, we may do this
listen = {
"0.0.0.0:2136",
"[::]:2136"
}
Then we get a bind error that said the port has already Bind.
We have 2 modules have the issue Peer and RPC

Propose base on """Linux"""

Use [::] to represent all interface
In configuration,
In RPC module
In Peer module

"BUT" ---> This is a os related and a library issue ... please see follow

Investigation on the Issue

according to this reference: https://lwn.net/Articles/688462/
In kernel Level,
OS do IPV4 IPV6 Mapping. In Linux it is a default, therefore, "[::]" means listen All
However, according to the article, BSD may not be the default. (OS dependent)

In Go Library Level, (Test on Ubuntu Linux Only )
In RPC, ipType can be specified "tcp" -- > listen all
l, err := tls.Listen(ipType[i], listen, tlsConfiguration)

If we want to specify this
listen = {
"0.0.0.0:2136",
"[::]:2136"
}
It is also ok, we should use
tcp4 -- > "0.0.0.0:2136",
tcp6 --> "[::]:2136"

However, In Peer ZMQ Library , If we can not bind both in NewBind. To listen to all, we shall use [::]:2136 (Notice: Maybe a deep investigation on ZMQ library may can )

// allocate IPv4 and IPv6 sockets
lstn.socket4, lstn.socket6, err = zmqutil.NewBind(log, zmq.REP, listenerZapDomain, privateKey, publicKey, c)

What should we do ??

Check on differences in in BSD, MAC and Linux and find the rules

  • Will IPV4 map IPV6?
  • What the parameters to reflect this on RPC and ZMQ setting