All Projects → kaklakariada → Portmapper

kaklakariada / Portmapper

Licence: gpl-3.0
A tool for managing port forwardings via UPnP

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Portmapper

YAWAC
Yet Another Wifi Auto Connect (YAWAC) is a shell script to connect to a dataset of wireless connection and free hotspot like FreeWifi. It's works on OpenWrt.
Stars: ✭ 22 (-94.71%)
Mutual labels:  router, internet
Dowse
The Awareness Hub for the Internet of Things
Stars: ✭ 139 (-66.59%)
Mutual labels:  router, internet
Asuswrt Merlin Transparent Proxy
transparent proxy base on ss, v2ray, ipset, iptables, chinadns on asuswrt merlin.
Stars: ✭ 367 (-11.78%)
Mutual labels:  router
Blacklist
Blacklist and Adware Blocking for the Ubiquiti EdgeMax Router
Stars: ✭ 393 (-5.53%)
Mutual labels:  router
Uwebsockets.js
μWebSockets for Node.js back-ends 🤘
Stars: ✭ 4,552 (+994.23%)
Mutual labels:  router
Bgpalerter
Software to monitor streams of BGP data. Pre-configured for real-time detection of visibility loss, RPKI invalid announcements, hijacks, and more.
Stars: ✭ 367 (-11.78%)
Mutual labels:  internet
Ivim
A vim port to iOS.
Stars: ✭ 389 (-6.49%)
Mutual labels:  port
Blog.vue
☘ 一个vue的个人博客项目,配合.net core api教程,打造前后端分离
Stars: ✭ 362 (-12.98%)
Mutual labels:  router
Ozzo Routing
An extremely fast Go (golang) HTTP router that supports regular expression route matching. Comes with full support for building RESTful APIs.
Stars: ✭ 398 (-4.33%)
Mutual labels:  router
Padavan
padavan 简体中文 & 路由器适配
Stars: ✭ 385 (-7.45%)
Mutual labels:  router
Dcurlrouter
通过自定义URL实现控制器之间的跳转
Stars: ✭ 393 (-5.53%)
Mutual labels:  router
Krakend
Ultra performant API Gateway with middlewares. A project hosted at The Linux Foundation
Stars: ✭ 4,752 (+1042.31%)
Mutual labels:  router
Rustscan
🤖 The Modern Port Scanner 🤖
Stars: ✭ 5,218 (+1154.33%)
Mutual labels:  port
Regexparam
A tiny (308B) utility that converts route patterns into RegExp. Limited alternative to `path-to-regexp` 🙇‍♂️
Stars: ✭ 390 (-6.25%)
Mutual labels:  router
Openwrtinvasion
Root shell exploit for several Xiaomi routers: 4A Gigabit, 4A 100M, 4, 4C, 3Gv2, 4Q, miWifi 3C...
Stars: ✭ 366 (-12.02%)
Mutual labels:  router
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (-5.29%)
Mutual labels:  router
Route Composer
Protocol oriented, Cocoa UI abstractions based library that helps to handle view controllers composition, navigation and deep linking tasks in the iOS application. Can be used as the universal replacement for the Coordinator pattern.
Stars: ✭ 362 (-12.98%)
Mutual labels:  router
Dev Sidecar
开发者边车,github打不开,github加速,git clone加速,git release下载加速,stackoverflow加速
Stars: ✭ 163 (-60.82%)
Mutual labels:  internet
React
🔼 UI-Router for React
Stars: ✭ 386 (-7.21%)
Mutual labels:  router
Routersdk
A mini and excellent Router Framwork一款小而美的路由框架。网页动态添加自定义参数启动应用。 https://github.com/Jomes/routerSDK
Stars: ✭ 402 (-3.37%)
Mutual labels:  router

UPnP PortMapper

Java CI Download UPnP PortMapper Maven Central Quality Gate Status Coverage

UPnP PortMapper is an easy to use program that manages the port mappings (port forwarding) of a UPnP enabled internet gateway device (router) in the local network. You can easily view, add and remove port mappings.

Using port forwarding, it is possible to access servers (SSH, Web, Game servers, ...) running in a private network from the internet. Port mappings can be configured using the web administration interface of a router, but using the UPnP PortMapper is much more convenient: Just create a new preset or select an existing preset and click one button to add a port mapping for your current computer, the IP address is retrieved automatically!

The interface is written in English and German. PortMapper automatically selects the language according your operating system.

Changes

See CHANGELOG.md for changes in the new version.

Getting started

Download UPnP PortMapper

Download binaries from SourceForge.

Install Java 11

UPnP PortMapper requires JRE 11 (Java Runtime Environment) or later. I recommend you download OpenJDK 11 JRE from AdoptOpenJDK.

For Windows please choose the .msi installer which will set the environment variable JAVA_HOME and add java to the PATH.

Verify that the installation was successful by running this command:

$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

Using PortMapper with Java 1.8

If you are still using Java 1.8 and can't upgrade to Java 11, you can use PortMapper version 2.1.1.

Running PortMapper

To run PortMapper, double click on the JAR file or run

$ java -jar portmapper.jar

on the command line.

Troubleshooting

General

  • Update the firmware of your router to the latest version.

PortMapper fails to start

Error 1: When you double click portmapper.jar, an error dialog with the following message is displayed:

A JNI error has occurred, please check your installation and try again

Error 2: When you start PortMapper from the command line using java -jar portmapper.jar you get the following exception:

java.lang.UnsupportedClassVersionError: org/chris/portmapper/PortMapperStarter has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Usually this means your Java version is outdated. Please install Java 11 or later. If this does not help: run PortMapper from the command line using java -jar portmapper.jar and create a ticket containing the stack trace.

PortMapper fails to start with ClassNotFoundException

$ java -Duser.language=en -jar portmapper.jar
Error: Could not find or load main class .language=en
Caused by: java.lang.ClassNotFoundException: /language=en

This error occurs when using PowerShell to start PortMapper with a system property argument, e.g. -Duser.language=en. To fix this, enclose the system property in double quotes, e.g.:

$ java "-Duser.language=en" -jar portmapper.jar

Router not found

  • Check if UPnP is activated in your router's settings.
  • Use a different UPnP library in the settings. Please note that DummyRouterFactory is just for testing.
  • Set Log level to TRACE in the settings, connect again and check the log.

Manually specify location URL

If you can connect to your router from one device but not from another you can directly specify the location URL.

Note: this is only supported for library weupnp (-lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory).

  1. Get location URL on the machine that can connect to the router by clicking the Info button (look for something like INFO - location = http://192.168.178.1:49000/igddesc.xml)
  2. Specify the location URL as a command line argument:
$ java "-Dportmapper.locationUrl=<locationurl>" -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory <args>

Adding port forwardings not possible

  • Check that your router allows write access via UPnP.
  • Try to add port forwardings manually via your router's user interface.
  • Use a different UPnP library in the settings. Please note that DummyRouterFactory is just for testing.

Multiple routers

If you have multiple routers in your network please use library org.chris.portmapper.router.weupnp.WeUPnPRouterFactory or org.chris.portmapper.router.sbbi.SBBIRouterFactory. After connecting a dialog will allow you to select one of the found routers. org.chris.portmapper.router.cling.ClingRouterFactory currently only supports one router.

Small font on high resolution displays

If you have a high resolution display and the fonts (e.g. the log) in PortMapper is too small, please upgrade to Java 9 or later. See http://openjdk.java.net/jeps/263 for details.

Port mappings are expiring

Some routers delete port mappings after some time. To avoid this you can use the command line interface of PortMapper to add the port mapping in an infinite loop. Under Windows you can use a .cmd script like this:

:loop

rem Add port mapping
java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -protocol tcp

rem Wait for 6 hours (6*60*60 seconds)
timeout 21600

goto loop

Press Ctrl+C to stop the infinite loop.

See the command line interface section for details about using the command line interface and available options.

Error when fetching port mappings

Sometimes you get a log message like this:

Got error response when fetching port mapping for entry number 0: '(IncomingActionResponseMessage) 500 Internal Server Error'. Stop getting more entries.

This error message is expected. UPnP does not allow getting the total number of available port mappings. That's why PortMapper continues fetching the mappings until it receives an error like this one. You can ignore these messages, they don't mean there is a problem.

Known issues

  • Under Ubuntu Linux it is not possible to retrieve the IP address of the local host, the address must be entered manually.

Command line interface

PortMapper also has a command line interface. You can see the available options by adding parameter -h:

$ java -jar portmapper.jar -h
 -add                  : Add a new port mapping
 -delete               : Delete a new port mapping
 -description VAL      : Description of the port mapping
 -externalPort N       : External port of the port mapping
 -gui                  : Start graphical user interface
 -h (-help)            : Print usage help
 -info                 : Print router info
 -internalPort N       : Internal port of the port mapping
 -ip VAL               : Internal IP of the port mapping (default: localhost)
 -lib VAL              : UPnP library to use
 -list                 : Print existing port mappings
 -protocol [TCP | UDP] : Protocol of the port mapping
 -routerIndex N        : Router index if more than one is found (zero-based)

Examples

  • Create a new port mapping for a specific IP address
$ java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -ip <ip-addr> -protocol tcp
  • Create a new port mapping for the local machine (just omit the IP)
$ java -jar portmapper.jar -add -externalPort <port> -internalPort <port> -protocol tcp
  • Delete a port forwarding
$ java -jar portmapper.jar -delete -externalPort <port> -protocol tcp
  • List existing port forwardings
$ java -jar portmapper.jar -list
  • Specify a UPnP library (see below for available libraries)
$ java -jar portmapper.jar -lib org.chris.portmapper.router.weupnp.WeUPnPRouterFactory -list

UPnP libraries

PortMapper includes three third party UPnP libraries. If the default does not work for your device, try using a different library.

  • Cling: org.chris.portmapper.router.cling.ClingRouterFactory (default)
  • weupnp: org.chris.portmapper.router.weupnp.WeUPnPRouterFactory
  • SBBI UPnP lib: org.chris.portmapper.router.sbbi.SBBIRouterFactory
  • org.chris.portmapper.router.dummy.DummyRouterFactory (for testing only)

Select language

PortMapper is translated to English (en) and German (de). It automatically detects the operating system's language, using English as default. If you want use a different language, add command line option -Duser.language=de to java, e.g.:

$ java "-Duser.language=de" -jar portmapper.jar

Using a custom directory for configuration files

PortMapper stores its configuration as XML files in a folder. Under Windows this folder is located at %AppData%\UnknownApplicationVendor\PortMapper\ (e.g. C:\Users\<username>\AppData\Roaming\UnknownApplicationVendor\PortMapper). You can change this folder by specifying a command line argument:

java -Dportmapper.config.dir=C:/path/to/config -jar portmapper.jar

Create an empty directory before starting, else PortMapper will fail with an error message.

The configuration files are only used when PortMapper runs in GUI mode. When running in command line mode the configuration files are not used. Instead you must specify all settings as command line arguments.

Development

Using PortMapper as a library

PortMapper is available as a Maven dependency at Maven Central. Use the following coordinates:

  • Gradle: com.github.kaklakariada:portmapper:2.2.2

  • Maven:

    <dependency>
      <groupId>com.github.kaklakariada</groupId>
      <artifactId>portmapper</artifactId>
      <version>2.2.2</version>
    </dependency>
    

Important: Due to the deprecation of JCenter new versions will be published to Maven Central. In your build script please use

repositories {
    mavenCentral()
}

Building PortMapper

Build PortMapper on the command line:

$ git clone https://github.com/kaklakariada/portmapper.git
$ cd portmapper
$ ./gradlew build
$ java -jar build/libs/portmapper-*.jar

Generate license header for added files

$ ./gradlew licenseFormat

Publish to Maven Central

  1. Add the following to your ~/.gradle/gradle.properties:

    ossrhUsername=<your maven central username>
    ossrhPassword=<your maven central passwort>
    
    signing.keyId=<gpg key id (last 8 chars)>
    signing.password=<gpg key password>
    signing.secretKeyRingFile=<path to secret keyring file>
    
  2. Increment version number in build.gradle and README.md, commit and push.

  3. Run the following command:

    $ ./gradlew clean check build publish closeAndReleaseRepository --info
    
  4. Create a new release on GitHub.

  5. After some time the release will be available at Maven Central.

Participate

Your feedback is most welcome at the project page:

  • Found a bug? Create an issue!
  • Miss some important feature? Create an issue!
  • Need help using the UPnP PortMapper? Post a message in the Forum!
  • Want to help with developing? Contact me via SourceForge.net!
  • Want to send me a mail? Use christoph at users.sourceforge.net!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].