Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Request feature: Different network interfaces support (some IP). #10269

Closed
DChistyakov opened this issue Oct 22, 2011 · 27 comments
Closed

Request feature: Different network interfaces support (some IP). #10269

DChistyakov opened this issue Oct 22, 2011 · 27 comments

Comments

@DChistyakov
Copy link

chistyak...@gmail.com commented:

Please, make a support of different network interfaces like:
phantomjs -iface=192.168.0.2 ...

Qt webkit supports it.

Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #269.
🌟   6 people had starred this issue at the time of migration.

@ariya
Copy link
Owner

ariya commented Oct 22, 2011

ariya.hi...@gmail.com commented:

Is there an API of QtWebKit which does that?

I think it's more on the network module.

 
Metadata Updates

  • Label(s) removed:
    • Type-Defect
  • Label(s) added:
    • Type-Enhancement
  • Milestone updated: FutureRelease (was: ---)

@codeb2cc
Copy link

codeb2cc commented Jun 4, 2013

I wonder if that feature possible since it's been two years...

@JamesMGreene
Copy link
Collaborator

I think @vitallium had mentioned something about this to me before...?

@vitallium
Copy link
Collaborator

Yes. This feature is almost implemented. I think it will be ready soon.

@jobay
Copy link

jobay commented Oct 24, 2013

Hi,

I started enjoying phantomjs on a linux server with many virtual ips. I am also interested in this issue, in order to make requests with different available ips, like I usually do with curl.

I was just wondering how was the work-in-progress... any news?

Cheers

@JamesMGreene
Copy link
Collaborator

Update from @vitallium on #10378:

Unfortunately, this feature will be available only in PhantomJS 2.0

@AdamCanady
Copy link

Hey, just a quick search of the repo shows many results for localAddress in the C++ sources. Is this close to being implemented or is it out in 2.0?

Would love to be able to specify my network interface when making requests, and I'm happy to help out wherever possible, but I thought I'd check in first.

Cheers!

@amalagaura
Copy link

I see that feature needed qtwebkit 5.0 in PhantomJS 2.0. @vitallium, if you have any code to start it looks like there may be people who are willing to work on this.

@mandb
Copy link

mandb commented Feb 26, 2015

Doesn't look like this is going to get implemented unless somebody does it and submits a pull request.

@Julienh
Copy link

Julienh commented Apr 17, 2015

Any news about this feature please?

@zackw zackw removed this from the FutureRelease milestone Apr 19, 2015
@zackw
Copy link
Collaborator

zackw commented Apr 19, 2015

@vitallium Do you have an update on the implementation you were working on?

@vitallium
Copy link
Collaborator

@zackw this feature is not possible to implement without modifying QtWebkit code.

@zackw
Copy link
Collaborator

zackw commented Apr 19, 2015

I was afraid of that.

@XiaoChenMa
Copy link

@vitallium Can tell me how to modify QtWebkit code to implement this feature?

@zackw
Copy link
Collaborator

zackw commented Apr 20, 2015

@XiaoChenMa I'm pretty sure that figuring out how to modify QtWebkit code to implement this feature would be at least 90% of the work. Therefore, if we knew what to tell you, we would already have implemented it ourselves.

I can get you started, though: read the code in src/qt/qtbase/src/network. Yes, there's an awful lot of it. You're looking for calls to the system primitives socket, connect, and bind. You need to figure out how to make Qt call bind on a client TCP socket before calling connect on it.

If you don't know how the low-level socket API works, read all of chapter 16 of the GNU C Library manual: https://www.gnu.org/software/libc/manual/html_node/Sockets.html

@zackw zackw removed the In progress label Apr 20, 2015
@ghost
Copy link

ghost commented Apr 29, 2015

Has there been any movement on this issue. I really don't want to have to manage an IPTABLE when phantomjs can bind the interface for me.

@DChistyakov
Copy link
Author

Guys... After 4 year.. I advise to use sqiud. I live 4 years with 32k ips and squid. Everything is ... yofi!
Phantom is much more slowly than squid. I use 1000+ threads. Works fine. i7 3.5ghz, 48gb ram, hartzner.com

@seliquity
Copy link

If you can use LD_PRELOAD just use something like fixsrcip to overwrite connect() and bind to whatever IP you want. A bit of a hacky solution but less overhead than running everything through squid.

@DChistyakov
Copy link
Author

Well.. Single instace of squid could accept more connections with less memory usage. But everything depends on the task body.

Anyway.. I see no reason to reduse usage of resources because of server power is enough for my tasks.

@seliquity
Copy link

Sorry, I was suggesting fixsrcip as a potential generic workaround. I didn't mean you specifically. There's no need to run a whole proxy server just to bind to an interface as long as you're not running it as root.

@DChistyakov
Copy link
Author

I got it. Sorry too. I mean I have some servers with phantom and one gate.

Anyway this feature could be implemented with much ease than overcoding QT engine. So closing is the optimal option for this task for now.

@zackw
Copy link
Collaborator

zackw commented Apr 29, 2015

Please don't close issues just because you have found a workaround. We will get to this - eventually.

@zackw zackw reopened this Apr 29, 2015
@DChistyakov
Copy link
Author

But the implementation is impossible. Okay, its your play, Im out.

Conclusion. By saying impossible I mean that it is IMPOSSIBLE to implement this feature without modifing the QT core. But it is also impossible to modify qt core, because of the back lagacy problem. So it will not be implemented for years.

@arya6000
Copy link

Has anyone tried this with forcebindip? With forcebindip I am able to bind any program to any interface. I don't know if it would work with Selenium and Phantomks https://r1ch.net/projects/forcebindip

@AshMartian
Copy link

My solution in theory would work, but in practice has been hit or miss. Using Docker containers you can bind to a specific interface using Docker networks. In practice I haven't had much luck, maybe this would help somebody down the road.
(I'm doing this on a Raspberry Pi, using PhantomJS to auto join an open wireless network with accept screen)

/etc/systemd/system/docker.service.d/docker.conf

[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -b=wlan1 --ip=10.0.0.151 -H fd://

This binds all of Docker under that specific interface, sometimes I had to do this for it to work.

Using compose to create a network

version: "2"

networks:
  open_network_2:
    driver: bridge
    driver_opts:
      com.docker.network.host_binding_ipv4: "10.0.0.151"

services:
   open_wifi_phantom:
     image: https://github.com/ollihoo/phantomjs-docker-rpi
     networks: 
       - open_network_2

Often I've had to create an IP tables rule, to route the docker bridge traffic to the interface's IP
iptables -t nat -A POSTROUTING -s 172.16.0.0/16 -j SNAT --to-source 10.0.0.151

I use Puppet to place the wlan1 IP address in these files.

Documentation on this functionality is also very vague, or I don't understand lower level networking.
https://docs.docker.com/engine/userguide/networking/#the-default-bridge-network-in-detail
http://serverfault.com/questions/696747/routing-from-docker-containers-using-a-different-physical-network-interface-and

@ghost ghost removed 2.0 labels Jan 10, 2018
@stale stale bot added the stale label Dec 25, 2019
@stale
Copy link

stale bot commented Dec 28, 2019

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests