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

28
LINES

< > BotCompany Repo | #1001176 // Windows: Find gateway (e.g. your phone or VirtualBox host) and connect to it

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (620L/5K/17K).

1  
!747
2  
3  
main {
4  
  psvm {
5  
    String s = backtick("ipconfig");
6  
    List<String> lines = toLines(s);
7  
    new TreeSet<String> ips;
8  
    for (String line : lines) {
9  
      if (indexOfIgnoreCase(line, "Gateway") >= 0)
10  
        ips.addAll(matchAll("\\d+\\.\\d+\\.\\d+\\.\\d+", line));
11  
    }
12  
    if (ips.isEmpty()) System.out.println("No gateways found.");
13  
    for (String ip : ips) {
14  
      System.out.println("Possible gateway found: " + ip);
15  
      try {
16  
        String page = loadHomepage(ip);
17  
        System.out.println("Home page of device follows\n");
18  
        System.out.println(page);
19  
      } catch (Throwable e) {
20  
        System.out.println("Could not load home page of " + ip + ".");
21  
      }
22  
    }
23  
  }
24  
  
25  
  static String loadHomepage(String ip) tex {
26  
    return loadPage("http://" + ip + ":8888");
27  
  }
28  
}

Author comment

Began life as a copy of #712

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1107 stefan Works on Windows XP :) 2015-09-28 17:39:25

add comment

Snippet ID: #1001176
Snippet name: Windows: Find gateway (e.g. your phone or VirtualBox host) and connect to it
Eternal ID of this version: #1001176/1
Text MD5: aee00f84d97ebd4389c16ed071411985
Transpilation MD5: df52748053732cfca236304cde6edc8e
Author: stefan
Category: javax android
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-28 17:32:47
Source code size: 825 bytes / 28 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 815 / 821
Referenced in: [show references]