qaul / qaul.net

Internet Independent Wireless Mesh Communication App
https://qaul.net
GNU Affero General Public License v3.0
496 stars 63 forks source link

Add IPv6 Interface to Swarm #547

Closed MathJud closed 1 year ago

MathJud commented 1 year ago

Currently qaul can be configured to be connectable either via IPv4 or via IPv6. In order for a libp2p swarm to become dual stack (IPv4 & IPv6), we need to add a second interface to each swarm.

The current interface starts listening to IPv4 and a second interface shall start listening to IPv6.

Sub Tasks

Optional Advanced Tasks

Information

This is a good first issue, which touches quite a few areas of the Don't hesitate to ask further questions about it, e.g. in the matrix group chat. We will help you with that.

To have some further information for the fields that are touched here:

Testing

Harshil-Jani commented 1 year ago

@MathJud In the configuration.rs do we need to use two structs for Lan and Internet (Eg : Lan_IPv4 and Lan_IPv6) ? Or there is already support for IPv4 connections through IPv4-mapped IPv6 addresses ?

If there is support already then do we really need two Swarm::listen_on() ? It should be possible with just one itself i guess.

MathJud commented 1 year ago

@Harshil-Jani

In the configuration file users can define the addresses, the socket is listening on. This is defined via a multiaddress.

Definition and explanation of the configuration file

  # multi address configuring the port the internet module listens on
  # 0.0.0.0 - the module is listening on all addresses.
  # 9229 - the port number 9229 zero means the module listens on port 9229 for incoming connections
  listen: /ip4/0.0.0.0/tcp/9229

These addresses define on which address and port a swarm is listening on, with /ip4/0.0.0.0/tcp/0 is listening on any available IPv4 addresses and a randomly assigned port.

The problem is that a single listener therefore only listens to either IPv4 or IPv6. While the node is still able to connect to any address, regardless of IPv4 or IPv6, it can itself only be accessed via either the IP version it is listening on. In order to become dual-stack and to listen on IPv4 as well as IPv6 we need to create multiple listening interfaces.

IMHO, a good possibility for configuration would be to make the listen entry an array. When starting libqaul one could loop over the array and dynamically create a listen_on() interface.

  # default settings for listening on all IPv4 and all IPv6 interfaces
  listen: [/ip4/0.0.0.0/tcp/0, /ip6/::/tcp/0]
MathJud commented 1 year ago

fixed by #551