|
|
|
@ -50,13 +50,24 @@ public final class seedlist {
|
|
|
|
|
boolean nodeonly = post == null || !post.containsKey("node") ? false : post.getBoolean("node");
|
|
|
|
|
boolean includeme = post == null || !post.containsKey("me") ? true : post.getBoolean("me");
|
|
|
|
|
boolean addressonly = post == null || !post.containsKey("address") ? false : post.getBoolean("address");
|
|
|
|
|
String peername = post == null ? null : post.get("peername");
|
|
|
|
|
final ArrayList<Seed> v = sb.peers.getSeedlist(maxcount, includeme, nodeonly, minversion);
|
|
|
|
|
String peername = post == null ? null : post.containsKey("my") ? sb.peers.myName() : post.get("peername");
|
|
|
|
|
final ArrayList<Seed> v;
|
|
|
|
|
if (post != null && post.containsKey("my")) {
|
|
|
|
|
v = new ArrayList<Seed>(1);
|
|
|
|
|
v.add(sb.peers.mySeed());
|
|
|
|
|
} else if (post != null && post.containsKey("id")) {
|
|
|
|
|
v = new ArrayList<Seed>(1);
|
|
|
|
|
Seed s = sb.peers.get(post.get("id"));
|
|
|
|
|
if (s != null) v.add(s);
|
|
|
|
|
} else {
|
|
|
|
|
v= sb.peers.getSeedlist(maxcount, includeme, nodeonly, minversion);
|
|
|
|
|
}
|
|
|
|
|
final serverObjects prop = new serverObjects();
|
|
|
|
|
|
|
|
|
|
// write simple-encoded seed lines or json
|
|
|
|
|
String EXT = header.get("EXT");
|
|
|
|
|
boolean json = EXT != null && EXT.equals("json");
|
|
|
|
|
boolean xml = EXT != null && EXT.equals("xml");
|
|
|
|
|
|
|
|
|
|
if (json) {
|
|
|
|
|
// check for JSONP
|
|
|
|
@ -93,6 +104,32 @@ public final class seedlist {
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prop.put("peers_" + (count - 1) + "_c", 0);
|
|
|
|
|
prop.put("peers", count);
|
|
|
|
|
} else if (xml) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (int i = 0; i < v.size(); i++) {
|
|
|
|
|
Seed seed = v.get(i);
|
|
|
|
|
if (peername != null && !peername.equals(seed.getName())) continue;
|
|
|
|
|
prop.putXML("peers_" + count + "_map_0_k", Seed.HASH);
|
|
|
|
|
prop.putXML("peers_" + count + "_map_0_v", seed.hash);
|
|
|
|
|
prop.put("peers_" + count + "_map_0_c", 1);
|
|
|
|
|
Map<String, String> map = seed.getMap();
|
|
|
|
|
int c = 1;
|
|
|
|
|
if (!addressonly) {
|
|
|
|
|
for (Map.Entry<String, String> m: map.entrySet()) {
|
|
|
|
|
prop.putXML("peers_" + count + "_map_" + c + "_k", m.getKey());
|
|
|
|
|
prop.putXML("peers_" + count + "_map_" + c + "_v", m.getValue());
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
prop.putXML("peers_" + count + "_map_" + c + "_k", "Address");
|
|
|
|
|
prop.putXML("peers_" + count + "_map_" + c + "_v", seed.getPublicAddress());
|
|
|
|
|
prop.put("peers_" + count + "_map_" + c + "_c", 0);
|
|
|
|
|
prop.put("peers_" + count + "_map", c + 1);
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prop.put("peers_" + (count - 1) + "_c", 0);
|
|
|
|
|
prop.put("peers", count);
|
|
|
|
|
} else {
|
|
|
|
|