nodechan

decentralized peer-to-peer anonymous messageboard client
git clone git://squid-tech.com/nodechan.git
Log | Files | Refs | README

commit 657edeb30c6ebb0515c96d39e3f3bb43c5794790
parent b93ff4e93be2db3333f5bf345751e114cd1742e1
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Tue,  6 Aug 2019 13:09:45 -0400

Enable UPnP port mapping on startup

Diffstat:
Mbuild.sh | 2--
Arun.sh | 1+
Msrc/NodeChan.java | 19+++++++++++++++++--
3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/build.sh b/build.sh @@ -1,3 +1 @@ sudo javac -cp lib/WaifUPnP.jar src/NodeChan.java - -sudo java -cp src/:lib/WaifUPnP.jar NodeChan diff --git a/run.sh b/run.sh @@ -0,0 +1 @@ +sudo java -cp src/:lib/WaifUPnP.jar NodeChan diff --git a/src/NodeChan.java b/src/NodeChan.java @@ -15,6 +15,9 @@ import com.dosse.upnp.UPnP; * */ public class NodeChan { + /** The port the application will use to connect. **/ + public static final int PORT = 13370; + /** The IP address of this NodeChan node. **/ private static String node_ip; @@ -38,9 +41,21 @@ public class NodeChan { System.out.println("Your Node IP is " + node_ip + "\n"); if (UPnP.isUPnPAvailable()) { - + if (!UPnP.isMappedUDP(PORT)) { + if (UPnP.openPortUDP(PORT)) { + // UPnP port mapping successful + System.out.println("UPnP port mapping enabled.\n"); + } else { + System.out.println("UPnP port mapping failed. You will need to " + + "manually forward port " + PORT + " to your " + + "local IP.\n"); + } + } else { + System.out.println("Port " + PORT + " already mapped, continuing.\n"); + } } else { - System.err.println("UPnP not available. You will need to port forward.\n"); + System.out.println("UPnP not available. You will need to manually " + + "forward port " + PORT + " to your local IP.\n"); } System.out.println("Enter peer IP to connect directly,\nleave blank to" +