The background!
Title background
 

QWERKI

Dexter's Jamie Thompson's web laboratory (aka. The Development Version of the Site)

MrPorts

- UPnP for any application

Licensing

MrPorts is licensed under the GPL license.

Lacking any better ideas, and despite the seemingly futile gesture of using the GPL on scripts, the GPL is what this software is licensed to you under. It would be appreciated if you were to credit here if you do decide to extend the scripts, even better if you were to drop me an email too, but thats up to you.

- Jamie Thompson

Preamble

I like UPnP. Using the linuxigd package I even got it working on my Linux router. I also have several machines on my network, all of which my brothers want to run eMule on. I dislike having to micro-manage the router's port mappings, but with eMule lacking UPnP support as it does, this is seemingly unavoidable. Thats where this script comes in.

Starting with the initial ideas that Knox North came up with, I wrapped the UPnP object with a simple script that opens the specified ports, then goes to sleep until the child application terminates, removing the ports before it itself terminates.

I then combined this with another script, "MrMulePorts.js", to which you pass a couple of valid port ranges (for the UDP and TCP ports). This script finds a pair of unused TCP and UDP ports in the specified ranges, then writes them into the emule config file, before spawning the MrPorts.js script with the generated port numbers.

Obviously, MrPorts.js will work with any application, the real trick is letting the spawned application know what ports you want to use. If they are static it's not so bad, but I wanted something a bit more dynamic for eMule (also meaning that an unlimited number of clients can exist quite happily on a network all with high-ids).

Installation

Just a few simple steps:

  1. First things first, download the scripts :)
  2. Now you have a choice, the scripts need to be dumped somewhere in your path, so that they can be called by their name alone. You have two options:
    • (easy) Just copy the two scripts into your Windows directory.
    • (advised) Make a new directory for scripts, and then add it to your path
  3. Create a shortcut with something along the lines of: MrMulePorts.js "C:\Program Files\eMule" "Local Area Connection", if you run the script with incorrect arguments it will prompt you with the available options

Notes

Error handling? What error handling? :) Seriously though, I haven't been bothered to make this as robust as much as it could prehaps be. If you give the script the right arguments though, everything does work. Feel free to add more handling if you feel like it, feel free to send me a copy and I'll add it here.

Memory usage is a bit of a problem. The Windows scripting host uses about 8MB of RAM whilst running, and obviously, as the script remains running for the duration of the spawned application, this means you lose 8MB. In reality this will proably be paged out pretty quickly unitl it's needed, so it's no biggie.

Startup time does increase slightly, bit more than I'd like, but hardly a show stopper.

Files

Mr DataStrip

  • Time:
    07:13:01 am
  • Date:
    22/11/2008
  • Visitors:
    1
  • Max Visitors:
    111 on 2008-10-03 02:45:12
  • Uptime:
    75 days, 21:09:32
  • Really need to think of more things...