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

!747

main {
  psvm {
    String s = backtick("ipconfig");
    List<String> lines = toLines(s);
    new TreeSet<String> ips;
    for (String line : lines) {
      if (indexOfIgnoreCase(line, "Gateway") >= 0)
        ips.addAll(matchAll("\\d+\\.\\d+\\.\\d+\\.\\d+", line));
    }
    if (ips.isEmpty()) System.out.println("No gateways found.");
    for (String ip : ips) {
      System.out.println("Possible gateway found: " + ip);
      try {
        String page = loadHomepage(ip);
        System.out.println("Home page of device follows\n");
        System.out.println(page);
      } catch (Throwable e) {
        System.out.println("Could not load home page of " + ip + ".");
      }
    }
  }
  
  static String loadHomepage(String ip) tex {
    return loadPage("http://" + ip + ":8888");
  }
}

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

1 comment(s) hidden. show

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: 799 / 793
Referenced in: [show references]