moll / node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
Other
636 stars 48 forks source link

Is ubuntu supported? #8

Closed bonesoul closed 9 years ago

bonesoul commented 9 years ago

I was able to use node-mitm with my windows based setup and successfully intercept stuff but when I try with it node over ubuntu, events does not fire.

Any ideas?

moll commented 9 years ago

Hey!

Ubuntu and any other Linux system is most definitely supported. I use Mitm.js myself both on Macs and Linuxes. Mitm.js's tests run on Travis CI, which is a Linux based system as well.

Sorry you're having trouble. Would you mind pasting a small example of how you're trying to use it. Thanks!

bonesoul commented 9 years ago

The code I'm using it;

https://github.com/int6/hpool-stratum/blob/master/test/integration/interceptor.js

and used by; https://github.com/int6/hpool-stratum/blob/master/test/integration/pool.js#L36

On windows, it's all doing good and but somehow it doesn't within my ubuntu machine.

moll commented 9 years ago

Haven't run the code, but skimmed through it. A few comments:

bonesoul commented 9 years ago

@moll, thanks

setting a conditional for bypass fixed it.

if(options.host !== 'localhost' || options.port !== 9337)
        socket.bypass();

Rather than calling Mitm() and then disable, you could just do new Mitm. That won't enable it automatically.

So should I just call _this.mitm = Mitm() and then enable() it once I want to use it?

moll commented 9 years ago

You're welcome. Rather this.mitm = new Mitm. Calling Mitm as a function (without new) does both new Mitm and enable internally.

If I can help more, let me know. Feel free to close this issue when you feel like it. ;-)