Skip to content

Refactor proxies to use the same UTP socket for external connections #360

@tegefaulkes

Description

@tegefaulkes

Specification

There is a problem with obtaining the ReverseConnection's NATified port during the NAT traversial process. If we can combine the two sockets that the ForwardProxy and the ReverseProxy uses we can greatly simplify the problem. The result being that if we receive a connection from a node, to establish a connection back we can use the same IP and Port` information.

The ReverseProxy and ForwardProxy needs to share a UTP socket. To this end we need to combine the ForwardProxy and ReverseProxy into a single Proxy class. any config parameters will need to be updated. duplicated logic between the two proxies will need to be combined together. anything specific to the forward or reverse case will need to remain separate. Things like openConnection will need to be differentiated by forwardOpenConnection reverseOpenConnection ect.

The old proxies will need to be removed and any tests using them will need to be updated to use the new Proxy class.

New naming of all ports and hosts:

┌────────────┐ clientHost forwardHost                               forwardHost clientHost┌────────────┐
│            │ clientPort forwardPort                               forwardPort clientPort│            │
│ GRPCClient ├────────────────┐                                            ┌──────────────┤ GRPCClient │
│            │                │      ┌───────┐             ┌───────┐       │              │            │
└────────────┘                └──────►       │             │       ◄───────┘              └────────────┘
                                     │ Proxy ◄─────────────► Proxy │
┌────────────┐                ┌──────┤       │  proxyHost  │       ├───────┐              ┌────────────┐
│            │                │      └───────┘  proxyPort  └───────┘       │              │            │
│ GRPCServer ◄────────────────┘                                            └──────────────► GRPCServer │
│            │ serverHost reverseHost                               reverseHost serverHost│            │
└────────────┘ serverPort reversePort                               reversePort serverPort└────────────┘

Additional context

Tasks

  • 1. prototype using a single UTP socket shared between the ForwardProxy and ReverseProxy.
  • 2. combine ForwardProxy and ReverseProxy into a single Proxy class.
  • 3. update config types and config defaults to reflect egress and ingress being the same now.
  • 4. remove old ReverseProxy and ForwardProxy modules.
  • 5. update any code that uses the old proxies to use the new Proxy module
  • 6. update any tests to use the new Proxy module
  • 7. combine fwd/rev proxy tests into Proxy.test.ts
  • 8. update host/port names.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions