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 support for local host and port binding #238

Merged
merged 3 commits into from
Sep 25, 2013

Conversation

mkroman
Copy link
Contributor

@mkroman mkroman commented Sep 24, 2013

Add support for specifying a local host and port to bind to, before connecting.

This was implemented as per https://bugs.ruby-lang.org/issues/6617 and only works for Ruby 2.0 or later.

@jnunemaker
Copy link
Owner

🆒 Looks good. What is the use case for this? Sorry for the lame question, I just have no idea why I would use this so I'm curious as to what you are using it for.

@mkroman
Copy link
Contributor Author

mkroman commented Sep 25, 2013

It's for use when you have multiple IP-addresses bound to a single machine, on a single interface.

To give you an example, I have a single interface, on which I have bound 2 IPv4 addresses, and a single IPv6 address. With this change, I can choose which address I want to connect from.

If I were running a TOR relay on one of my IPv4 addresses, and wanted to connect to a HTTP service that automatically denies access to all IP-addresses that are on a DNS blacklist (which many TOR nodes are), I could circumvent this by connecting from my other IP address.

@@ -202,6 +202,13 @@
end
end

context 'when providing a local bind address and port' do
Copy link
Owner

Choose a reason for hiding this comment

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

This test should be wrapped with the ruby version if statement as well.

@jnunemaker
Copy link
Owner

With the tweak I just mentioned I'll happily pull it.


its(:local_host) { should == '127.0.0.1' }
its(:local_port) { should == 12345 }
end if RUBY_VERSION >= '2.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is. 😏

Copy link
Owner

Choose a reason for hiding this comment

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

Gah. Missed it. Thanks.

jnunemaker pushed a commit that referenced this pull request Sep 25, 2013
Add support for local host and port binding
@jnunemaker jnunemaker merged commit ef79d0f into jnunemaker:master Sep 25, 2013
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.

2 participants