Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4358 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jan 22, 2008
1 parent e81bced commit 4ffbcd5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
20 changes: 12 additions & 8 deletions source/de/anomic/net/natLib.java
Expand Up @@ -65,7 +65,7 @@ public static String getDI604(String password) {
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);
Expand All @@ -77,7 +77,7 @@ public static String getDI604(String password) {

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);
Expand All @@ -88,7 +88,7 @@ private static String getWhatIsMyIP() {

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);
Expand All @@ -99,7 +99,7 @@ private static String getStanford() {

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);
Expand Down Expand Up @@ -153,10 +153,14 @@ public static final InetAddress getInetAddress(String ip) {
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) {
Expand Down
36 changes: 18 additions & 18 deletions source/de/anomic/yacy/yacyPeerActions.java
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -142,14 +142,14 @@ public void saveMySeed() {
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");

Expand Down Expand Up @@ -366,8 +366,8 @@ public boolean peerArrival(yacySeed peer, boolean direct) {
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;
}
Expand All @@ -376,17 +376,17 @@ public void peerDeparture(yacySeed peer, String cause) {
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) {
if (peer == null) return;
// 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) {
Expand Down
3 changes: 2 additions & 1 deletion source/de/anomic/yacy/yacySeed.java
Expand Up @@ -496,7 +496,7 @@ public final String getClusterAddress() {
* @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 */
Expand Down Expand Up @@ -854,6 +854,7 @@ public static yacySeed load(File f) throws IOException {
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());
Expand Down

0 comments on commit 4ffbcd5

Please sign in to comment.