|
|
@ -174,11 +174,22 @@ public class yacySeed {
|
|
|
|
available = 0;
|
|
|
|
available = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getIP() { return get(IP, ""); }
|
|
|
|
|
|
|
|
public String getJunior() { return get(PEERTYPE, PEERTYPE_JUNIOR); }
|
|
|
|
|
|
|
|
public String getSenior() { return get(PEERTYPE, PEERTYPE_SENIOR); }
|
|
|
|
|
|
|
|
public String getPrincipal() { return get(PEERTYPE, PEERTYPE_PRINCIPAL); }
|
|
|
|
|
|
|
|
|
|
|
|
public String get(String key, String dflt) {
|
|
|
|
public String get(String key, String dflt) {
|
|
|
|
final Object o = dna.get(key);
|
|
|
|
final Object o = dna.get(key);
|
|
|
|
if (o == null) { return dflt; } else { return (String) o; }
|
|
|
|
if (o == null) { return dflt; } else { return (String) o; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setIP(String ip) { put(IP, ip); }
|
|
|
|
|
|
|
|
public void setJunior() { put(PEERTYPE, PEERTYPE_JUNIOR); }
|
|
|
|
|
|
|
|
public void setSenior() { put(PEERTYPE, PEERTYPE_SENIOR); }
|
|
|
|
|
|
|
|
public void setPrincipal() { put(PEERTYPE, PEERTYPE_PRINCIPAL); }
|
|
|
|
|
|
|
|
public void setLastSeen(long rd) { put(LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() + serverDate.UTCDiff() - rd))); }
|
|
|
|
|
|
|
|
|
|
|
|
public void put(String key, String value) {
|
|
|
|
public void put(String key, String value) {
|
|
|
|
dna.put(key, value);
|
|
|
|
dna.put(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -342,6 +353,9 @@ public class yacySeed {
|
|
|
|
public boolean isOnline() {
|
|
|
|
public boolean isOnline() {
|
|
|
|
return (isSenior() || isPrincipal());
|
|
|
|
return (isSenior() || isPrincipal());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOnline(String type) {
|
|
|
|
|
|
|
|
return (type.equals(PEERTYPE_SENIOR) || type.equals(PEERTYPE_PRINCIPAL));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String encodeLex(long c, int length) {
|
|
|
|
public String encodeLex(long c, int length) {
|
|
|
|
if (length < 0) { length = 0; }
|
|
|
|
if (length < 0) { length = 0; }
|
|
|
@ -491,10 +505,14 @@ public class yacySeed {
|
|
|
|
return genSeedStr('b', key);
|
|
|
|
return genSeedStr('b', key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String genSeedStr(char method, String key) {
|
|
|
|
synchronized public String genSeedStr(char method, String key) {
|
|
|
|
return crypt.simpleEncode(toString(), key, method);
|
|
|
|
return crypt.simpleEncode(toString(), key, method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isPeerOK() {
|
|
|
|
|
|
|
|
return (this.hash != null && isProper() == null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String isProper() {
|
|
|
|
public String isProper() {
|
|
|
|
// checks if everything is ok with that seed
|
|
|
|
// checks if everything is ok with that seed
|
|
|
|
if (this.hash == null) { return "hash is null"; }
|
|
|
|
if (this.hash == null) { return "hash is null"; }
|
|
|
|