Git Product home page Git Product logo

Comments (4)

igrigorik avatar igrigorik commented on August 28, 2024

Hmm, that's a great question. Assuming your box has multiple IP's assigned to it... I'm not sure if EventMachine has any API's for picking a specific interface to initiate an outgoing connection.

@tmm1: any thought on this?

Equivalent for curl: http://stackoverflow.com/questions/2425651/select-outgoing-ip-for-curl-request

from em-proxy.

tmm1 avatar tmm1 commented on August 28, 2024

Use EM.bind_connect

from em-proxy.

igrigorik avatar igrigorik commented on August 28, 2024

Ah, figures.. Never used that API before. Thanks!

@barbolo, so the answer is: yes it is possible, but it would require some patching to support this use case :-)

from em-proxy.

barbolo avatar barbolo commented on August 28, 2024

Thanks @tmm1 and @igrigorik!

I tryed patching the em-proxy gem and believe I got it working. One new problem is that EM.bind_connect (as well as EM.connect) seems not to work correctly with IPv6. The IP addresses attached to my machine are all IPv6.

I replaced the following line of lib/em-proxy/connection.rb:

srv = EventMachine::connect(opts[:host], opts[:port], EventMachine::ProxyServer::Backend, @debug) do |c|

with:

ipv6 = Socket.ip_address_list.sample # choose a random ipv6 attached to the machine
srv = EventMachine::bind_connect(ipv6, nil, opts[:host], opts[:port], EventMachine::ProxyServer::Backend, @debug) do |c|

from em-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.