Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UPnP support and configurations to Kaspad #288

Merged
merged 10 commits into from Oct 24, 2023

Conversation

biryukovmaxim
Copy link
Collaborator

Introduced Universal Plug and Play (UPnP) configurations in the Kaspad system to automatically forward ports on a broadband router. The UPnP setting is optional and can be configured via the 'kaspad/src/args.rs' file. The 'upnp' field was added to 'Config' structs and default configuration was set as 'false'. A function was added to map ports if UPnP is enabled and the 'igd-next' library was incorporated to facilitate UPnP support. The changes improve Kaspad's peer discovery mechanism by allowing it to be accessed by more peers especially when behind a NAT firewall.

kaspad/src/args.rs Outdated Show resolved Hide resolved
@biryukovmaxim biryukovmaxim force-pushed the support-upnp branch 6 times, most recently from a49550a to 57d05d9 Compare October 7, 2023 08:14
@biryukovmaxim biryukovmaxim force-pushed the support-upnp branch 2 times, most recently from 0aa2eaa to 637165a Compare October 13, 2023 01:37
kaspad/src/args.rs Outdated Show resolved Hide resolved
components/addressmanager/src/lib.rs Outdated Show resolved Hide resolved
components/addressmanager/src/lib.rs Outdated Show resolved Hide resolved
components/addressmanager/src/lib.rs Outdated Show resolved Hide resolved
components/addressmanager/src/lib.rs Outdated Show resolved Hide resolved
components/addressmanager/src/lib.rs Outdated Show resolved Hide resolved
Introduced Universal Plug and Play (UPnP) configurations in the Kaspad system to automatically forward ports on a broadband router. The UPnP setting is optional and can be configured via the 'kaspad/src/args.rs' file. The 'upnp' field was added to 'Config' structs and default configuration was set as 'false'. A function was added to map ports if UPnP is enabled and the 'igd-next' library was incorporated to facilitate UPnP support. The changes improve Kaspad's peer discovery mechanism by allowing it to be accessed by more peers especially when behind a NAT firewall.
…at UPnP is enabled by default and can be deactivated using this flag.
Implemented a port mapping extender to periodically extend the lifetime of port mappings in UPnP. This change includes the addition of a new module 'port_mapping_extender'. The commit also modifies the existing 'AddressManager' to initiate and control the extender. The Cargo.toml file is updated for asynchronous I/O support with 'igd-next'. The behaviour of the flag has been changed to 'disable_upnp', indicating that UPnP is enabled by default and can be deactivated using this flag.
The .idea/ directory generated by JetBrains-based IDEs, which contains user-specific settings, was deleted from version control. This is due to it's non-essential nature for the project's operation and its tendency to create conflicts between different users' IDE settings. The .gitignore file was also updated to ignore this directory going forward. This change reduces the potential for unnecessary merge conflicts and keeps the repository clean of user-specific files.
A line in args.rs was altered to set the p2p_listen_address in the config. Previously, this field was not being set. Now, it is set to the given 'listen' argument value, falling back to an Unspecified ContextualNetAddress if 'listen' is not given. This change ensures that the p2p_listen_address is always defined.
Changed the `addressmanager` to adjust the P2P listen address port dynamically with a normalize function. This addresses the occasional unavailability of the default P2P port or changing network conditions, providing a more flexible and reliable network connection.
Added error handling in PortMappingExtender to give a warning when there is an error in extending external IP mapping. Previously, the application would panic on encountering an error as it was unwrapped without any error handling. This change improves the stability of the application especially in an unstable network environment where extending external Ip mapping could fail due to various reasons.
Changes have been made to use NetAddress instead of IpAddress in the externalip field of the configuration module. The same adjustment was reflected in the addressmanager and kaspad components. This change aims to include port information along with IP for externalip, making the application more flexible and feature-rich in handling network addresses.
This commit addresses two primary changes. Firstly, logging statements in 'addressmanager/src/lib.rs' have been improved for clarity. Statements like "Get external ip from gateway using upnp: {ip}" have been changed to "Got external ip from gateway using upnp: {ip}", etc.

Secondly, the constant "Kaspad-rusty" has been replaced with APP_NAME - "rusty-kaspa" for better code readability and maintainability. This was done to eliminate hardcoded strings in the app.

Additionally, small grammar correction was made in 'kaspad/src/args.rs'. Changed "an socket address" to "a socket address".
@someone235 someone235 merged commit fb64d90 into kaspanet:master Oct 24, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants