orbiter 17 years ago
parent e81bced2bd
commit 4ffbcd54a4

@ -65,7 +65,7 @@ public class natLib {
rm status.htm
*/
try {
ArrayList x = nxTools.strings(httpc.wget(new yacyURL("http://192.168.0.1:80/status.htm", null), "192.168.0.1", 5000, "admin", password, null, null, null));
ArrayList<String> x = nxTools.strings(httpc.wget(new yacyURL("http://192.168.0.1:80/status.htm", null), "192.168.0.1", 5000, "admin", password, null, null, null));
x = nxTools.grep(x, 1, "IP Address");
if ((x == null) || (x.size() == 0)) return null;
String line = nxTools.tail1(x);
@ -77,7 +77,7 @@ public class natLib {
private static String getWhatIsMyIP() {
try {
ArrayList x = nxTools.strings(httpc.wget(new yacyURL("http://www.whatismyip.com/", null), "www.whatsmyip.com", 5000, null, null, null, null, null));
ArrayList<String> x = nxTools.strings(httpc.wget(new yacyURL("http://www.whatismyip.com/", null), "www.whatsmyip.com", 5000, null, null, null, null, null));
x = nxTools.grep(x, 0, "Your IP is");
String line = nxTools.tail1(x);
return nxTools.awk(line, " ", 4);
@ -88,7 +88,7 @@ public class natLib {
private static String getStanford() {
try {
ArrayList x = nxTools.strings(httpc.wget(new yacyURL("http://www.slac.stanford.edu/cgi-bin/nph-traceroute.pl", null), "www.slac.stanford.edu", 5000, null, null, null, null, null));
ArrayList<String> x = nxTools.strings(httpc.wget(new yacyURL("http://www.slac.stanford.edu/cgi-bin/nph-traceroute.pl", null), "www.slac.stanford.edu", 5000, null, null, null, null, null));
x = nxTools.grep(x, 0, "firewall protecting your browser");
String line = nxTools.tail1(x);
return nxTools.awk(line, " ", 7);
@ -99,7 +99,7 @@ public class natLib {
private static String getIPID() {
try {
ArrayList x = nxTools.strings(httpc.wget(new yacyURL("http://ipid.shat.net/", null), "ipid.shat.net", 5000, null, null, null, null, null), "UTF-8");
ArrayList<String> x = nxTools.strings(httpc.wget(new yacyURL("http://ipid.shat.net/", null), "ipid.shat.net", 5000, null, null, null, null, null), "UTF-8");
x = nxTools.grep(x, 2, "Your IP address");
String line = nxTools.tail1(x);
return nxTools.awk(nxTools.awk(nxTools.awk(line, " ", 5), ">", 2), "<", 1);
@ -153,10 +153,14 @@ public class natLib {
String[] ips = ip.split("\\.");
if (ips.length != 4) return null;
byte[] ipb = new byte[4];
ipb[0] = (byte) Integer.parseInt(ips[0]);
ipb[1] = (byte) Integer.parseInt(ips[1]);
ipb[2] = (byte) Integer.parseInt(ips[2]);
ipb[3] = (byte) Integer.parseInt(ips[3]);
try {
ipb[0] = (byte) Integer.parseInt(ips[0]);
ipb[1] = (byte) Integer.parseInt(ips[1]);
ipb[2] = (byte) Integer.parseInt(ips[2]);
ipb[3] = (byte) Integer.parseInt(ips[3]);
} catch (NumberFormatException e) {
return null;
}
try {
return InetAddress.getByAddress(ipb);
} catch (UnknownHostException e) {

@ -61,8 +61,8 @@ public class yacyPeerActions {
private yacySeedDB seedDB;
private plasmaSwitchboard sb;
private HashSet actions;
private HashMap userAgents;
private HashSet<yacyPeerAction> actions;
private HashMap<String, String> userAgents;
public long juniorConnects;
public long seniorConnects;
public long principalConnects;
@ -72,8 +72,8 @@ public class yacyPeerActions {
public yacyPeerActions(yacySeedDB seedDB, plasmaSwitchboard switchboard) {
this.seedDB = seedDB;
this.sb = switchboard;
this.actions = new HashSet();
this.userAgents = new HashMap();
this.actions = new HashSet<yacyPeerAction>();
this.userAgents = new HashMap<String, String>();
this.juniorConnects = 0;
this.seniorConnects = 0;
this.principalConnects = 0;
@ -142,14 +142,14 @@ public class yacyPeerActions {
public void loadSeedLists() {
// uses the superseed to initialize the database with known seeds
yacySeed ys;
String seedListFileURL;
yacyURL url;
ArrayList seedList;
Iterator enu;
int lc;
int sc = seedDB.sizeConnected();
httpHeader header;
yacySeed ys;
String seedListFileURL;
yacyURL url;
ArrayList<String> seedList;
Iterator<String> enu;
int lc;
int sc = seedDB.sizeConnected();
httpHeader header;
yacyCore.log.logInfo("BOOTSTRAP: " + sc + " seeds known from previous run");
@ -366,8 +366,8 @@ public class yacyPeerActions {
boolean res = connectPeer(peer, direct);
// perform all actions if peer is effective new
if (res) {
Iterator i = actions.iterator();
while (i.hasNext()) ((yacyPeerAction) i.next()).processPeerArrival(peer, direct);
Iterator<yacyPeerAction> i = actions.iterator();
while (i.hasNext()) i.next().processPeerArrival(peer, direct);
}
return res;
}
@ -376,8 +376,8 @@ public class yacyPeerActions {
if (peer == null) return;
disconnectPeer(peer, cause);
// perform all actions
Iterator i = actions.iterator();
while (i.hasNext()) ((yacyPeerAction) i.next()).processPeerDeparture(peer);
Iterator<yacyPeerAction> i = actions.iterator();
while (i.hasNext()) i.next().processPeerDeparture(peer);
}
public void peerPing(yacySeed peer) {
@ -385,8 +385,8 @@ public class yacyPeerActions {
// this is called only if the peer has junior status
seedDB.addPotential(peer);
// perform all actions
Iterator i = actions.iterator();
while (i.hasNext()) ((yacyPeerAction) i.next()).processPeerPing(peer);
Iterator<yacyPeerAction> i = actions.iterator();
while (i.hasNext()) i.next().processPeerPing(peer);
}
public void setUserAgent(String IP, String userAgent) {

@ -496,7 +496,7 @@ public class yacySeed {
* @return the IP address of the peer represented by this yacySeed object as {@link InetAddress}
*/
public final InetAddress getInetAddress() {
return natLib.getInetAddress((String) this.dna.get(yacySeed.IP));
return natLib.getInetAddress(this.dna.get(yacySeed.IP));
}
/** @return the portnumber of this seed or <code>-1</code> if not present */
@ -854,6 +854,7 @@ public class yacySeed {
return genRemoteSeed(new String(b), null, false);
}
@SuppressWarnings("unchecked")
public final Object clone() {
synchronized (this.dna) {
return new yacySeed(this.hash, (HashMap<String, String>) (new HashMap<String, String>(this.dna)).clone());

Loading…
Cancel
Save