kdzwinel / betwixt

:zap: Web Debugging Proxy based on Chrome DevTools Network panel.
MIT License
4.53k stars 125 forks source link

Set proxy programmatically #2

Open kdzwinel opened 8 years ago

kdzwinel commented 8 years ago

Right now proxy has to be set by hand, there should be a way to set it programmatically.

Question: Should that be a default behaviour? If I want to debug network traffic for a specific thing (e.g. npm), not the whole system, it's better for me to have control.

Challenge: even if it's possible how do we support all operating systems?

samccone commented 8 years ago

cc @fcanas for mac... do you know if this is scriptable via jscore?

max-mapper commented 8 years ago

I have another idea that might work (for OSX/Linux). Recently @mafintosh and I wrote https://www.npmjs.com/package/utun which lets you create virtual network devices by using the same syscall that VPN software uses to redirect all system traffic over a custom tunnel. Combining the utun module with some IP routing tricks (using the route command) can redirect system traffic to your own process.

kdzwinel commented 8 years ago

@maxogden that sounds neat! Although, I'm not quite sure what are the benefits of using utun over a proxy - easier setup? (doesn't it require root access?) more accurate data? better transparency?

max-mapper commented 8 years ago

The benefit is that you can do it programmatically and capture all system traffic

fcanas commented 8 years ago

@samccone JSCore still needs to be kicked off from a native process which I don't think there's any well-understood tooling for. I think a node native module is the right approach. If you don't want to use utun, it shouldn't be too hard to write your own:

Documentation for configuring network services on the Mac -- see about proxies dictionary in "The System Configuration Schema" Boilerplate for a node native module

samccone commented 8 years ago

awww snap thanks for the info @fcanas :)

max-mapper commented 8 years ago

We're happy to add anyone to utun who wants to help improve it too (http://openopensource.org/ style). Only thing it needs right now is prebuilt binaries (we use https://www.npmjs.com/package/prebuild but havent hooked it up there yet because we haven't needed to use utun in production yet)