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 for peer discovery. Resolves #1036 #1088

Merged
merged 5 commits into from
Dec 13, 2019

Conversation

CoeJoder
Copy link

@CoeJoder CoeJoder commented Nov 8, 2019

Feature description:

  • UPnP is toggleable by the config property peer.discovery.upnp_enabled and is enabled by default.

  • If automatic port mapping fails, a log message notifies the user to enable UPnP on their router, or disable UPnP in the node conf and forward router ports manually.

  • Any automatic port mapping created via UPnP on the router is deleted upon node shutdown.

Implementation notes:

  • The UpnpService is injected into UDPServer if the service was enabled in the conf. This is the only service using UPnP right now.

  • There are three TCP services running: Web3WebSocketServer, Web3HttpServer , PeerServerImpl. All three of these services are configurable with different network interfaces/local addresses, each of which could be connected to unique WAN gateways. If UpnpService was injected into these server objects, it could handle the port mapping easily. But that is out of scope for this ticket.

  • There is one unit test which relies on @VisibleForTesting (UpnpServiceTest::testExceptionDuringStop())

  • There are two integration test which rely on PowerMockito which was already being used in the test class (RskContextTest::testPeerDiscoveryWithUpnpEnabled() and RskContextTest::testPeerDiscoveryWithUpnpDisabled()).

TODO:
There is a new dependency on the weUPnP library, see rsksmart/reproducible-builds#19. The build.gradle dependency is currently using the SHA hash of the public repo, but should be switched to that of the reproducible build when it is ready.

…oncurrent modification of the port mappings list. Also removed 3 code smells:

 - logging of a swallowed Exception in `UpnpService::stop()`.

 - removed `Optional` type used as an instance field in `UDPServer`.

 - reduced cyclomatic complexity of `RskContext.buildInternalServices()`.
@CoeJoder CoeJoder mentioned this pull request Nov 22, 2019
@nacho692 nacho692 changed the base branch from master to gitcoin-issue-1036 December 12, 2019 17:53
@nacho692
Copy link
Contributor

Hey @CoeJoder, sorry for the delay.

Thanks a lot for your contribution and the explicit notes on the design decitions.
Could you please rebase to master so I can merge the PR into the branch?

…oncurrent modification of the port mappings list. Also removed 3 code smells:

 - logging of a swallowed Exception in `UpnpService::stop()`.

 - removed `Optional` type used as an instance field in `UDPServer`.

 - reduced cyclomatic complexity of `RskContext.buildInternalServices()`.
@CoeJoder
Copy link
Author

@nacho692 No problem. I just removed an integration test which relied on PowerMockito.

@nacho692 nacho692 merged commit 3c7c0b1 into rsksmart:gitcoin-issue-1036 Dec 13, 2019
@aeidelman aeidelman added the Gitcoin hackathon See https://gitcoin.co/hackathon/web3-world/ label Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gitcoin hackathon See https://gitcoin.co/hackathon/web3-world/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants