offbynull / portmapper

Java library that maps ports on NAT-enabled routers (supported protocols: UPnP-IGD/NAT-PMP/PCP).
Apache License 2.0
88 stars 17 forks source link

Error using in Windows. Is this library Unix only? #33

Closed adam-law closed 7 years ago

adam-law commented 7 years ago

Hi,

I was evaluating this library, and while following the example, I got

[Thread-27] INFO com.offbynull.portmapper.mappers.upnpigd.UpnpIgdPortMapper - Attempting to identify devices [Thread-27] INFO com.offbynull.portmapper.mappers.natpmp.NatPmpPortMapper - Attempting to identify devices [Process IO] ERROR com.offbynull.portmapper.gateways.process.ProcessRunnable - Unable to create process java.io.IOException: Cannot run program "ifconfig": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at com.offbynull.portmapper.gateways.process.ProcessRunnable.processMessage(ProcessRunnable.java:106) at com.offbynull.portmapper.gateways.process.ProcessRunnable.run(ProcessRunnable.java:67) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(ProcessImpl.java:386) at java.lang.ProcessImpl.start(ProcessImpl.java:137) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 3 more [Thread-27] INFO com.offbynull.portmapper.mappers.pcp.PcpPortMapper - Attempting to identify devices [Process IO] ERROR com.offbynull.portmapper.gateways.process.ProcessRunnable - Unable to create process java.io.IOException: Cannot run program "ifconfig": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at com.offbynull.portmapper.gateways.process.ProcessRunnable.processMessage(ProcessRunnable.java:106) at com.offbynull.portmapper.gateways.process.ProcessRunnable.run(ProcessRunnable.java:67) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(ProcessImpl.java:386) at java.lang.ProcessImpl.start(ProcessImpl.java:137) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 3 more

So, this library can't be used on Windows?

offbynull commented 7 years ago

Yes it can. The errors your seeing are benign.

The library tries every possible command for every OS. It doesn't check which OS you're using beforehand. So, even if you're running Windows, it will still try to run ifconfig (along with its Windows equivalent).

The reason I did this was because I didn't want to run into a case where the library failed because the OS wasn't properly detected.

See https://github.com/offbynull/portmapper/issues/31

Is what I'm saying making sense?

offbynull commented 7 years ago

Closing EOD today if no feedback.

adam-law commented 7 years ago

Hi, sorry for the reply. Yes, it makes sense, thank you for explaining.

I'll continue my evaluation then. Thanks again!