diff --git a/htroot/yacy/seedlist.java b/htroot/yacy/seedlist.java index 7f3ba082f..c30de0c66 100644 --- a/htroot/yacy/seedlist.java +++ b/htroot/yacy/seedlist.java @@ -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 v = sb.peers.getSeedlist(maxcount, includeme, nodeonly, minversion); + String peername = post == null ? null : post.containsKey("my") ? sb.peers.myName() : post.get("peername"); + final ArrayList v; + if (post != null && post.containsKey("my")) { + v = new ArrayList(1); + v.add(sb.peers.mySeed()); + } else if (post != null && post.containsKey("id")) { + v = new ArrayList(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 map = seed.getMap(); + int c = 1; + if (!addressonly) { + for (Map.Entry 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 { diff --git a/htroot/yacy/seedlist.xml b/htroot/yacy/seedlist.xml new file mode 100644 index 000000000..dfc0c0825 --- /dev/null +++ b/htroot/yacy/seedlist.xml @@ -0,0 +1,10 @@ + + +#{peers}# + +#{map}# + <#[k]#>#[v]# +#{/map}# + +#{/peers}# + \ No newline at end of file