Git Product home page Git Product logo

waifupnp's Introduction

WaifUPnP

UPnP Port Forwarding for Java couldn't be any easier!

WaifUPnP is an extermely lightweight Java library that allows you to:

  • open/close TCP/UDP ports
  • check if there's an UPnP router available
  • check if a port is already mapped

using literally 1 line of code, as it should be!

It's as easy as:

UPnP.openTCP(<port number here>);

Usage Examples are included.

Usage

To compile, import the project in Netbeans. Alternatively, download the binaries from http://fdossena.com/?p=waifupnp/index.frag

Once you have the .jar files:

  • Import WaifUPnP.jar into your application
  • Optionally, import WaifUPnP-javadoc.jar if you need JavaDoc
  • WaifUPnP-sources.jar contains the source code and should not be imported into your project

Compatibility

Java 6 and newer

Limitations

WaifUPnP is a very basic implementation of UPnP, that only scans for the default gateway, and can only open/close ports.

While this is enough for most people, if you need a full implementation of UPnP, you should take a look at Cling

License

Copyright (C) 2015-2018 Federico Dossena

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/lgpl.

waifupnp's People

Contributors

adolfintel avatar asterixom avatar oreillymj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

waifupnp's Issues

Release new changes into a tag

Last commit is on Feb 9 2021
Last release is on June 24 2018

I'm not sure how many commits that release is behind from master but 3 years is a long time. I'm pretty sure every user of the library would appreciate an update.

Ensure that the selected default Gateway is the actual external router

Hi,
On my home network I have 4 Wireless routers. Unusual yes, but I'm sure I'm not the only person with more than 1 router.
3 routers are running in AP mode connected back to the internet router over Cat5. They don't supply IP addresses but all have the same SSID
However when I look at a UPnP scan I get 1 Netgear D6200 (not connected to the Internet) and the D6400 which is.

The D6200 is coming back first in the UPnP scan and is incorrectly being selected as the default GW.

It may not be a complete fix, but I altered GatewayFinder to exclude the D6200 which has an external IP of 0.0.0.0 and also to store the Gateways IP address using the source address of the returned Unicast UpnP packet.

Android compatibility

This piece of code is not compatible with Android. Do I need some libraries? or is there any other solution?

import org.w3c.dom.traversal.DocumentTraversal;
import org.w3c.dom.traversal.NodeFilter;
import org.w3c.dom.traversal.NodeIterator;

        NodeIterator iter = ((DocumentTraversal) d).createNodeIterator(d.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true);
        Node n;
        while ((n = iter.nextNode()) != null) {
            try {
                if (n.getFirstChild().getNodeType() == Node.TEXT_NODE) {
                    ret.put(n.getNodeName(), n.getTextContent());
                }
            } catch (Throwable t) {
            }
        }

Publishing to Maven

Hello,

I'm assuming based on issue #8 that it won't be a problem if I publish this library on Maven. However, I'll have to publish under my domain. I will, of course, maintain your copyright info as well as your name throughout the library.

I'm also thinking about publishing a modular version for Java 9+ though it might be enough to just include an automatic module name in the manifest file... certainly would be enough for most devs anyway...

It's an awesome library that just works, and it works well.

Thanks.

License/Permission Issue

Hey minecraft doesn't have your library installed. Can I distribute this jar for a networking mod? I don't see a release forums like maven and it might fail anyways.

I don't understand the license under gnu it says may convey a modified copy what the heck does that even mean can I or can I not redistribute it?

I would of course give a credits to you and a link back.

Resources Never Closed

From what I can tell it's only Line 62 of Gatewayfinder that the warning is but, I would check all three classes to be sure everything is right. If this is purposeful close the issue I just don't think it would be

Allow developers to change the name

Currently. If a user were to look at what uPnP applications activated a port it comes up with the name of WaifUPnP, something that isn't too informative to a user

Screenshot_20220702-182711

When I get some time, I'll create a pr

Help Port Doesn't Forward

so I love the idea of one line but, it appears it's not working for me. I believe UPNP is enabled on my internet box and utorrent does port forward but, I am trying to make a safe program to do so.

The code prints port did open and upnp is available also says true in the loop:
Issue http://www.canyouseeme.org can't find port open for 25565. I also tried udp same result Maybe I need to config your program to port my public ip instead of my private ip????

I also read that your only looking for a default gateway my internet is xfiniti maybe you could add an option to scan for all gateways? All I need is a port to open

Code:
https://pastebin.com/0uS4guVE

Output:
port opened:true
mapping:true
true

[Enhancement] Refresh UPNP all related stuffs

function: UPNP.refresh()

makes your program start from scratch again and find all gateways and stuffs
This is so when people port forward and media gets disconnected client's/servers don't have to restart the game which can take as much as 30 minuets in an mc modpack.

I don't know what all to call to make a refresh method myself since you wrote It I was hoping you could write it for me.

Closing Port Doesn't Always Work

router xfiniti:
program tested with: minecraft with lan-essentials(Not quite up to date):
https://github.com/jredfox/lanessentials
waifupnp

Code Ran during test run:
https://gist.github.com/jredfox/b98f0dca5da13d4d359b9fa6fcadfdb1

Test run:
while game is still running close port > doesn't always close port
while game has closed close port > doesn't always remove entry from http://10.1.10.1 internet service provider
when game is closed try and close the port.

Test run 2:
when application has been closed for several minuets close the port works

Test run 3:
when minecraft is still port forwarding close UDP port instead of TCP port and my port did get closed. Maybe your close UDP port and close TCP port are named wrong? I have an unmodified latest version of your library

Test run was tested with this code to close the port tried with both and just plain tcp which is what minecraft uses to host lan.

I hope you can make it remove the entry better since I have tried both while the program was running when it was closing and after it closed same result. Maybe it's an issue/bug with my internet service provider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.