Skip to content

FEAT: Add the ability to choose originating address for TCP connections #855

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

Closed
wants to merge 0 commits into from
Closed

Conversation

daviddenis-stx
Copy link

Would you be interested by this kind of change ?

The idea is to be able to bind a particular local network interface.

It's for example useful when you have several routable interfaces on a given machine (ex: server with several failovers) and you want to be seen connecting from one of these interfaces (ex: the interface holding an IP that is white listed by the remote server you want to connect to).

I already posted a similar change to fluentftp here robinrodricks/FluentFTP@a761d05

User would only have to set the LocalIpAddress to something valid on its ConnectionInfo instance

Currently testing the change in real life

AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp,
IPAddress.Loopback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other Tests are failing after this one runs because you're not Disposing the socket.
You can perhaps look at the DirectConnectorTest_Connect_* testcases and add this one to that collection, inheriting from DirectConnectorTestBase and overriding Teardown() function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, actually, I think tests are failing due to port exhaustion on the Appveyor VM - sockets remain in TIME_WAIT state for a long time. This is happening randomly on other PRs that have nothing to do with sockets.

To avoid this the SocketFactory code may need a flag to tell it to use SO_REUSEADDR on the sockets. Or if possible, reducing the TIME_WAIT delay or increasing the pool of available dynamic ports on the VM.

This is outside of your PR.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so whom should be the person to reconfigure the VM as you mentioned this is outside of the PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drieseng has access to it, not sure if anyone else has.

/// Gets or sets the local IP address to bind.
/// If not null, bind local socket to given address (use this if you have several interfaces and want to be seen as connecting from a particular one).
/// </summary>
public IPAddress LocalIpAddress { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not IPEndpoint LocalEndpoint ? This way the user can optionally specify a local port as well, which might be needed for some strict firewalls.

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.

3 participants