[dijjer-cvs] Dijjer/src/dijjer Dijjer.java,1.112,1.113 Main.java,1.83,1.84
Brought to you by:
gnovos
|
From: Chris C. <vo...@us...> - 2005-12-15 11:36:50
|
Update of /cvsroot/dijjer/Dijjer/src/dijjer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16091/src/dijjer Modified Files: Dijjer.java Main.java Log Message: Added an initial peers feature mainly for debugging. Index: Dijjer.java =================================================================== RCS file: /cvsroot/dijjer/Dijjer/src/dijjer/Dijjer.java,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** Dijjer.java 25 Aug 2005 23:40:24 -0000 1.112 --- Dijjer.java 15 Dec 2005 11:36:40 -0000 1.113 *************** *** 211,214 **** --- 211,218 ---- _seedNodes.add(peer); } + + public void addPeer(Peer peer) { + RoutingTable.getRoutingTable().addPeer(peer); + } public void setDataStoreSize(int dataStoreSize) { Index: Main.java =================================================================== RCS file: /cvsroot/dijjer/Dijjer/src/dijjer/Main.java,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** Main.java 23 Aug 2005 19:09:19 -0000 1.83 --- Main.java 15 Dec 2005 11:36:40 -0000 1.84 *************** *** 159,163 **** } }); ! addArgument("seedNode", "The address of an initial peer through which Dijjer can connect to the network", new ArgumentAction() { public void performAction(String arg) throws Exception { --- 159,163 ---- } }); ! addArgument("seedNode", "The addresses of an seednode through which Dijjer can connect to the network", new ArgumentAction() { public void performAction(String arg) throws Exception { *************** *** 200,203 **** --- 200,234 ---- } }); + addArgument("initPeer", "The addresses of some known peers, mainly for testing", + new ArgumentAction() { + public void performAction(String arg) throws Exception { + int cp = 0; + int sn = arg.indexOf(','); + while (sn != -1) { + // blank list items (sn == cp) get skipped (ie. host:port,,host:port) + if ( sn > cp ) { + String sarg = arg.substring(cp, sn); + int p = sarg.indexOf(':'); + if (p != -1) { + String addr = sarg.substring(0, p); + int port = Integer.parseInt(sarg.substring(p + 1, sarg.length())); + Dijjer.getDijjer().addPeer(new Peer(InetAddress.getByName(addr), port)); + } else { + Logger.warning(sarg + " initPeer is not in host:port format"); + } + } + cp = sn + 1; + sn = arg.indexOf(',', cp); + } + int p = arg.indexOf(':', cp); + if (p != -1) { + String addr = arg.substring(cp, p); + int port = Integer.parseInt(arg.substring(p + 1, arg.length())); + Dijjer.getDijjer().addPeer(new Peer(InetAddress.getByName(addr), port)); + } else { + Logger.warning(arg.substring(cp) + " initPeer is not in host:port format"); + } + } + }); addUnmatchedKeyArgument("help", "This help menu", new ArgumentAction() { public void performAction(String arg) throws Exception { |