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

54
LINES

< > BotCompany Repo | #1006041 // Information Gatherer (collects visible peers with IP and computer ID)

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

Libraryless. Click here for Pure Java version (6972L/48K/157K).

!752

static double sleepTime = 10; // seconds

!include #1006054 // ContactInvisibles

concepts.

concept IP {
  S ip;
  bool myIP, aware;
  long lastCheck, lastSeenAware;
  S computerID;
  new Set<S> pastComputerIDs;
}

static L<S> myIPs;
static ContactInvisibles contactInvisibles;

p {
  contactInvisibles = new ContactInvisibles;
  myIPs = getMyIPs();
  startAwareness();
  conceptsAndBot();
  
  while licensed {
    pcall {
      for (S ip : getPeersListFrom("localhost"))
        checkIP(ip);
      contactInvisibles.doIt();
    }
    sleepSeconds(sleepTime);
  }
}

svoid checkIP(S ipAddress) {
  if (isLoopbackIP(ipAddress)) ret;
  IP ip = uniq(IP, ip := ipAddress);
  cset(ip, myIP := myIPs.contains(ipAddress));
  long time = now();
  if (isAware(ipAddress))
    cset(ip, aware := true, lastSeenAware := time);
  else
    cset(ip, aware := false);
  cset(ip, lastCheck := time);
  if (ip.aware) try {
    cset(ip, computerID := matchOK(sendToAwareness(ip.ip, "get computer id")));
    ip.pastComputerIDs.add(ip.computerID);
  } catch e {
    printShortException(e);
    cset(ip, computerID := null);
  }
  printConcept(ip);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006041
Snippet name: Information Gatherer (collects visible peers with IP and computer ID)
Eternal ID of this version: #1006041/1
Text MD5: 108f2e890b2e950350c94ee82e584cbf
Transpilation MD5: 4a86a6ae5b9eab02b81a1c7df1cbb8b8
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-18 02:41:57
Source code size: 1190 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 640 / 1092
Referenced in: [show references]