added location column to network pages.

The location is computed from the userAgent string of connecting peers.
Therefore this information is not available right after start-up.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1241 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 4c42dbab3a
commit b3dca06bb1

@ -45,6 +45,7 @@
<td class="small"><b>PPM</b><br>&nbsp;</td> <td class="small"><b>PPM</b><br>&nbsp;</td>
<td class="small"><b>Last<br>Seen</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=LastSeen&order=down">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=LastSeen&order=up">&gt;</a></td> <td class="small"><b>Last<br>Seen</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=LastSeen&order=down">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=LastSeen&order=up">&gt;</a></td>
<td class="small"><b>UTC</b><br>Offset<br>&nbsp;</td> <td class="small"><b>UTC</b><br>Offset<br>&nbsp;</td>
<td class="small"><b>Location</b><br><br>&nbsp;</td>
<td class="small"><b>Uptime</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=Uptime&order=up">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=Uptime&order=down">&gt;</a></td> <td class="small"><b>Uptime</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=Uptime&order=up">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=Uptime&order=down">&gt;</a></td>
<td class="small"><b>#Links</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=LCount&order=up">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=LCount&order=down">&gt;</a></td> <td class="small"><b>#Links</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=LCount&order=up">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=LCount&order=down">&gt;</a></td>
<td class="small"><b>#RWIs</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=ICount&order=up">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=ICount&order=down">&gt;</a></td> <td class="small"><b>#RWIs</b><br>&nbsp;&nbsp;<a href="/Network.html?page=#[page]#&sort=ICount&order=up">&lt;</a>&nbsp;<a href="/Network.html?page=#[page]#&sort=ICount&order=down">&gt;</a></td>
@ -59,6 +60,7 @@
<td class="small"><b>Age</b><br>&nbsp;</td> <td class="small"><b>Age</b><br>&nbsp;</td>
<td class="small"><b>#Seeds</b><br>&nbsp;</td> <td class="small"><b>#Seeds</b><br>&nbsp;</td>
<td class="small"><b>con/h<br></b><br>&nbsp;</td> <td class="small"><b>con/h<br></b><br>&nbsp;</td>
<td class="small"><b>user agent<br></b><br>&nbsp;</td>
#(/complete)# #(/complete)#
</tr> </tr>
#{list}# #{list}#
@ -74,6 +76,7 @@
<td class="small" align="right">#[ppm]#</td> <td class="small" align="right">#[ppm]#</td>
<td class="small" align="right">#[lastSeen]#</td> <td class="small" align="right">#[lastSeen]#</td>
<td class="small" align="right">#[utc]#</td> <td class="small" align="right">#[utc]#</td>
<td class="small" align="right">#[location]#</td>
<td class="small" align="right"><NOBR>#[uptime]#</NOBR></td> <td class="small" align="right"><NOBR>#[uptime]#</NOBR></td>
<td class="small" align="right">#[links]#</td> <td class="small" align="right">#[links]#</td>
<td class="small" align="right">#[words]#</td> <td class="small" align="right">#[words]#</td>
@ -89,6 +92,7 @@
<td class=small>#[age]#</td> <td class=small>#[age]#</td>
<td class="small" align="right">#[seeds]#</td> <td class="small" align="right">#[seeds]#</td>
<td class="small" align="right">#[connects]#</td> <td class="small" align="right">#[connects]#</td>
<td class="small" align="right">#[userAgent]#</td>
#(/complete)# #(/complete)#
</tr> </tr>
#{/list}# #{/list}#

@ -266,8 +266,10 @@ public class Network {
case 3 : e = yacyCore.seedDB.seedsSortedPotential(post.get("order", "down").equals("up"), post.get("sort", yacySeed.LASTSEEN)); break; case 3 : e = yacyCore.seedDB.seedsSortedPotential(post.get("order", "down").equals("up"), post.get("sort", yacySeed.LASTSEEN)); break;
default: break; default: break;
} }
int p;
String startURL; String startURL;
String wikiPage; String wikiPage;
String userAgent, location;
final StringBuffer alert = new StringBuffer(); final StringBuffer alert = new StringBuffer();
int PPM; int PPM;
while (e.hasMoreElements() && conCount < maxCount) { while (e.hasMoreElements() && conCount < maxCount) {
@ -305,6 +307,10 @@ public class Network {
} }
prop.put(STR_TABLE_LIST + conCount + "_shortname", shortname); prop.put(STR_TABLE_LIST + conCount + "_shortname", shortname);
prop.put(STR_TABLE_LIST + conCount + "_fullname", seed.get(yacySeed.NAME, "deadlink")); prop.put(STR_TABLE_LIST + conCount + "_fullname", seed.get(yacySeed.NAME, "deadlink"));
userAgent = yacyCore.peerActions.getUserAgent(seed.getIP());
p = userAgent.lastIndexOf(';');
location = (p > 0) ? userAgent.substring(p + 1, userAgent.length() - 1).trim(): "";
prop.put(STR_TABLE_LIST + conCount + "_location", location);
if (complete) { if (complete) {
prop.put(STR_TABLE_LIST + conCount + "_complete", 1); prop.put(STR_TABLE_LIST + conCount + "_complete", 1);
prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.get(yacySeed.IP, "-") ); prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.get(yacySeed.IP, "-") );
@ -315,6 +321,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_complete_CRTCnt", seed.get(yacySeed.CRTCNT, "0")); prop.put(STR_TABLE_LIST + conCount + "_complete_CRTCnt", seed.get(yacySeed.CRTCNT, "0"));
prop.put(STR_TABLE_LIST + conCount + "_complete_seeds", seed.get(yacySeed.SCOUNT, "-")); prop.put(STR_TABLE_LIST + conCount + "_complete_seeds", seed.get(yacySeed.SCOUNT, "-"));
prop.put(STR_TABLE_LIST + conCount + "_complete_connects", groupDigits(seed.get(yacySeed.CCOUNT, "0"))); prop.put(STR_TABLE_LIST + conCount + "_complete_connects", groupDigits(seed.get(yacySeed.CCOUNT, "0")));
prop.put(STR_TABLE_LIST + conCount + "_complete_userAgent", userAgent);
} else { } else {
prop.put(STR_TABLE_LIST + conCount + "_complete", 0); prop.put(STR_TABLE_LIST + conCount + "_complete", 0);
} }

@ -86,6 +86,7 @@ public final class hello {
// we easily know the caller's IP: // we easily know the caller's IP:
final String clientip = (String) header.get("CLIENTIP", "<unknown>"); // read an artificial header addendum final String clientip = (String) header.get("CLIENTIP", "<unknown>"); // read an artificial header addendum
final String userAgent = (String) header.get(httpHeader.USER_AGENT, "<unknown>");
final String reportedip = remoteSeed.get(yacySeed.IP, ""); final String reportedip = remoteSeed.get(yacySeed.IP, "");
final String reportedPeerType = remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR); final String reportedPeerType = remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
final float clientversion = remoteSeed.getVersion(); final float clientversion = remoteSeed.getVersion();
@ -162,6 +163,7 @@ public final class hello {
yacyCore.peerActions.peerPing(remoteSeed); yacyCore.peerActions.peerPing(remoteSeed);
} }
} }
yacyCore.peerActions.setUserAgent(clientip, userAgent);
if (!((String)prop.get(yacySeed.YOURTYPE)).equals(reportedPeerType)) { if (!((String)prop.get(yacySeed.YOURTYPE)).equals(reportedPeerType)) {
yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() + yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() +
"' [" + reportedip + "' [" + reportedip +

@ -152,21 +152,23 @@ public final class httpc {
private boolean allowContentEncoding = true; private boolean allowContentEncoding = true;
static boolean useYacyReferer = true; static boolean useYacyReferer = true;
public static boolean yacyDebugMode = false; public static boolean yacyDebugMode = false;
static {
// set time-out of InetAddress.getByName cache ttl
java.security.Security.setProperty("networkaddress.cache.ttl" , "60");
java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "0");
}
/** /**
* Indicates if the current object was removed from pool because the maximum limit * Indicates if the current object was removed from pool because the maximum limit
* was exceeded. * was exceeded.
*/ */
boolean removedFromPool = false; boolean removedFromPool = false;
// Configuring the httpc object pool static SSLSocketFactory theSSLSockFactory = null;
static { static {
// set time-out of InetAddress.getByName cache ttl
java.security.Security.setProperty("networkaddress.cache.ttl" , "60");
java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "0");
// Configuring the httpc object pool
// implementation of session thread pool // implementation of session thread pool
GenericObjectPool.Config config = new GenericObjectPool.Config(); GenericObjectPool.Config config = new GenericObjectPool.Config();
@ -183,11 +185,10 @@ public final class httpc {
config.minEvictableIdleTimeMillis = 30000; config.minEvictableIdleTimeMillis = 30000;
theHttpcPool = new httpcPool(new httpcFactory(),config); theHttpcPool = new httpcPool(new httpcFactory(),config);
}
// initializing a dummy trustManager to enable https connections // initializing a dummy trustManager to enable https connections
static SSLSocketFactory theSSLSockFactory = null;
static {
// Create a trust manager that does not validate certificate chains // Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() { public java.security.cert.X509Certificate[] getAcceptedIssuers() {
@ -220,8 +221,21 @@ public final class httpc {
HttpsURLConnection.setDefaultHostnameVerifier(hv); HttpsURLConnection.setDefaultHostnameVerifier(hv);
} catch (Exception e) { } catch (Exception e) {
} }
// provide system information for client identification
String loc = System.getProperty("user.timezone", "nowhere");
int p = loc.indexOf("/");
if (p > 0) loc = loc.substring(0,p);
loc = loc + "/" + System.getProperty("user.language", "dumb");
systemOST =
System.getProperty("os.arch", "no-os-arch") + " " +
System.getProperty("os.name", "no-os-name") + " " +
System.getProperty("os.version", "no-os-version") + "; " +
"java " + System.getProperty("java.version", "no-java-version") + "; " + loc;
userAgent = "yacy (www.yacy.net; v" + vDATE + "; " + systemOST + ")";
} }
/** /**
* A reusable readline buffer * A reusable readline buffer
* @see serverByteBuffer * @see serverByteBuffer
@ -471,21 +485,7 @@ public final class httpc {
return new GregorianCalendar(GMTTimeZone).getTime(); return new GregorianCalendar(GMTTimeZone).getTime();
} }
// FIXME: Why weren't all static parts put together? They are run one after
// each other on class loading? Hopefully. So why not put them into one
// static block?
static {
// provide system information for client identification
String loc = System.getProperty("user.timezone", "nowhere");
int p = loc.indexOf("/");
if (p > 0) loc = loc.substring(0,p);
loc = loc + "/" + System.getProperty("user.language", "dumb");
systemOST =
System.getProperty("os.arch", "no-os-arch") + " " + System.getProperty("os.name", "no-os-arch") + " " +
System.getProperty("os.version", "no-os-version") + "; " +
"java " + System.getProperty("java.version", "no-java-version") + "; " + loc;
userAgent = "yacy (www.yacy.net; v" + vDATE + "; " + systemOST + ")";
}
/** /**
* Initialize the httpc-instance with the given data. This method is used, * Initialize the httpc-instance with the given data. This method is used,

@ -51,6 +51,7 @@ import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
@ -67,6 +68,7 @@ public class yacyPeerActions {
private yacySeedDB seedDB; private yacySeedDB seedDB;
private plasmaSwitchboard sb; private plasmaSwitchboard sb;
private HashSet actions; private HashSet actions;
private HashMap userAgents;
private File superseedFile; private File superseedFile;
private String superseedURL; private String superseedURL;
public long juniorConnects; public long juniorConnects;
@ -78,8 +80,9 @@ public class yacyPeerActions {
this.seedDB = seedDB; this.seedDB = seedDB;
this.sb = switchboard; this.sb = switchboard;
this.actions = new HashSet(); this.actions = new HashSet();
this.userAgents = new HashMap();
this.superseedFile = superseedFile; this.superseedFile = superseedFile;
this.superseedURL = superseedURL; this.superseedURL = superseedURL;
this.superseedURL = superseedURL; this.superseedURL = superseedURL;
this.juniorConnects = 0; this.juniorConnects = 0;
this.seniorConnects = 0; this.seniorConnects = 0;
@ -407,4 +410,13 @@ public class yacyPeerActions {
Iterator i = actions.iterator(); Iterator i = actions.iterator();
while (i.hasNext()) ((yacyPeerAction) i.next()).processPeerPing(peer); while (i.hasNext()) ((yacyPeerAction) i.next()).processPeerPing(peer);
} }
public void setUserAgent(String IP, String userAgent) {
userAgents.put(IP, userAgent);
}
public String getUserAgent(String IP) {
String userAgent = (String) userAgents.get(IP);
return (userAgent == null) ? "" : userAgent;
}
} }

@ -264,14 +264,25 @@ public class yacySeed {
put(URL_IN, Integer.toString(Integer.parseInt(v) + count)); put(URL_IN, Integer.toString(Integer.parseInt(v) + count));
} }
// 12 * 6 bit = 72 bit = 9 byte // 12 * 6 bit = 72 bit = 18 characters hex-hash
public static String b64Hash2hexHash(String b64Hash) {
// the hash string represents 12 * 6 bit = 72 bits. This is too much for a long integer.
return serverCodings.encodeHex(serverCodings.enhancedCoder.decodeBase64(b64Hash));
}
public static String hexHash2b64Hash(String hexHash) { public static String hexHash2b64Hash(String hexHash) {
return serverCodings.enhancedCoder.encodeBase64(serverCodings.decodeHex(hexHash)); return serverCodings.enhancedCoder.encodeBase64(serverCodings.decodeHex(hexHash));
} }
public static String b64Hash2hexHash(String b64Hash) { // 12 * 6 bit = 72 bit = 9 byte
// the hash string represents 12 * 6 bit = 72 bits. This is too much for a long integer. public static byte[] b64Hash2b256Hash(String b64Hash) {
return serverCodings.encodeHex(serverCodings.enhancedCoder.decodeBase64(b64Hash)); assert (b64Hash.length() == 12);
return serverCodings.enhancedCoder.decodeBase64(b64Hash);
}
public static String b256Hash2b64Hash(byte[] b256Hash) {
assert (b256Hash.length == 9);
return serverCodings.enhancedCoder.encodeBase64(b256Hash);
} }
public float getVersion() { public float getVersion() {

@ -95,7 +95,6 @@ public final class yacySeedDB {
private final Hashtable nameLookupCache; private final Hashtable nameLookupCache;
private final Hashtable ipLookupCache; private final Hashtable ipLookupCache;
public yacySeedDB(plasmaSwitchboard sb, public yacySeedDB(plasmaSwitchboard sb,
File seedActiveDBFile, File seedActiveDBFile,
File seedPassiveDBFile, File seedPassiveDBFile,

Loading…
Cancel
Save