-
Notifications
You must be signed in to change notification settings - Fork 147
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coderofstuff
requested changes
Oct 1, 2023
biryukovmaxim
force-pushed
the
support-upnp
branch
6 times, most recently
from
October 7, 2023 08:14
a49550a
to
57d05d9
Compare
biryukovmaxim
force-pushed
the
support-upnp
branch
2 times, most recently
from
October 13, 2023 01:37
0aa2eaa
to
637165a
Compare
someone235
requested changes
Oct 23, 2023
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".
biryukovmaxim
force-pushed
the
support-upnp
branch
from
October 23, 2023 13:23
d2c690a
to
59c5f02
Compare
someone235
approved these changes
Oct 24, 2023
smartgoo
pushed a commit
to smartgoo/rusty-kaspa
that referenced
this pull request
Jun 18, 2024
* Add UPnP support and configurations to Kaspad 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. * Switched the 'upnp' variable to 'disable_upnp'. It is now apparent that UPnP is enabled by default and can be deactivated using this flag. * Add port mapping extender for UPnP support 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. * Remove .idea/ directory from version control 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. * Remove outdated test_sync_state_notifications package. * Update p2p_listen_address in args.rs 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. * Increase network connection flexibility with P2P port normalization 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. * Update error handling in PortMappingExtender 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. * Replace IpAddress with NetAddress in externalip configuration 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. * Refactor logging statements and improve code readability 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".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.