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

39
LINES

< > BotCompany Repo | #1006054 // ContactInvisibles + concepts [Include]

JavaX fragment (include)

1  
concept SuccessfulProxyContact {
2  
  S proxy, target;
3  
  long lastSuccess;
4  
  S targetComputerID;
5  
}
6  
7  
sclass ContactInvisibles {
8  
  L<IP> aware, unaware;
9  
  Concepts in = mainConcepts;
10  
11  
  void doIt() {
12  
    aware = findConcepts(in, IP, aware := true);
13  
    print("Aware computers I can see: " + struct(collect(aware, "ip")));
14  
    unaware = findConcepts(in, IP, aware := false);
15  
    print("Computers I could try to proxy-contact: " + struct(collect(unaware, "ip")));
16  
    
17  
    for (IP ip : unaware)
18  
      tryToContact(ip.ip);
19  
  }
20  
  
21  
  void tryToContact(S target) {
22  
    for (IP proxy : aware) pcall {
23  
      print("Trying to contact " + target + " through " + proxy.ip);
24  
      long time = now();
25  
      S answer = sendToPublicCommBotThroughProxy(proxy.ip, target, "test");
26  
      print("  Answer: " + answer);
27  
      if (match("test", answer)) {
28  
        print("  Success!!\n");
29  
        SuccessfulProxyContact contact = uniq(SuccessfulProxyContact, proxy := proxy.ip, +target);
30  
        cset(contact, lastSuccess := time);
31  
        answer = sendToPublicCommBotThroughProxy(proxy.ip, target, forward("Awareness", "get computer id"));
32  
        S computerID = matchOK(answer);
33  
        if (computerID != null)
34  
          cset(contact, targetComputerID := computerID);
35  
        break;
36  
      }
37  
    }
38  
  }
39  
}

Author comment

Began life as a copy of #1006044

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006054
Snippet name: ContactInvisibles + concepts [Include]
Eternal ID of this version: #1006054/1
Text MD5: b69da0fdb02f535538e4c30c2a15371c
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-15 14:43:32
Source code size: 1315 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 551 / 807
Referenced in: [show references]