IPv6-enhanced Network monitoring page

pull/1/head
Michael Peter Christen 10 years ago
parent 7c1707872b
commit 65e6ae52fb

@ -1 +0,0 @@
#(table)#:: ::#[active-count]#;#[active-links]#;#[active-words]#;#[passive-count]#;#[passive-links]#;#[passive-words]#;#[potential-count]#;#[potential-links]#;#[potential-words]#;#[all-count]#;#[all-links]#;#[all-words]#;#[my-links]#;#[my-words]##(/table)#
1 #(table)#:: ::#[active-count]# #[active-links]# #[active-words]# #[passive-count]# #[passive-links]# #[passive-words]# #[potential-count]# #[potential-links]# #[potential-words]# #[all-count]# #[all-links]# #[all-words]# #[my-links]# #[my-words]##(/table)#

@ -104,54 +104,43 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.
</form>
<table class="sortable" border="0">
<tr class="TableHeader" valign="bottom">
<td>send&nbsp;<strong>M</strong>essage/<br/>show&nbsp;<strong>P</strong>rofile/<br/>edit&nbsp;<strong>W</strong>iki/<br/>browse&nbsp;<strong>B</strong>log</td>
<td><strong>Hash</strong></td>
<td><strong>Name</strong><br/></td>
<td width="34"><strong>Info</strong></td>
<td><strong>Release</strong></td>
<td><strong>Age</strong></td>
<td><strong>#Seeds</strong></td>
<td><strong>con/h<br/></strong></td>
<td><strong>PPM</strong></td>
<td><strong>QPH</strong></td>
<td><strong>Last<br/>Seen</strong></td>
<td><strong>UTC</strong><br/>Offset</td>
<td><strong>Location</strong><br/></td>
<td style="width:70px;"><strong>Uptime</strong></td>
<td><strong>Links</strong></td>
<td><strong>RWIs</strong></td>
<td><strong>URLs for<br/>Remote<br/>Crawl</strong></td>
<td><strong>Sent<br/>DHT Word Chunks</strong></td>
<td><strong>URLs<br/>for<br/>Remote<br/>Crawl</strong></td>
<td><strong>Sent DHT<br/>Word Chunks</strong></td>
<td><strong>Sent<br/>URLs</strong></td>
<td><strong>Received<br/>DHT Word Chunks</strong></td>
<td><strong>Received DHT<br/>Word Chunks</strong></td>
<td><strong>Received<br/>URLs</strong></td>
#(complete)#::
<td><strong>Address</strong></td>
<td><strong>Hash</strong></td>
<td><strong>Age</strong></td>
<td><strong>#Seeds</strong></td>
<td><strong>con/h<br/></strong></td>
<td><strong>user agent<br/></strong></td>
<td><strong>Peer<br/>Ping</strong></td>
#(/complete)#
<td><strong>Location</strong><br/></td>
#(c)#::<td><strong>user agent<br/></strong></td>#(/c)#
<td>send&nbsp;<strong>M</strong>essage/<br/>show&nbsp;<strong>P</strong>rofile/<br/>edit&nbsp;<strong>W</strong>iki/<br/>browse&nbsp;<strong>B</strong>log</td>
</tr>
#{list}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
<td><nobr>
<a href="MessageSend_p.html?hash=#[hash]#" title="Send message to peer #[fullname]#">m</a>&nbsp;
<a href="ViewProfile.html?hash=#[hash]#&amp;display=1" title="View profile of peer #[fullname]#">p</a>&nbsp;
<a href="goto_p.html?hash=#[hash]#&path=/Wiki.html" title="Read and edit wiki on peer #[fullname]#">w</a>&nbsp;
<a href="goto_p.html?hash=#[hash]#&path=/Blog.html" title="Browse blog of peer #[fullname]#">b</a>&nbsp;
#(updatedProfile)#::<a href="ViewProfile.html?hash=#[hash]#&amp;display=1"><img src="env/grafics/profile.gif" width="54" height="11" alt="Profile updated" /></a>#(/updatedProfile)#
#(updatedWiki)#::<a href="http://#[address]#/Wiki.html?page=#[page]#" title="#[page]#"><img src="env/grafics/wiki.gif" width="54" height="11" alt="Wiki updated" /></a>#(/updatedWiki)#
#(updatedBlog)#::<a href="http://#[address]#/Blog.html?page=#[page]#" title="#[subject]#"><img src="env/grafics/blog.gif" width="54" height="11" alt="Blog updated" /></a>#(/updatedBlog)#
#(isCrawling)#::<a href="#[page]#"><img src="env/grafics/crawl.gif" width="54" height="11" alt="Crawl" /></a>#(/isCrawling)#
</nobr></td>
<td #(special)#::class="TableCellActive"#(/special)#><a href="goto_p.html?hash=#[hash]#">#[shortname]#</a>#(ssl)#::<img src="env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/ssl)#</td>
<td >#[hash]#</td>
<td #(special)#::class="TableCellActive"#(/special)#>#[shortname]##(ssl)#::<img src="env/grafics/lock.gif" width="11" height="15" title="https supported" alt="https supported" />#(/ssl)#</td>
<td nowrap>
#(type)##(direct)#<img src="env/grafics/JuniorPassive.gif" width="11" height="11" title="Type: Junior | Contact: passive" alt="Junior passive" />::<img src="env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior | Contact: direct" alt="Junior direct" />::<img src="env/grafics/JuniorOffline.gif" width="11" height="11" title="Type: Junior | Contact: offline" alt="Junior offline" />#(/direct)#::#(direct)#<img src="env/grafics/SeniorPassive.gif" width="11" height="11" title="Type: Senior | Contact: passive" alt="senior passive" />::<img src="env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior | Contact: direct" alt="Senior direct" />::<img src="env/grafics/SeniorOffline.gif" width="11" height="11" title="Type: Senior | Contact: offline" alt="Senior offline" />#(/direct)#::<a href="#[url]#">#(direct)#<img src="env/grafics/PrincipalPassive.gif" width="11" height="11" title="Type: Principal | Contact: passive | Seed download: possible" alt="Principal passive" />::<img src="env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal | Contact: direct | Seed download: possible" alt="Principal active" />::<img src="env/grafics/PrincipalOffline.gif" width="11" height="11" title="Type: Principal | Contact: offline | Seed download: ?" alt="Principal offline" />#(/direct)#</a>#(/type)##(acceptcrawl)#<img src="env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />::<img src="env/grafics/CrawlYesOffline.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />#(/acceptcrawl)##(dhtreceive)#<img src="env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no; #[peertags]#" alt="no DHT receive" />::<img src="env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />::<img src="env/grafics/DHTReceiveYesOffline.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />#(/dhtreceive)##(nodestate)#<img src="env/grafics/RootStateNo.gif" width="11" height="11" title="Not a Node Candidate" alt="no node candidate" />::<a href="http://#[ip]#:#[port]#/Network.html?page=1"><img src="env/grafics/RootStateYes.gif" width="11" height="11" title="Node Candidate" alt="node candidate" /></a>#(/nodestate)#</td>
#(type)##(direct)#<img src="env/grafics/JuniorPassive.gif" width="11" height="11" title="Type: Junior | Contact: passive" alt="Junior passive" />::<img src="env/grafics/JuniorDirect.gif" width="11" height="11" title="Type: Junior | Contact: direct" alt="Junior direct" />::<img src="env/grafics/JuniorOffline.gif" width="11" height="11" title="Type: Junior | Contact: offline" alt="Junior offline" />#(/direct)#::#(direct)#<img src="env/grafics/SeniorPassive.gif" width="11" height="11" title="Type: Senior | Contact: passive" alt="senior passive" />::<img src="env/grafics/SeniorDirect.gif" width="11" height="11" title="Type: Senior | Contact: direct" alt="Senior direct" />::<img src="env/grafics/SeniorOffline.gif" width="11" height="11" title="Type: Senior | Contact: offline" alt="Senior offline" />#(/direct)#::<a href="#[url]#" class="forceNoExternalIcon">#(direct)#<img src="env/grafics/PrincipalPassive.gif" width="11" height="11" title="Type: Principal | Contact: passive | Seed download: possible" alt="Principal passive" />::<img src="env/grafics/PrincipalDirect.gif" width="11" height="11" title="Type: Principal | Contact: direct | Seed download: possible" alt="Principal active" />::<img src="env/grafics/PrincipalOffline.gif" width="11" height="11" title="Type: Principal | Contact: offline | Seed download: ?" alt="Principal offline" />#(/direct)#</a>#(/type)##(acceptcrawl)#<img src="env/grafics/CrawlNo.gif" width="11" height="11" title="Accept Crawl: no" alt="no crawl" />::<img src="env/grafics/CrawlYes.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />::<img src="env/grafics/CrawlYesOffline.gif" width="11" height="11" title="Accept Crawl: yes" alt="crawl possible" />#(/acceptcrawl)##(dhtreceive)#<img src="env/grafics/DHTReceiveNo.gif" width="11" height="11" title="DHT Receive: no; #[peertags]#" alt="no DHT receive" />::<img src="env/grafics/DHTReceiveYes.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />::<img src="env/grafics/DHTReceiveYesOffline.gif" width="11" height="11" title="DHT Receive: yes" alt="DHT receive enabled" />#(/dhtreceive)##{ips}#<a href="#(c)#http://#(ipv6)#::[#(/ipv6)##[ip]##(ipv6)#::]#(/ipv6)#:#[port]#/Network.html?page=1::Network.html?page=4&amp;peerHash=#[hash]#&amp;peerIP=#[ip]#&amp;peerPort=#[port]#&amp;addPeer=add+Peer#(/c)#" class="forceNoExternalIcon"><img src="env/grafics/#(nodestate)#NodeDisqualified::NodeQualified#(/nodestate)##(c)##(ipv6)#IPv4::IPv6#(/ipv6)#::#(ipv6)#IPv4::IPv6#(/ipv6)##(/c)#.gif" width="11" height="11" title="#(c)##(ipv6)#IPv4::IPv6#(/ipv6)#::#(ipv6)#IPv4::IPv6#(/ipv6)##(/c)# #(nodestate)#Peer::Node Peer#(/nodestate)#" /></a>#{/ips}#</td>
<td align="right">#[version]#</td>
<td align="right">#[age]#</td>
<td align="right">#[seeds]#</td>
<td align="right">#[connects]#</td>
<td align="right">#[ppm]#</td>
<td align="right">#[qph]#</td>
<td align="right">#[lastSeen]#</td>
<td align="right">#[utc]#</td>
<td align="right">#[location]#</td>
<td align="right" nowrap>#[uptime]#</td>
<td align="right">#[LCount]#</td>
<td align="right">#[ICount]#</td>
@ -160,16 +149,18 @@ document.getElementById("apilink").setAttribute("href", "Network.xml?" + window.
<td align="right">#[sU]#</td>
<td align="right">#[rI]#</td>
<td align="right">#[rU]#</td>
#(complete)#
::
<td><a href="http://#[ip]#:#[port]#/Network.html?page=1&amp;ip=">http://#[ip]#:#[port]#</a> #[ips]#</td>
<td >#[hash]#</td>
<td >#[age]#</td>
<td align="right">#[seeds]#</td>
<td align="right">#[connects]#</td>
<td align="right">#[userAgent]#</td>
<td align="right">[<a href="Network.html?page=4&amp;peerHash=#[hash]#&amp;peerIP=#[ip]#&amp;peerPort=#[port]#&amp;addPeer=add+Peer">Ping</a>]</td>
#(/complete)#
<td align="right">#[location]#</td>
#(c)#::<td align="right">#[userAgent]#</td>#(/c)#
<td><nobr>
<a href="MessageSend_p.html?hash=#[hash]#" title="Send message to peer #[fullname]#">m</a>&nbsp;
<a href="ViewProfile.html?hash=#[hash]#&amp;display=1" title="View profile of peer #[fullname]#">p</a>&nbsp;
<a href="goto_p.html?hash=#[hash]#&path=/Wiki.html" title="Read and edit wiki on peer #[fullname]#">w</a>&nbsp;
<a href="goto_p.html?hash=#[hash]#&path=/Blog.html" title="Browse blog of peer #[fullname]#">b</a>&nbsp;
#(updatedProfile)#::<a href="ViewProfile.html?hash=#[hash]#&amp;display=1"><img src="env/grafics/profile.gif" width="54" height="11" alt="Profile updated" /></a>#(/updatedProfile)#
#(updatedWiki)#::<a href="http://#[address]#/Wiki.html?page=#[page]#" title="#[page]#"><img src="env/grafics/wiki.gif" width="54" height="11" alt="Wiki updated" /></a>#(/updatedWiki)#
#(updatedBlog)#::<a href="http://#[address]#/Blog.html?page=#[page]#" title="#[subject]#"><img src="env/grafics/blog.gif" width="54" height="11" alt="Blog updated" /></a>#(/updatedBlog)#
#(isCrawling)#::<a href="#[page]#"><img src="env/grafics/crawl.gif" width="54" height="11" alt="Crawl" /></a>#(/isCrawling)#
</nobr></td>
</tr>
#{/list}#
</table>

@ -32,6 +32,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Matcher;
@ -210,19 +211,21 @@ public class Network {
Seed peer = new Seed(post.get("peerHash"), map);
sb.updateMySeed();
final int added = Protocol.hello(sb.peers.mySeed(), sb.peers.peerActions, peer);
final Map<String, String> response = Protocol.hello(sb.peers.mySeed(), sb.peers.peerActions, peer);
if (added <= 0) {
if (response == null) {
prop.put("table_comment",1);
prop.putHTML("table_comment_status","publish: disconnected peer '" + peer.getName() + "/" + post.get("peerHash") + "' from " + peer.getIPs());
prop.putHTML("table_comment_status","publish: no response from peer '" + peer.getName() + "/" + post.get("peerHash") + "' from " + peer.getIPs());
} else {
String yourtype = response.get("yourtype");
String yourip = response.get("yourip");
peer = sb.peers.getConnected(peer.hash);
if (peer == null) {
prop.put("table_comment",1);
prop.putHTML("table_comment_status","publish: disconnected peer 'UNKNOWN/" + post.get("peerHash") + "' from UNKNOWN");
prop.putHTML("table_comment_status","publish: disconnected peer 'UNKNOWN/" + post.get("peerHash") + "' from UNKNOWN, yourtype = " + yourtype + ", yourip = " + yourip);
} else {
prop.put("table_comment",2);
prop.putHTML("table_comment_status","publish: handshaked " + peer.get(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR) + " peer '" + peer.getName() + "' at " + peer.getIPs());
prop.putHTML("table_comment_status","publish: handshaked " + peer.get(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR) + " peer '" + peer.getName() + "' at " + peer.getIPs() +", yourtype = " + yourtype + ", yourip = " + yourip);
prop.putHTML("table_comment_details",peer.toString());
}
}
@ -285,7 +288,7 @@ public class Network {
boolean dark = true;
Seed seed;
final boolean complete = (post != null && post.containsKey("ip"));
final boolean c = (post != null && post.containsKey("ip"));
final boolean onlyIncomingDHT = (post != null && post.containsKey("onlydhtin"));
final boolean onlyNode = (post != null && post.containsKey("onlynode"));
final long onlyAgeOverDays = post == null ? 0 : post.getLong("onlyageoverdays", 0);
@ -341,6 +344,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", 0);
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
String ip = seed.getIP();
if (conCount >= maxCount) { break; }
if (sb.peers != null && sb.peers.mySeed() != null && seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) {
prop.put(STR_TABLE_LIST + conCount + "_dark", 2);
@ -356,7 +360,7 @@ public class Network {
} else {
prop.put(STR_TABLE_LIST + conCount + "_updatedWiki", 1);
prop.putHTML(STR_TABLE_LIST + conCount + "_updatedWiki_page", wikiMap.get("page"));
prop.put(STR_TABLE_LIST + conCount + "_updatedWiki_address", seed.getPublicAddress());
prop.put(STR_TABLE_LIST + conCount + "_updatedWiki_address", seed.getPublicAddress(ip));
}
if ((blogMap = updatedBlog.get(seed.hash)) == null) {
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
@ -364,7 +368,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 1);
prop.putHTML(STR_TABLE_LIST + conCount + "_updatedBlog_page", blogMap.get("page"));
prop.putHTML(STR_TABLE_LIST + conCount + "_updatedBlog_subject", blogMap.get("subject"));
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog_address", seed.getPublicAddress());
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog_address", seed.getPublicAddress(ip));
}
PPM = seed.getPPM();
QPM = seed.getQPM();
@ -386,30 +390,39 @@ public class Network {
userAgent = ClientIdentification.yacyInternetCrawlerAgent.userAgent;
location = ClientIdentification.generateLocation();
} else {
userAgent = sb.peers.peerActions.getUserAgent(seed.getIP());
userAgent = sb.peers.peerActions.getUserAgent(ip);
location = ClientIdentification.parseLocationInUserAgent(userAgent);
}
if (location.length() > 10) location = location.substring(0, 10);
if (location.length() == 0) {
Locale l = Domains.getLocale(seed.getIP());
Locale l = Domains.getLocale(ip);
if (l != null) location = l.toString();
}
prop.putHTML(STR_TABLE_LIST + conCount + "_location", location);
if (complete) {
prop.put(STR_TABLE_LIST + conCount + "_complete", 1);
prop.putHTML(STR_TABLE_LIST + conCount + "_complete_ip", seed.getIP() );
prop.putHTML(STR_TABLE_LIST + conCount + "_complete_ips", seed.getIPs().toString() );
prop.put(STR_TABLE_LIST + conCount + "_complete_port", seed.get(Seed.PORT, "-") );
prop.put(STR_TABLE_LIST + conCount + "_complete_hash", seed.hash);
prop.put(STR_TABLE_LIST + conCount + "_complete_age", seed.getAge());
prop.putNum(STR_TABLE_LIST + conCount + "_complete_seeds", seed.getLong(Seed.SCOUNT, 0L));
prop.putNum(STR_TABLE_LIST + conCount + "_complete_connects", seed.getFloat(Seed.CCOUNT, 0F));
prop.putHTML(STR_TABLE_LIST + conCount + "_complete_userAgent", userAgent);
String port = seed.get(Seed.PORT, "-");
Set<String> ips = seed.getIPs();
int ipsc = 0;
for (String s: ips) {
prop.put(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_nodestate", seed.getFlagRootNode() ? 1 : 0);
prop.put(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_c", c ? 1 : 0);
prop.putHTML(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_c_hash", seed.hash);
prop.putHTML(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_c_ip", s);
prop.putHTML(STR_TABLE_LIST + conCount + "_ips_" + ipsc + "_c_port", port);
prop.put(STR_TABLE_LIST + conCount + "_ips_" + ipsc++ + "_c_ipv6", s.indexOf(':') >= 0 ? 1 : 0);
}
prop.put(STR_TABLE_LIST + conCount + "_ips", ipsc);
prop.put(STR_TABLE_LIST + conCount + "_port", port);
prop.put(STR_TABLE_LIST + conCount + "_hash", seed.hash);
prop.put(STR_TABLE_LIST + conCount + "_age", seed.getAge());
prop.putNum(STR_TABLE_LIST + conCount + "_seeds", seed.getLong(Seed.SCOUNT, 0L));
prop.putNum(STR_TABLE_LIST + conCount + "_connects", seed.getFloat(Seed.CCOUNT, 0F));
if (c) {
prop.put(STR_TABLE_LIST + conCount + "_c", 1);
prop.putHTML(STR_TABLE_LIST + conCount + "_c_userAgent", userAgent);
} else {
prop.put(STR_TABLE_LIST + conCount + "_complete", 0);
prop.put(STR_TABLE_LIST + conCount + "_c", 0);
}
if (seed.isJunior()) {
prop.put(STR_TABLE_LIST + conCount + "_type", 0);
} else if(seed.isSenior()){
@ -447,9 +460,6 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", 0); // red/red; offline was off
}
}
prop.put(STR_TABLE_LIST + conCount + "_nodestate", seed.getFlagRootNode() ? 1 : 0);
prop.put(STR_TABLE_LIST + conCount + "_nodestate_ip", seed.getIP());
prop.put(STR_TABLE_LIST + conCount + "_nodestate_port", seed.get(Seed.PORT, "-") );
if (seed.getFlagAcceptRemoteIndex()) {
prop.put(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", "");
} else {
@ -479,7 +489,7 @@ public class Network {
prop.put("table", 1);
prop.putNum("table_num", conCount);
prop.putNum("table_total", ((page == 1) && (iAmActive)) ? (size + 1) : size );
prop.put("table_complete", ((complete)? 1 : 0) );
prop.put("table_c", ((c)? 1 : 0) );
}
}
prop.put("page", page);

@ -21,17 +21,16 @@
<direct>#(type_direct)#direct::passive#(/type_direct)#</direct>
<acceptcrawl>#[acceptcrawl]#</acceptcrawl>
<dhtreceive>#[dhtreceive]#</dhtreceive>
<nodestate>#[nodestate]#</nodestate>
<nodestate>#(nodestate)#false::true#(/nodestate)#</nodestate>
<location>#[location]#</location>
<seedurl>#[type_url]#</seedurl>
#(complete)#
::
<age>#[age]#</age>
<seeds>#[seeds]#</seeds>
<connects>#[connects]#</connects>
<address>#[ip]#:#[port]#</address>
<useragent>#[userAgent]#</useragent>
#(/complete)#
#{ips}#<ip>#(c)##[ip]#::#[ip]##(/c)#</ip>#{/ips}#
#{ips}#<address>#(c)##(ipv6)#::[#(/ipv6)##[ip]##(ipv6)#::]#(/ipv6)#:#[port]#::#(/c)#</address>#{/ips}#
<port>#[port]#</port>
#(c)#::<useragent>#[userAgent]#</useragent>#(/c)#
</peer>
#{/list}#
::

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

@ -185,14 +185,7 @@ public class Network
+ this.sb.peers.sizeConnected()
+ " new peer(s)");
}
final int newSeeds = publishMySeed(false);
if ( newSeeds > 0 ) {
log.info("received "
+ newSeeds
+ " new peer(s), know a total of "
+ this.sb.peers.sizeConnected()
+ " different peers");
}
publishMySeed(false);
}
// use our own formatter to prevent concurrency locks with other processes
@ -202,7 +195,7 @@ public class Network
protected class publishThread extends Thread
{
int added;
private Map<String, String> result;
private final Seed seed;
private final Semaphore sync;
private final List<Thread> syncList;
@ -219,14 +212,14 @@ public class Network
this.syncList = syncList;
this.seed = seed;
this.added = 0;
this.result = null;
}
@Override
public final void run() {
try {
this.added = Protocol.hello(Network.this.sb.peers.mySeed(), Network.this.sb.peers.peerActions, this.seed);
if ( this.added < 0 ) {
this.result = Protocol.hello(Network.this.sb.peers.mySeed(), Network.this.sb.peers.peerActions, this.seed);
if ( this.result == null ) {
// no or wrong response, delete that address
final String cause = "peer ping to peer resulted in error response (added < 0)";
log.info("publish: disconnected "
@ -324,7 +317,7 @@ public class Network
}
}
private int publishMySeed(final boolean force) {
private boolean publishMySeed(final boolean force) {
try {
// call this after the httpd was started up
@ -349,9 +342,7 @@ public class Network
// getting a list of peers to contact
if ( this.sb.peers.mySeed().get(Seed.PEERTYPE, Seed.PEERTYPE_VIRGIN).equals(Seed.PEERTYPE_VIRGIN) ) {
if ( attempts > PING_INITIAL ) {
attempts = PING_INITIAL;
}
if (attempts > PING_INITIAL) attempts = PING_INITIAL;
final Set<byte[]> ch = Switchboard.getSwitchboard().clusterhashes;
seeds = DHTSelection.seedsByAge(this.sb.peers, true, attempts - ((ch == null) ? 0 : ch.size())); // best for fast connection
// add also all peers from cluster if this is a public robinson cluster
@ -363,9 +354,7 @@ public class Network
seed = seeds.get(hash);
if (seed == null) {
seed = this.sb.peers.get(hash);
if ( seed == null ) {
continue;
}
if (seed == null) continue;
}
seeds.put(hash, seed);
}
@ -385,12 +374,8 @@ public class Network
seeds = DHTSelection.seedsByAge(this.sb.peers, false, attempts); // best for seed list maintenance/cleaning
}
if ( seeds == null || seeds.isEmpty() ) {
return 0;
}
if ( seeds.size() < attempts ) {
attempts = seeds.size();
}
if (seeds == null || seeds.isEmpty()) return false;
if (seeds.size() < attempts) attempts = seeds.size();
// This will try to get Peers that are not currently in amIAccessibleDB
final Iterator<Seed> si = seeds.values().iterator();
@ -408,14 +393,13 @@ public class Network
log.severe("publishMySeed: problem with news encoding", e);
}
this.sb.peers.mySeed().setUnusedFlags();
int newSeeds = -1;
//if (seeds.length > 1) {
// holding a reference to all started threads
int contactedSeedCount = 0;
final List<Thread> syncList = Collections.synchronizedList(new LinkedList<Thread>()); // memory for threads
final Semaphore sync = new Semaphore(attempts);
// going through the peer list and starting a new publisher thread for each peer
// go through the peer list and starting a new publisher thread for each peer
int i = 0;
while ( si.hasNext() ) {
seed = si.next();
@ -426,9 +410,7 @@ public class Network
i++;
final String address = seed.getPublicAddress(seed.getIP());
if ( log.isFine() ) {
log.fine("HELLO #" + i + " to peer '" + seed.get(Seed.NAME, "") + "' at " + address); // debug
}
if ( log.isFine() ) log.fine("HELLO #" + i + " to peer '" + seed.get(Seed.NAME, "") + "' at " + address); // debug
final String seederror = seed.isProper(false);
if ( (address == null) || (seederror != null) ) {
// we don't like that address, delete it
@ -456,15 +438,6 @@ public class Network
// getting a reference to the finished thread
final publishThread t = (publishThread) syncList.remove(0);
// getting the amount of new reported seeds
if ( t.added >= 0 ) {
if ( newSeeds == -1 ) {
newSeeds = t.added;
} else {
newSeeds += t.added;
}
}
}
int accessible = 0;
@ -486,19 +459,9 @@ public class Network
}
}
}
if ( log.isFine() ) {
log
.fine("DBSize before -> after Cleanup: "
+ dbSize
+ " -> "
+ amIAccessibleDB.size());
}
if (log.isFine()) log.fine("DBSize before -> after Cleanup: " + dbSize + " -> " + amIAccessibleDB.size());
}
log.info("PeerPing: I am accessible for "
+ accessible
+ " peer(s), not accessible for "
+ notaccessible
+ " peer(s).");
log.info("PeerPing: I am accessible for " + accessible + " peer(s), not accessible for " + notaccessible + " peer(s).");
if ( (accessible + notaccessible) > 0 ) {
final String newPeerType;
@ -517,11 +480,7 @@ public class Network
if ( this.sb.peers.mySeed().orVirgin().equals(newPeerType) ) {
log.info("PeerPing: myType is " + this.sb.peers.mySeed().orVirgin());
} else {
log.info("PeerPing: changing myType from '"
+ this.sb.peers.mySeed().orVirgin()
+ "' to '"
+ newPeerType
+ "'");
log.info("PeerPing: changing myType from '" + this.sb.peers.mySeed().orVirgin() + "' to '" + newPeerType + "'");
this.sb.peers.mySeed().put(Seed.PEERTYPE, newPeerType);
}
} else {
@ -534,20 +493,11 @@ public class Network
this.sb.peers.saveMySeed();
// if we have an address, we do nothing
if ( this.sb.peers.mySeed().isProper(true) == null && !force ) {
return 0;
}
if ( newSeeds > 0 ) {
return newSeeds;
}
if (this.sb.peers.mySeed().isProper(true) == null) return true;
// still no success: ask own NAT or internet responder
//final boolean DI604use = switchboard.getConfig("DI604use", "false").equals("true");
//final String DI604pw = switchboard.getConfig("DI604pw", "");
// still no success
final String ip = this.sb.getConfig("staticIP", "");
//if (ip.equals("")) ip = natLib.retrieveIP(DI604use, DI604pw);
// yacyCore.log.logDebug("DEBUG: new IP=" + ip);
if (Seed.isProperIP(ip)) {
this.sb.peers.mySeed().setIP(ip);
}
@ -556,7 +506,7 @@ public class Network
}
log.info("publish: no recipient found, our address is " + this.sb.peers.mySeed().getIPs());
this.sb.peers.saveMySeed();
return 0;
return false;
} catch (final InterruptedException e ) {
try {
log.info("publish: Interruption detected while publishing my seed.");
@ -606,12 +556,10 @@ public class Network
log.info("publish: Shutdown off all remaining publishing thread finished.");
} catch (final Exception ee ) {
log.warn(
"publish: Unexpected error while trying to shutdown all remaining publishing threads.",
e);
log.warn("publish: Unexpected error while trying to shutdown all remaining publishing threads.", e);
}
return 0;
return false;
}
}

@ -167,7 +167,7 @@ public final class Protocol {
*
* @return the number of new seeds
*/
public static int hello(
public static Map<String, String> hello(
final Seed mySeed,
final PeerActions peerActions,
final Seed otherSeed) {
@ -201,7 +201,7 @@ public final class Protocol {
Network.log.info("yacyClient.hello thread '"
+ Thread.currentThread().getName()
+ "' interrupted.");
return -1;
return null;
}
Network.log.info("yacyClient.hello thread '" + Thread.currentThread().getName() + "', peer " + address + "; exception: " + e.getMessage());
// try again (go into loop)
@ -211,7 +211,7 @@ public final class Protocol {
if (result == null || result.size() == 0) {
Network.log.info("yacyClient.hello result error: "
+ ((result == null) ? "result null" : ("result=" + result.toString())));
return -1;
return null;
}
Network.log.info("yacyClient.hello thread '"
+ Thread.currentThread().getName()
@ -233,7 +233,7 @@ public final class Protocol {
try {
// patch the remote peer address to avoid that remote peers spoof the network with wrong addresses
final int p = address.lastIndexOf(':');
if ( p < 0 ) return -1;
if ( p < 0 ) return null;
String h = address.substring(0, p);
if (h.charAt(0) == '[') h = h.substring(1);
if (h.charAt(h.length() - 1) == ']') h = h.substring(0, h.length() - 1);
@ -241,11 +241,11 @@ public final class Protocol {
otherPeer = Seed.genRemoteSeed(seed, false, ie.getHostAddress());
if ( !otherPeer.hash.equals(otherSeed.hash) ) {
Network.log.info("yacyClient.hello: consistency error: otherPeer.hash = " + otherPeer.hash + ", otherHash = " + otherSeed.hash);
return -1; // no success
return null; // no success
}
} catch (final IOException e ) {
Network.log.info("yacyClient.hello: consistency error: other seed bad:" + e.getMessage() + ", seed=" + seed);
return -1; // no success
return null; // no success
}
}
}
@ -313,7 +313,7 @@ public final class Protocol {
+ mytype
+ ", rejecting other peer.");
}
return -1;
return null;
}
if ( mySeed.orVirgin().equals(Seed.PEERTYPE_VIRGIN) ) {
mySeed.put(Seed.PEERTYPE, mytype);
@ -322,7 +322,7 @@ public final class Protocol {
final String error = mySeed.isProper(true);
if ( error != null ) {
Network.log.warn("yacyClient.hello mySeed error - not proper: " + error);
return -1;
return null;
}
//final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time
@ -347,7 +347,7 @@ public final class Protocol {
if ( i == 1 ) {
final int p = address.indexOf(':');
if ( p < 0 ) {
return -1;
return null;
}
InetAddress ia = Domains.dnsResolve(address.substring(0, p));
if (ia == null) continue;
@ -371,7 +371,7 @@ public final class Protocol {
// update event tracker
EventTracker.update(EventTracker.EClass.PEERPING, new ProfilingGraph.EventPing(mySeed.getName(), otherSeed.getName(), true, connectedAfter - connectedBefore), false);
return count;
return result;
}
public static Seed querySeed(final Seed target, final String seedHash) {

Loading…
Cancel
Save