Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1031421 // "Hole Puncher" [in the firewall, i.e. see if you can run a public webserver]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1123K of libraries. Click here for Pure Java version (4920L/29K).

!7

lib 1400216 import com.dosse.upnp.*;

static int port = 1234;

cmodule2 HolePuncher > DynPrintLog {
  switchable int port = 1234;
  S info;
  
  start-thread {
    serveHttp(port);
    print("Attempting UPnP port forwarding...");
    if (UPnP.isUPnPAvailable()) {
      if (UPnP.isMappedTCP(port))
        info("UPnP port forwarding not enabled: port is already mapped");
      else if (UPnP.openPortTCP(port))
        info("UPnP port forwarding enabled. port " + port + " opened");
      else
        info("UPnP port forwarding failed");
    } else
      info("UPnP is not available");
  }
  
  void info(S info) {
    setField(info := print(info));
  }
}

html { ret "It works brah!!"; }

Author comment

Began life as a copy of #1024025

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031421
Snippet name: "Hole Puncher" [in the firewall, i.e. see if you can run a public webserver]
Eternal ID of this version: #1031421/4
Text MD5: 8d2997f1859e07d41705f9f3cb85593c
Transpilation MD5: 21f286bca11671e9d78a271e1ce3a445
Author: stefan
Category: javax / networking
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-12 05:07:46
Source code size: 722 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 106 / 669
Version history: 3 change(s)
Referenced in: [show references]