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).

1  
!7
2  
3  
lib 1400216 import com.dosse.upnp.*;
4  
5  
static int port = 1234;
6  
7  
cmodule2 HolePuncher > DynPrintLog {
8  
  switchable int port = 1234;
9  
  S info;
10  
  
11  
  start-thread {
12  
    serveHttp(port);
13  
    print("Attempting UPnP port forwarding...");
14  
    if (UPnP.isUPnPAvailable()) {
15  
      if (UPnP.isMappedTCP(port))
16  
        info("UPnP port forwarding not enabled: port is already mapped");
17  
      else if (UPnP.openPortTCP(port))
18  
        info("UPnP port forwarding enabled. port " + port + " opened");
19  
      else
20  
        info("UPnP port forwarding failed");
21  
    } else
22  
      info("UPnP is not available");
23  
  }
24  
  
25  
  void info(S info) {
26  
    setField(info := print(info));
27  
  }
28  
}
29  
30  
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: 217 / 782
Version history: 3 change(s)
Referenced in: [show references]