From juiceman at freenetproject.org Fri Jun 1 05:39:38 2007 From: juiceman at freenetproject.org (juiceman at freenetproject.org) Date: Fri, 1 Jun 2007 05:39:38 +0000 (UTC) Subject: [freenet-cvs] r13429 - trunk/freenet/src/freenet/l10n Message-ID: <20070601053938.02DC24791A8@emu.freenetproject.org> Author: juiceman Date: 2007-06-01 05:39:37 +0000 (Fri, 01 Jun 2007) New Revision: 13429 Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties Log: A little cleaner looking Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties =================================================================== --- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-05-31 23:03:37 UTC (rev 13428) +++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-06-01 05:39:37 UTC (rev 13429) @@ -757,7 +757,7 @@ StatisticsToadlet.bandwidthTitle=Bandwidth StatisticsToadlet.cpus=Available CPUs: ${count} StatisticsToadlet.getLogs=Get latest node's logfile -StatisticsToadlet.inputRate=Input Rate: ${rate}/second (of ${max}/second) +StatisticsToadlet.inputRate=Input Rate: ${rate}/second (of ${max}) StatisticsToadlet.jeDumpButton=Generate a JE Dump StatisticsToadlet.jvmInfoTitle=JVM Info StatisticsToadlet.jvmVendor=JVM Vendor: ${vendor} @@ -767,8 +767,8 @@ StatisticsToadlet.osArch=OS Architecture: ${arch} StatisticsToadlet.osName=OS Name: ${name} StatisticsToadlet.osVersion=OS Version: ${version} -StatisticsToadlet.outputRate=Output Rate: ${rate}/second (of ${max}/second) -StatisticsToadlet.payloadOutput=Payload Output: ${total} (${rate}/second) (${percent}%) +StatisticsToadlet.outputRate=Output Rate: ${rate}/second (of ${max}) +StatisticsToadlet.payloadOutput=Payload Output: ${total} (${rate}/second)(${percent}%) StatisticsToadlet.peerStatsTitle=Peer statistics StatisticsToadlet.threadDumpButton=Generate a Thread Dump StatisticsToadlet.threads=Running threads: ${running}/${max} From toad at freenetproject.org Fri Jun 1 09:16:35 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 09:16:35 +0000 (UTC) Subject: [freenet-cvs] r13430 - trunk/freenet/src/freenet/io/comm Message-ID: <20070601091635.04A2C479707@emu.freenetproject.org> Author: toad Date: 2007-06-01 09:16:34 +0000 (Fri, 01 Jun 2007) New Revision: 13430 Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java Log: Fix NPE Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java =================================================================== --- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-06-01 05:39:37 UTC (rev 13429) +++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-06-01 09:16:34 UTC (rev 13430) @@ -370,16 +370,15 @@ matched = true; i.remove(); match = f; - synchronized (f) { - f.notifyAll(); - } if(logMINOR) Logger.minor(this, "Matched: "+f); break; // Only one match permitted per message } } } - match.setMessage(m); - match.onMatched(); + if(match != null) { + match.setMessage(m); + match.onMatched(); + } // Feed unmatched messages to the dispatcher if ((!matched) && (_dispatcher != null)) { try { From toad at freenetproject.org Fri Jun 1 09:32:10 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 09:32:10 +0000 (UTC) Subject: [freenet-cvs] r13431 - trunk/freenet/src/freenet/io/comm Message-ID: <20070601093210.E64A24798D4@emu.freenetproject.org> Author: toad Date: 2007-06-01 09:32:10 +0000 (Fri, 01 Jun 2007) New Revision: 13431 Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java trunk/freenet/src/freenet/io/comm/UdpSocketManager.java Log: Improve filter/USM changes. Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java =================================================================== --- trunk/freenet/src/freenet/io/comm/MessageFilter.java 2007-06-01 09:16:34 UTC (rev 13430) +++ trunk/freenet/src/freenet/io/comm/MessageFilter.java 2007-06-01 09:32:10 UTC (rev 13431) @@ -204,14 +204,17 @@ _or = null; } - public boolean matchesDroppedConnection() { - return _matchesDroppedConnections; + public boolean matchesDroppedConnection(PeerContext ctx) { + return _matchesDroppedConnections && _source == ctx; } - public void onDroppedConnection(PeerContext ctx) { - if(_matchesDroppedConnections && (_source == ctx)) { - _droppedConnection = ctx; - } + /** + * Notify because of a dropped connection. + * Caller must verify _matchesDroppedConnection and _source. + * @param ctx + */ + public synchronized void onDroppedConnection(PeerContext ctx) { + notifyAll(); } /** Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java =================================================================== --- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-06-01 09:16:34 UTC (rev 13430) +++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-06-01 09:32:10 UTC (rev 13431) @@ -325,9 +325,6 @@ MessageFilter f = (MessageFilter) _timedOutFilters.get(i); f.setMessage(null); f.onTimedOut(); - synchronized (f) { - f.notifyAll(); - } } _timedOutFilters.clear(); @@ -454,20 +451,25 @@ /** IncomingPacketFilter should call this when a node is disconnected. */ public void onDisconnect(PeerContext ctx) { + Vector droppedFilters = null; // rare operation, we can waste objects for better locking synchronized(_filters) { ListIterator i = _filters.listIterator(); while (i.hasNext()) { MessageFilter f = (MessageFilter) i.next(); - if(f.matchesDroppedConnection() && (f._source == ctx)) { - f.onDroppedConnection(ctx); - if(f.droppedConnection() != null) { - synchronized(f) { - f.notifyAll(); - } - } + if(f.matchesDroppedConnection(ctx)) { + if(droppedFilters == null) + droppedFilters = new Vector(); + droppedFilters.add(f); + i.remove(); } } } + if(droppedFilters != null) { + for(int i=0;i Author: nextgens Date: 2007-06-01 11:13:53 +0000 (Fri, 01 Jun 2007) New Revision: 13433 Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java Log: l10n fix Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-06-01 10:30:40 UTC (rev 13432) +++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java 2007-06-01 11:13:53 UTC (rev 13433) @@ -568,7 +568,7 @@ if (numberOfListenOnly > 0) { HTMLNode peerStatsListenOnlyListItem = peerStatsList.addChild("li").addChild("span"); peerStatsListenOnlyListItem.addChild("span", new String[] { "class", "title", "style" }, - new String[] { "peer_listen_only", l10n("listenOnly"), "border-bottom: 1px dotted; cursor: help;" }, l10nDark("listenOnlyShort")); + new String[] { "peer_listen_only", l10nDark("listenOnly"), "border-bottom: 1px dotted; cursor: help;" }, l10nDark("listenOnlyShort")); peerStatsListenOnlyListItem.addChild("span", ":\u00a0" + numberOfListenOnly); } From toad at freenetproject.org Fri Jun 1 11:15:20 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 11:15:20 +0000 (UTC) Subject: [freenet-cvs] r13434 - in trunk/freenet/src/freenet: io/comm node Message-ID: <20070601111520.09D24479707@emu.freenetproject.org> Author: toad Date: 2007-06-01 11:15:19 +0000 (Fri, 01 Jun 2007) New Revision: 13434 Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java trunk/freenet/src/freenet/io/comm/UdpSocketManager.java trunk/freenet/src/freenet/node/PeerNode.java Log: Match by default on node restarts as well as node disconnection Modified: trunk/freenet/src/freenet/io/comm/MessageFilter.java =================================================================== --- trunk/freenet/src/freenet/io/comm/MessageFilter.java 2007-06-01 11:13:53 UTC (rev 13433) +++ trunk/freenet/src/freenet/io/comm/MessageFilter.java 2007-06-01 11:15:19 UTC (rev 13434) @@ -45,11 +45,13 @@ private MessageFilter _or; private Message _message; private boolean _matchesDroppedConnections; + private boolean _matchesRestartedConnections; private AsyncMessageFilterCallback _callback; private MessageFilter() { setTimeout(DEFAULT_TIMEOUT); _matchesDroppedConnections = true; // on by default + _matchesRestartedConnections = true; // also on by default } public static MessageFilter create() { @@ -129,6 +131,11 @@ return this; } + public MessageFilter setMatchesRestartedConnections(boolean m) { + _matchesRestartedConnections = m; + return this; + } + public MessageFilter setAsyncCallback(AsyncMessageFilterCallback cb) { _callback = cb; return this; @@ -208,6 +215,10 @@ return _matchesDroppedConnections && _source == ctx; } + public boolean matchesRestartedConnection(PeerContext ctx) { + return _matchesRestartedConnections && _source == ctx; + } + /** * Notify because of a dropped connection. * Caller must verify _matchesDroppedConnection and _source. @@ -218,6 +229,15 @@ } /** + * Notify because of a restarted connection. + * Caller must verify _matchesDroppedConnection and _source. + * @param ctx + */ + public synchronized void onRestartedConnection(PeerContext ctx) { + notifyAll(); + } + + /** * Notify waiters that we have been matched. * Hopefully no locks will be held at this point by the caller. */ Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java =================================================================== --- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-06-01 11:13:53 UTC (rev 13433) +++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2007-06-01 11:15:19 UTC (rev 13434) @@ -472,6 +472,28 @@ } } + /** IncomingPacketFilter should call this when a node connects with a new boot ID */ + public void onRestart(PeerContext ctx) { + Vector droppedFilters = null; // rare operation, we can waste objects for better locking + synchronized(_filters) { + ListIterator i = _filters.listIterator(); + while (i.hasNext()) { + MessageFilter f = (MessageFilter) i.next(); + if(f.matchesRestartedConnection(ctx)) { + if(droppedFilters == null) + droppedFilters = new Vector(); + droppedFilters.add(f); + i.remove(); + } + } + } + if(droppedFilters != null) { + for(int i=0;i Author: toad Date: 2007-06-01 11:34:51 +0000 (Fri, 01 Jun 2007) New Revision: 13435 Modified: trunk/freenet/src/freenet/io/xfer/BulkReceiver.java trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java Log: Completed receiving code. Modified: trunk/freenet/src/freenet/io/xfer/BulkReceiver.java =================================================================== --- trunk/freenet/src/freenet/io/xfer/BulkReceiver.java 2007-06-01 11:15:19 UTC (rev 13434) +++ trunk/freenet/src/freenet/io/xfer/BulkReceiver.java 2007-06-01 11:34:51 UTC (rev 13435) @@ -4,8 +4,13 @@ package freenet.io.xfer; import freenet.io.comm.DMT; +import freenet.io.comm.DisconnectedException; +import freenet.io.comm.Message; +import freenet.io.comm.MessageFilter; import freenet.io.comm.NotConnectedException; import freenet.io.comm.PeerContext; +import freenet.io.comm.RetrievalException; +import freenet.support.ShortBuffer; /** * Bulk (not block) data transfer - receiver class. Bulk transfer is designed for largish files, much @@ -13,7 +18,8 @@ * @author toad */ public class BulkReceiver { - + + static final int TIMEOUT = 5*60*1000; /** Tracks the data we have received */ final PartiallyReceivedBulk prb; /** Peer we are receiving from */ @@ -21,11 +27,14 @@ /** Transfer UID for messages */ final long uid; private boolean sentCancel; + /** Not persistent over reboots */ + final long peerBootID; public BulkReceiver(PartiallyReceivedBulk prb, PeerContext peer, long uid) { this.prb = prb; this.peer = peer; this.uid = uid; + this.peerBootID = peer.getBootID(); } public void onAborted() { @@ -40,4 +49,39 @@ } } + /** + * Receive the file. + * @return True if the whole file was received, false otherwise. + */ + public boolean receive() { + MessageFilter mfSendKilled = MessageFilter.create().setSource(peer).setType(DMT.FNPBulkSendAborted) .setField(DMT.UID, uid).setTimeout(TIMEOUT); + MessageFilter mfPacket = MessageFilter.create().setSource(peer).setType(DMT.FNPBulkPacketSend) .setField(DMT.UID, uid).setTimeout(TIMEOUT); + while(true) { + if(prb.hasWholeFile()) return true; + Message m; + try { + m = prb.usm.waitFor(mfSendKilled.or(mfPacket), null); + } catch (DisconnectedException e) { + prb.abort(RetrievalException.SENDER_DISCONNECTED, "Sender disconnected"); + return false; + } + if(peer.getBootID() != peerBootID) { + prb.abort(RetrievalException.SENDER_DIED, "Sender restarted"); + return false; + } + if(m == null) { + prb.abort(RetrievalException.TIMED_OUT, "Sender timeout"); + return false; + } + if(m.getSpec() == DMT.FNPBulkSendAborted) { + prb.abort(RetrievalException.SENDER_DIED, "Sender cancelled send"); + return false; + } + if(m.getSpec() == DMT.FNPBulkPacketSend) { + int packetNo = m.getInt(DMT.PACKET_NO); + byte[] data = ((ShortBuffer) m.getObject(DMT.DATA)).getData(); + prb.received(packetNo, data, 0, data.length); + } + } + } } Modified: trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java =================================================================== --- trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java 2007-06-01 11:15:19 UTC (rev 13434) +++ trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java 2007-06-01 11:34:51 UTC (rev 13435) @@ -96,10 +96,18 @@ * Called when a block has been received. Will copy the data from the provided buffer and store it. * @param blockNum The block number. * @param data The byte array from which to read the data. - * @param offset The start of the + * @param offset The start of the data in the buffer. */ - void received(int blockNum, byte[] data, int offset) { + void received(int blockNum, byte[] data, int offset, int length) { BulkTransmitter[] notifyBTs; + long fileOffset = (long)blockNum * (long)blockSize; + int bs = (int) Math.max(blockSize, size - fileOffset); + if(length < bs) { + String err = "Data too short! Should be "+bs+" actually "+length; + Logger.error(this, err+" for "+this); + abort(RetrievalException.PREMATURE_EOF, err); + return; + } synchronized(this) { if(blocksReceived.bitAt(blockNum)) return; // ignore blocksReceived.setBit(blockNum, true); // assume the rest of the function succeeds @@ -107,8 +115,6 @@ notifyBTs = transmitters; } try { - long fileOffset = (long)blockNum * (long)blockSize; - int bs = (int) Math.max(blockSize, size - fileOffset); raf.pwrite(fileOffset, data, offset, bs); } catch (Throwable t) { Logger.error(this, "Failed to store received block "+blockNum+" on "+this+" : "+t, t); From toad at freenetproject.org Fri Jun 1 11:52:21 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 11:52:21 +0000 (UTC) Subject: [freenet-cvs] r13436 - in trunk/freenet/src/freenet/io: comm xfer Message-ID: <20070601115221.ABA9F479731@emu.freenetproject.org> Author: toad Date: 2007-06-01 11:52:21 +0000 (Fri, 01 Jun 2007) New Revision: 13436 Modified: trunk/freenet/src/freenet/io/comm/DMT.java trunk/freenet/src/freenet/io/xfer/BulkReceiver.java trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java Log: FNPBulkReceivedAll, timeouts, bugfixes Modified: trunk/freenet/src/freenet/io/comm/DMT.java =================================================================== --- trunk/freenet/src/freenet/io/comm/DMT.java 2007-06-01 11:34:51 UTC (rev 13435) +++ trunk/freenet/src/freenet/io/comm/DMT.java 2007-06-01 11:52:21 UTC (rev 13436) @@ -272,6 +272,16 @@ return msg; } + public static final MessageType FNPBulkReceivedAll = new MessageType("FNPBulkReceivedAll") {{ + addField(UID, Long.class); + }}; + + public static final Message createFNPBulkReceivedAll(long uid) { + Message msg = new Message(FNPBulkReceivedAll); + msg.set(UID, uid); + return msg; + } + public static final MessageType testTransferSend = new MessageType("testTransferSend") {{ addField(UID, Long.class); }}; Modified: trunk/freenet/src/freenet/io/xfer/BulkReceiver.java =================================================================== --- trunk/freenet/src/freenet/io/xfer/BulkReceiver.java 2007-06-01 11:34:51 UTC (rev 13435) +++ trunk/freenet/src/freenet/io/xfer/BulkReceiver.java 2007-06-01 11:52:21 UTC (rev 13436) @@ -57,7 +57,14 @@ MessageFilter mfSendKilled = MessageFilter.create().setSource(peer).setType(DMT.FNPBulkSendAborted) .setField(DMT.UID, uid).setTimeout(TIMEOUT); MessageFilter mfPacket = MessageFilter.create().setSource(peer).setType(DMT.FNPBulkPacketSend) .setField(DMT.UID, uid).setTimeout(TIMEOUT); while(true) { - if(prb.hasWholeFile()) return true; + if(prb.hasWholeFile()) { + try { + peer.sendAsync(DMT.createFNPBulkReceivedAll(uid), null, 0, null); + } catch (NotConnectedException e) { + // Ignore, we have the data. + } + return true; + } Message m; try { m = prb.usm.waitFor(mfSendKilled.or(mfPacket), null); Modified: trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java =================================================================== --- trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java 2007-06-01 11:34:51 UTC (rev 13435) +++ trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java 2007-06-01 11:52:21 UTC (rev 13436) @@ -12,6 +12,7 @@ import freenet.io.comm.PeerContext; import freenet.support.BitArray; import freenet.support.DoubleTokenBucket; +import freenet.support.Logger; /** * Bulk data transfer (not block). Bulk transfer is designed for files which may be much bigger than a @@ -22,6 +23,8 @@ */ public class BulkTransmitter { + /** If no packets sent in this period, and no completion acknowledgement / cancellation, assume failure. */ + static final int TIMEOUT = 5*60*1000; /** Available blocks */ final PartiallyReceivedBulk prb; /** Peer who we are sending the data to */ @@ -67,6 +70,19 @@ return false; } }); + prb.usm.addAsyncFilter(MessageFilter.create().setNoTimeout().setSource(peer).setType(DMT.FNPBulkReceivedAll).setField(DMT.UID, uid), + new AsyncMessageFilterCallback() { + public void onMatched(Message m) { + completed(); + } + public boolean shouldTimeout() { + synchronized(BulkTransmitter.this) { + if(cancelled || finished) return true; + } + if(BulkTransmitter.this.prb.isAborted()) return true; + return false; + } + }); } catch (DisconnectedException e) { cancel(); throw e; @@ -113,12 +129,24 @@ } prb.remove(this); } + + /** Like cancel(), but without the negative overtones: The client says it's got everything, + * we believe them (even if we haven't sent everything; maybe they had a partial). */ + public void completed() { + synchronized(this) { + finished = true; + notifyAll(); + } + prb.remove(this); + } /** * Send the file. * @return True if the file was successfully sent. False otherwise. */ public boolean send() { + int packetSize = prb.getPacketSize(); + long lastSentPacket = System.currentTimeMillis(); while(true) { if(prb.isAborted()) return false; int blockNo; @@ -130,23 +158,27 @@ prb.remove(BulkTransmitter.this); return false; } - boolean hasAll = prb.hasWholeFile(); synchronized(this) { + if(finished) return true; if(cancelled) return false; blockNo = blocksNotSentButPresent.firstOne(); } - if(blockNo < 0 && hasAll) { - prb.remove(BulkTransmitter.this); - return true; // All done - } else if(blockNo < 0) { + if(blockNo < 0) { + // Wait for a packet, BulkReceivedAll or BulkReceiveAborted synchronized(this) { try { wait(60*1000); } catch (InterruptedException e) { // No problem + continue; } - continue; } + long end = System.currentTimeMillis(); + if(end - lastSentPacket > TIMEOUT) { + Logger.error(this, "Send timed out on "+this); + cancel(); + return false; + } } // Send a packet byte[] buf = prb.getBlockData(blockNo); @@ -159,12 +191,22 @@ long now = System.currentTimeMillis(); long waitUntil = peer.getThrottle().scheduleDelay(now); - masterThrottle.blockingGrab(prb.getPacketSize()); + masterThrottle.blockingGrab(packetSize); while((now = System.currentTimeMillis()) < waitUntil) { long sleepTime = waitUntil - now; try { - Thread.sleep(sleepTime); + synchronized(this) { + wait(sleepTime); + if(finished) { + masterThrottle.recycle(packetSize); + return true; + } + if(cancelled) { + masterThrottle.recycle(packetSize); + return false; + } + } } catch (InterruptedException e) { // Ignore } @@ -173,6 +215,10 @@ try { peer.sendAsync(DMT.createFNPBulkPacketSend(uid, blockNo, buf), null, 0, null); + synchronized(this) { + blocksNotSentButPresent.setBit(blockNo, false); + } + lastSentPacket = System.currentTimeMillis(); } catch (NotConnectedException e) { cancel(); return false; From toad at freenetproject.org Fri Jun 1 12:02:47 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 12:02:47 +0000 (UTC) Subject: [freenet-cvs] r13437 - trunk/freenet/src/freenet/node Message-ID: <20070601120247.398E647A037@emu.freenetproject.org> Author: toad Date: 2007-06-01 12:02:47 +0000 (Fri, 01 Jun 2007) New Revision: 13437 Modified: trunk/freenet/src/freenet/node/Node.java Log: Language code not country code! Modified: trunk/freenet/src/freenet/node/Node.java =================================================================== --- trunk/freenet/src/freenet/node/Node.java 2007-06-01 11:52:21 UTC (rev 13436) +++ trunk/freenet/src/freenet/node/Node.java 2007-06-01 12:02:47 UTC (rev 13437) @@ -1409,7 +1409,7 @@ disableHangCheckers = nodeConfig.getBoolean("disableHangCheckers"); // l10n stuffs - nodeConfig.register("l10n", Locale.getDefault().getCountry().toLowerCase(), sortOrder++, false, true, + nodeConfig.register("l10n", Locale.getDefault().getLanguage().toLowerCase(), sortOrder++, false, true, "Node.l10nLanguage", "Node.l10nLanguageLong", new L10nCallback()); From toad at freenetproject.org Fri Jun 1 12:06:01 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 12:06:01 +0000 (UTC) Subject: [freenet-cvs] r13438 - in trunk/freenet/src/freenet: l10n node Message-ID: <20070601120601.9970347A090@emu.freenetproject.org> Author: toad Date: 2007-06-01 12:06:01 +0000 (Fri, 01 Jun 2007) New Revision: 13438 Modified: trunk/freenet/src/freenet/l10n/L10n.java trunk/freenet/src/freenet/node/Node.java Log: Try the set value, then the default value, then english Modified: trunk/freenet/src/freenet/l10n/L10n.java =================================================================== --- trunk/freenet/src/freenet/l10n/L10n.java 2007-06-01 12:02:47 UTC (rev 13437) +++ trunk/freenet/src/freenet/l10n/L10n.java 2007-06-01 12:06:01 UTC (rev 13438) @@ -36,6 +36,7 @@ public static final String OVERRIDE_SUFFIX = ".override" + SUFFIX; // English has to remain the first one! + public static final String FALLBACK_DEFAULT = "en"; public static final String[] AVAILABLE_LANGUAGES = { "en", "fr", "pl", "it", "se", "no", "unlisted" }; private final String selectedLanguage; Modified: trunk/freenet/src/freenet/node/Node.java =================================================================== --- trunk/freenet/src/freenet/node/Node.java 2007-06-01 12:02:47 UTC (rev 13437) +++ trunk/freenet/src/freenet/node/Node.java 2007-06-01 12:06:01 UTC (rev 13438) @@ -1408,7 +1408,7 @@ disableHangCheckers = nodeConfig.getBoolean("disableHangCheckers"); - // l10n stuffs + // l10n stuffs nodeConfig.register("l10n", Locale.getDefault().getLanguage().toLowerCase(), sortOrder++, false, true, "Node.l10nLanguage", "Node.l10nLanguageLong", @@ -1417,7 +1417,11 @@ try { L10n.setLanguage(nodeConfig.getString("l10n")); } catch (MissingResourceException e) { - L10n.setLanguage(nodeConfig.getOption("l10n").getDefault()); + try { + L10n.setLanguage(nodeConfig.getOption("l10n").getDefault()); + } catch (MissingResourceException e1) { + L10n.setLanguage(L10n.FALLBACK_DEFAULT); + } } nodeConfig.finishedInitialization(); From toad at freenetproject.org Fri Jun 1 12:24:15 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 12:24:15 +0000 (UTC) Subject: [freenet-cvs] r13439 - trunk/freenet/src/freenet/node Message-ID: <20070601122415.BB7DB4798AF@emu.freenetproject.org> Author: toad Date: 2007-06-01 12:24:15 +0000 (Fri, 01 Jun 2007) New Revision: 13439 Modified: trunk/freenet/src/freenet/node/Version.java Log: 1036: - Use language code, not country code, by default. And fall back to english if we don't have the set value or the default. - Always pad pubkeys - Minor l10n string fixes: openRSSAsRSS had raw HTML, listenOnly/listenOnlyShort are on darknet not on statstoadlet - Refactoring in messaging layer, asynchronous MessageFilter callback support - Trigger filters on reconnection with a new boot ID as well as disconnection - Bulk transmission layer coded, will use it in the next release - Trivial: norwegian translation is UTF8 (no impact on running node) - Minor (english) strings improvements - Comments Installer: - Wire in the wizard: Direct new installs to it. Modified: trunk/freenet/src/freenet/node/Version.java =================================================================== --- trunk/freenet/src/freenet/node/Version.java 2007-06-01 12:06:01 UTC (rev 13438) +++ trunk/freenet/src/freenet/node/Version.java 2007-06-01 12:24:15 UTC (rev 13439) @@ -24,7 +24,7 @@ public static final String protocolVersion = "1.0"; /** The build number of the current revision */ - private static final int buildNumber = 1035; + private static final int buildNumber = 1036; /** Oldest build of Fred we will talk to */ private static final int oldLastGoodBuild = 1029; From toad at freenetproject.org Fri Jun 1 14:41:14 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 14:41:14 +0000 (UTC) Subject: [freenet-cvs] r13440 - trunk/freenet/src/freenet/clients/http Message-ID: <20070601144114.6545F4791C0@emu.freenetproject.org> Author: toad Date: 2007-06-01 14:41:13 +0000 (Fri, 01 Jun 2007) New Revision: 13440 Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java Log: Indenting Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 12:24:15 UTC (rev 13439) +++ trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 14:41:13 UTC (rev 13440) @@ -27,120 +27,147 @@ public class N2NTMToadlet extends Toadlet { - private Node node; - private NodeClientCore core; - private UdpSocketManager usm; - - protected N2NTMToadlet(Node n, NodeClientCore core, HighLevelSimpleClient client) { - super(client); - this.node = n; - this.core = core; - this.usm = n.getUSM(); - } + private Node node; - public String supportedMethods() { - return "GET, POST"; - } + private NodeClientCore core; - public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx) throws ToadletContextClosedException, IOException, RedirectException { - - if(!ctx.isAllowedFullAccess()) { - super.sendErrorPage(ctx, 403, "Unauthorized", L10n.getString("Toadlet.unauthorized")); - return; - } - - if (request.isParameterSet("peernode_hashcode")) { - HTMLNode pageNode = ctx.getPageMaker().getPageNode(l10n("sendMessage"), ctx); - HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode); - - String peernode_name = null; - String input_hashcode_string = request.getParam("peernode_hashcode"); - int input_hashcode = -1; - try { - input_hashcode = (new Integer(input_hashcode_string)).intValue(); - } catch (NumberFormatException e) { - // ignore here, handle below - } - if(input_hashcode != -1) { - PeerNode[] peerNodes = node.getDarknetConnections(); - for(int i = 0; i < peerNodes.length; i++) { - int peer_hashcode = peerNodes[i].hashCode(); - if(peer_hashcode == input_hashcode) { - peernode_name = peerNodes[i].getName(); - break; - } - } - } - if(peernode_name == null) { - contentNode.addChild(createPeerInfobox("infobox-error", l10n("peerNotFoundTitle"), l10n("peerNotFoundWithHash", "hash", input_hashcode_string))); - this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); - return; - } + private UdpSocketManager usm; + + protected N2NTMToadlet(Node n, NodeClientCore core, + HighLevelSimpleClient client) { + super(client); + this.node = n; + this.core = core; + this.usm = n.getUSM(); + } + + public String supportedMethods() { + return "GET, POST"; + } + + public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx) + throws ToadletContextClosedException, IOException, + RedirectException { + + if (!ctx.isAllowedFullAccess()) { + super.sendErrorPage(ctx, 403, "Unauthorized", L10n + .getString("Toadlet.unauthorized")); + return; + } + + if (request.isParameterSet("peernode_hashcode")) { + HTMLNode pageNode = ctx.getPageMaker().getPageNode( + l10n("sendMessage"), ctx); + HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode); + + String peernode_name = null; + String input_hashcode_string = request + .getParam("peernode_hashcode"); + int input_hashcode = -1; + try { + input_hashcode = (new Integer(input_hashcode_string)) + .intValue(); + } catch (NumberFormatException e) { + // ignore here, handle below + } + if (input_hashcode != -1) { + PeerNode[] peerNodes = node.getDarknetConnections(); + for (int i = 0; i < peerNodes.length; i++) { + int peer_hashcode = peerNodes[i].hashCode(); + if (peer_hashcode == input_hashcode) { + peernode_name = peerNodes[i].getName(); + break; + } + } + } + if (peernode_name == null) { + contentNode.addChild(createPeerInfobox("infobox-error", + l10n("peerNotFoundTitle"), l10n("peerNotFoundWithHash", + "hash", input_hashcode_string))); + this.writeReply(ctx, 200, "text/html", "OK", pageNode + .generate()); + return; + } HashMap peers = new HashMap(); - peers.put( input_hashcode_string, peernode_name ); - String resultString = createN2NTMSendForm( pageNode, contentNode, ctx, peers); - if(resultString != null) { // was there an error in createN2NTMSendForm()? + peers.put(input_hashcode_string, peernode_name); + String resultString = createN2NTMSendForm(pageNode, contentNode, + ctx, peers); + if (resultString != null) { // was there an error in + // createN2NTMSendForm()? this.writeReply(ctx, 200, "text/html", "OK", resultString); return; } - this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); - return; - } - MultiValueTable headers = new MultiValueTable(); - headers.put("Location", "/friends/"); - ctx.sendReplyHeaders(302, "Found", headers, null, 0); - } - - private String l10n(String key, String pattern, String value) { - return L10n.getString("N2NTMToadlet."+key, new String[] { pattern }, new String[] { value }); - } + this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); + return; + } + MultiValueTable headers = new MultiValueTable(); + headers.put("Location", "/friends/"); + ctx.sendReplyHeaders(302, "Found", headers, null, 0); + } -private static String l10n(String key) { - return L10n.getString("N2NTMToadlet."+key); - } + private String l10n(String key, String pattern, String value) { + return L10n.getString("N2NTMToadlet." + key, new String[] { pattern }, + new String[] { value }); + } -private static HTMLNode createPeerInfobox(String infoboxType, String header, String message) { - HTMLNode infobox = new HTMLNode("div", "class", "infobox " + infoboxType); - infobox.addChild("div", "class", "infobox-header", header); - HTMLNode infoboxContent = infobox.addChild("div", "class", "infobox-content"); - infoboxContent.addChild("#", message); - HTMLNode list = infoboxContent.addChild("ul"); - Toadlet.addHomepageLink(list); - list.addChild("li").addChild("a", new String[] { "href", "title" }, new String[] { "/friends/", l10n("returnToFriends") }, l10n("friends")); - return infobox; - } - - public void handlePost(URI uri, HTTPRequest request, ToadletContext ctx) throws ToadletContextClosedException, IOException, RedirectException { - String pass = request.getPartAsString("formPassword", 32); - if((pass == null) || !pass.equals(core.formPassword)) { - MultiValueTable headers = new MultiValueTable(); - headers.put("Location", "/send_n2ntm/"); - ctx.sendReplyHeaders(302, "Found", headers, null, 0); - return; - } - - if(!ctx.isAllowedFullAccess()) { - super.sendErrorPage(ctx, 403, "Unauthorized", L10n.getString("Toadlet.unauthorized")); - return; - } - - if (request.isPartSet("send")) { - String message = request.getPartAsString("message", 5*1024); - message = message.trim(); - if(message.length() > 1024) { - this.writeReply(ctx, 400, "text/plain", l10n("tooLongTitle"), l10n("tooLong")); + private static String l10n(String key) { + return L10n.getString("N2NTMToadlet." + key); + } + + private static HTMLNode createPeerInfobox(String infoboxType, + String header, String message) { + HTMLNode infobox = new HTMLNode("div", "class", "infobox " + + infoboxType); + infobox.addChild("div", "class", "infobox-header", header); + HTMLNode infoboxContent = infobox.addChild("div", "class", + "infobox-content"); + infoboxContent.addChild("#", message); + HTMLNode list = infoboxContent.addChild("ul"); + Toadlet.addHomepageLink(list); + list.addChild("li").addChild("a", new String[] { "href", "title" }, + new String[] { "/friends/", l10n("returnToFriends") }, + l10n("friends")); + return infobox; + } + + public void handlePost(URI uri, HTTPRequest request, ToadletContext ctx) + throws ToadletContextClosedException, IOException, + RedirectException { + String pass = request.getPartAsString("formPassword", 32); + if ((pass == null) || !pass.equals(core.formPassword)) { + MultiValueTable headers = new MultiValueTable(); + headers.put("Location", "/send_n2ntm/"); + ctx.sendReplyHeaders(302, "Found", headers, null, 0); + return; + } + + if (!ctx.isAllowedFullAccess()) { + super.sendErrorPage(ctx, 403, "Unauthorized", L10n + .getString("Toadlet.unauthorized")); + return; + } + + if (request.isPartSet("send")) { + String message = request.getPartAsString("message", 5 * 1024); + message = message.trim(); + if (message.length() > 1024) { + this.writeReply(ctx, 400, "text/plain", l10n("tooLongTitle"), + l10n("tooLong")); return; } - HTMLNode pageNode = ctx.getPageMaker().getPageNode(l10n("processingSend"), ctx); + HTMLNode pageNode = ctx.getPageMaker().getPageNode( + l10n("processingSend"), ctx); HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode); - HTMLNode peerTableInfobox = contentNode.addChild("div", "class", "infobox infobox-normal"); - HTMLNode peerTable = peerTableInfobox.addChild("table", "class", "n2ntm-send-statuses"); + HTMLNode peerTableInfobox = contentNode.addChild("div", "class", + "infobox infobox-normal"); + HTMLNode peerTable = peerTableInfobox.addChild("table", "class", + "n2ntm-send-statuses"); HTMLNode peerTableHeaderRow = peerTable.addChild("tr"); peerTableHeaderRow.addChild("th", l10n("peerName")); peerTableHeaderRow.addChild("th", l10n("sendStatus")); PeerNode[] peerNodes = node.getDarknetConnections(); - for(int i = 0; i < peerNodes.length; i++) { - if (request.isPartSet("node_"+peerNodes[i].hashCode())) { + for (int i = 0; i < peerNodes.length; i++) { + if (request.isPartSet("node_" + peerNodes[i].hashCode())) { PeerNode pn = peerNodes[i]; String sendStatusShort; String sendStatusLong; @@ -149,32 +176,39 @@ long now = System.currentTimeMillis(); SimpleFieldSet fs = new SimpleFieldSet(true); fs.put("type", Node.N2N_TEXT_MESSAGE_TYPE_USERALERT); - fs.putSingle("source_nodename", Base64.encode(node.getMyName().getBytes())); - fs.putSingle("target_nodename", Base64.encode(pn.getName().getBytes())); + fs.putSingle("source_nodename", Base64.encode(node + .getMyName().getBytes())); + fs.putSingle("target_nodename", Base64.encode(pn + .getName().getBytes())); fs.putSingle("text", Base64.encode(message.getBytes())); fs.put("composedTime", now); fs.put("sentTime", now); Message n2ntm; - n2ntm = DMT.createNodeToNodeMessage(Node.N2N_TEXT_MESSAGE_TYPE_USERALERT, fs.toString().getBytes("UTF-8")); - if(!pn.isConnected()) { + n2ntm = DMT.createNodeToNodeMessage( + Node.N2N_TEXT_MESSAGE_TYPE_USERALERT, fs + .toString().getBytes("UTF-8")); + if (!pn.isConnected()) { sendStatusShort = l10n("queuedTitle"); sendStatusLong = l10n("queued"); sendStatusClass = "n2ntm-send-queued"; fs.removeValue("sentTime"); pn.queueN2NTM(fs); - Logger.normal(this, "Queued N2NTM to '"+pn.getName()+"': "+message); - } else if(pn.getPeerNodeStatus() == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { + Logger.normal(this, "Queued N2NTM to '" + + pn.getName() + "': " + message); + } else if (pn.getPeerNodeStatus() == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { sendStatusShort = l10n("delayedTitle"); sendStatusLong = l10n("delayed"); sendStatusClass = "n2ntm-send-delayed"; usm.send(pn, n2ntm, null); - Logger.normal(this, "Sent N2NTM to '"+pn.getName()+"': "+message); + Logger.normal(this, "Sent N2NTM to '" + + pn.getName() + "': " + message); } else { sendStatusShort = l10n("sentTitle"); sendStatusLong = l10n("sent"); sendStatusClass = "n2ntm-send-sent"; usm.send(pn, n2ntm, null); - Logger.normal(this, "Sent N2NTM to '"+pn.getName()+"': "+message); + Logger.normal(this, "Sent N2NTM to '" + + pn.getName() + "': " + message); } } catch (NotConnectedException e) { sendStatusShort = l10n("failedTitle"); @@ -182,44 +216,65 @@ sendStatusClass = "n2ntm-send-failed"; } HTMLNode peerRow = peerTable.addChild("tr"); - peerRow.addChild("td", "class", "peer-name").addChild("#", pn.getName()); - peerRow.addChild("td", "class", sendStatusClass).addChild("span", new String[] { "title", "style" }, new String[] { sendStatusLong, "border-bottom: 1px dotted; cursor: help;" }, sendStatusShort); + peerRow.addChild("td", "class", "peer-name").addChild("#", + pn.getName()); + peerRow + .addChild("td", "class", sendStatusClass) + .addChild( + "span", + new String[] { "title", "style" }, + new String[] { sendStatusLong, + "border-bottom: 1px dotted; cursor: help;" }, + sendStatusShort); } } - HTMLNode infoboxContent = peerTableInfobox.addChild("div", "class", "n2ntm-message-text"); + HTMLNode infoboxContent = peerTableInfobox.addChild("div", "class", + "n2ntm-message-text"); infoboxContent.addChild("#", message); HTMLNode list = peerTableInfobox.addChild("ul"); Toadlet.addHomepageLink(list); - list.addChild("li").addChild("a", new String[] { "href", "title" }, new String[] { "/friends/", l10n("returnToFriends") }, l10n("friends")); + list.addChild("li").addChild("a", new String[] { "href", "title" }, + new String[] { "/friends/", l10n("returnToFriends") }, + l10n("friends")); this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); return; - } - MultiValueTable headers = new MultiValueTable(); - headers.put("Location", "/friends/"); - ctx.sendReplyHeaders(302, "Found", headers, null, 0); + } + MultiValueTable headers = new MultiValueTable(); + headers.put("Location", "/friends/"); + ctx.sendReplyHeaders(302, "Found", headers, null, 0); } - - public static String createN2NTMSendForm(HTMLNode pageNode, HTMLNode contentNode, ToadletContext ctx, HashMap peers) throws ToadletContextClosedException, IOException { - HTMLNode infobox = contentNode.addChild("div", new String[] { "class", "id" }, new String[] { "infobox", "n2nbox" }); + + public static String createN2NTMSendForm(HTMLNode pageNode, + HTMLNode contentNode, ToadletContext ctx, HashMap peers) + throws ToadletContextClosedException, IOException { + HTMLNode infobox = contentNode.addChild("div", new String[] { "class", + "id" }, new String[] { "infobox", "n2nbox" }); infobox.addChild("div", "class", "infobox-header", l10n("sendMessage")); - HTMLNode messageTargets = infobox.addChild("div", "class", "infobox-content"); + HTMLNode messageTargets = infobox.addChild("div", "class", + "infobox-content"); messageTargets.addChild("p", l10n("composingMessageLabel")); HTMLNode messageTargetList = messageTargets.addChild("ul"); // Iterate peers - for (Iterator it = peers.values().iterator(); it.hasNext(); ) { + for (Iterator it = peers.values().iterator(); it.hasNext();) { String peer_name = (String) it.next(); messageTargetList.addChild("li", peer_name); } - HTMLNode infoboxContent = infobox.addChild("div", "class", "infobox-content"); - HTMLNode messageForm = ctx.addFormChild(infoboxContent, "/send_n2ntm/", "sendN2NTMForm"); + HTMLNode infoboxContent = infobox.addChild("div", "class", + "infobox-content"); + HTMLNode messageForm = ctx.addFormChild(infoboxContent, "/send_n2ntm/", + "sendN2NTMForm"); // Iterate peers - for (Iterator it = peers.keySet().iterator(); it.hasNext(); ) { + for (Iterator it = peers.keySet().iterator(); it.hasNext();) { String peerNodeHash = (String) it.next(); - messageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "node_"+peerNodeHash, "1" }); + messageForm.addChild("input", new String[] { "type", "name", + "value" }, new String[] { "hidden", "node_" + peerNodeHash, + "1" }); } - messageForm.addChild("textarea", new String[] { "id", "name", "rows", "cols" }, new String[] { "n2ntmtext", "message", "8", "74" }); + messageForm.addChild("textarea", new String[] { "id", "name", "rows", + "cols" }, new String[] { "n2ntmtext", "message", "8", "74" }); messageForm.addChild("br"); - messageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "send", l10n("sendMessageShort") }); + messageForm.addChild("input", new String[] { "type", "name", "value" }, + new String[] { "submit", "send", l10n("sendMessageShort") }); return null; } } From toad at freenetproject.org Fri Jun 1 14:43:22 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 14:43:22 +0000 (UTC) Subject: [freenet-cvs] r13441 - trunk/freenet/src/freenet/clients/http Message-ID: <20070601144322.81C0A4791C6@emu.freenetproject.org> Author: toad Date: 2007-06-01 14:43:22 +0000 (Fri, 01 Jun 2007) New Revision: 13441 Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java Log: It never returns anything. Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java 2007-06-01 14:41:13 UTC (rev 13440) +++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java 2007-06-01 14:43:22 UTC (rev 13441) @@ -737,11 +737,7 @@ } } } - String resultString = N2NTMToadlet.createN2NTMSendForm( pageNode, contentNode, ctx, peers); - if(resultString != null) { // was there an error in createN2NTMSendForm()? - this.writeReply(ctx, 200, "text/html", "OK", resultString); - return; - } + N2NTMToadlet.createN2NTMSendForm( pageNode, contentNode, ctx, peers); this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); return; } else if (request.isPartSet("doAction") && request.getPartAsString("action",25).equals("update_notes")) { Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 14:41:13 UTC (rev 13440) +++ trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 14:43:22 UTC (rev 13441) @@ -90,13 +90,7 @@ } HashMap peers = new HashMap(); peers.put(input_hashcode_string, peernode_name); - String resultString = createN2NTMSendForm(pageNode, contentNode, - ctx, peers); - if (resultString != null) { // was there an error in - // createN2NTMSendForm()? - this.writeReply(ctx, 200, "text/html", "OK", resultString); - return; - } + createN2NTMSendForm(pageNode, contentNode, ctx, peers); this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate()); return; } @@ -244,7 +238,7 @@ ctx.sendReplyHeaders(302, "Found", headers, null, 0); } - public static String createN2NTMSendForm(HTMLNode pageNode, + public static void createN2NTMSendForm(HTMLNode pageNode, HTMLNode contentNode, ToadletContext ctx, HashMap peers) throws ToadletContextClosedException, IOException { HTMLNode infobox = contentNode.addChild("div", new String[] { "class", @@ -275,6 +269,5 @@ messageForm.addChild("br"); messageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "send", l10n("sendMessageShort") }); - return null; } } From nextgens at freenetproject.org Fri Jun 1 15:57:55 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Fri, 1 Jun 2007 15:57:55 +0000 (UTC) Subject: [freenet-cvs] r13442 - trunk/freenet/src/freenet/pluginmanager Message-ID: <20070601155755.8618647A037@emu.freenetproject.org> Author: nextgens Date: 2007-06-01 15:57:55 +0000 (Fri, 01 Jun 2007) New Revision: 13442 Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java Log: fix a stupid NPE Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java =================================================================== --- trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2007-06-01 14:43:22 UTC (rev 13441) +++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2007-06-01 15:57:55 UTC (rev 13442) @@ -357,7 +357,7 @@ } File finalFile = new File("plugins/" + pluginname + ".jar"); - File f = File.createTempFile(pluginname, ".tmp", finalFile); + File f = File.createTempFile(pluginname, ".tmp", pluginsDirectory); fos = new FileOutputStream(f); bos = new BufferedOutputStream(fos); int len = 0, writenBytes = 0; @@ -515,4 +515,4 @@ return (FredPlugin)o; } -} \ No newline at end of file +} From toad at freenetproject.org Fri Jun 1 16:45:20 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 16:45:20 +0000 (UTC) Subject: [freenet-cvs] r13445 - in trunk/freenet/src/freenet: clients/http io/comm keys l10n node support support/io Message-ID: <20070601164520.0A4DA4798DF@emu.freenetproject.org> Author: toad Date: 2007-06-01 16:45:19 +0000 (Fri, 01 Jun 2007) New Revision: 13445 Added: trunk/freenet/src/freenet/support/io/RandomAccessFileWrapper.java Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java trunk/freenet/src/freenet/io/comm/DMT.java trunk/freenet/src/freenet/keys/FreenetURI.java trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties trunk/freenet/src/freenet/node/Node.java trunk/freenet/src/freenet/node/NodeDispatcher.java trunk/freenet/src/freenet/node/PeerNode.java trunk/freenet/src/freenet/support/SimpleFieldSet.java trunk/freenet/src/freenet/support/io/FileUtil.java trunk/freenet/src/freenet/support/io/RandomAccessThing.java Log: Direct f2f bulk data transfer, and significant related refactoring to N2NTM related code. Caveats: - Automatically accepts transfers! This is BAD! DO NOT RELEASE! Will be fixed before release. - Untested! - PeerNode now uses 2 different types in N2NTMs: n2nType, which is fproxy vs other apps, and within an fproxy message, type, which differentiates between a useralert and messages related to the bulk transfer mechanism. Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 16:45:14 UTC (rev 13444) +++ trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 16:45:19 UTC (rev 13445) @@ -3,6 +3,7 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.clients.http; +import java.io.File; import java.io.IOException; import java.net.URI; import java.util.HashMap; @@ -154,60 +155,63 @@ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode); HTMLNode peerTableInfobox = contentNode.addChild("div", "class", "infobox infobox-normal"); + PeerNode[] peerNodes = node.getDarknetConnections(); + String fnam = request.getPartAsString("filename", 1024); + File filename = null; + if(fnam != null) { + filename = new File(fnam); + if(!(filename.exists() && filename.canRead())) { + peerTableInfobox.addChild("#", l10n("noSuchFileOrCannotRead")); + Toadlet.addHomepageLink(peerTableInfobox); + this.writeReply(ctx, 400, "text/html", "OK", pageNode.generate()); + return; + } + } HTMLNode peerTable = peerTableInfobox.addChild("table", "class", - "n2ntm-send-statuses"); + "n2ntm-send-statuses"); HTMLNode peerTableHeaderRow = peerTable.addChild("tr"); peerTableHeaderRow.addChild("th", l10n("peerName")); peerTableHeaderRow.addChild("th", l10n("sendStatus")); - PeerNode[] peerNodes = node.getDarknetConnections(); for (int i = 0; i < peerNodes.length; i++) { if (request.isPartSet("node_" + peerNodes[i].hashCode())) { PeerNode pn = peerNodes[i]; + + int status; + + if(filename != null) { + try { + status = pn.sendFileOffer(filename, message); + } catch (IOException e) { + peerTableInfobox.addChild("#", l10n("noSuchFileOrCannotRead")); + Toadlet.addHomepageLink(peerTableInfobox); + this.writeReply(ctx, 400, "text/html", "OK", pageNode.generate()); + return; + } + } else { + status = pn.sendTextMessage(message); + } + String sendStatusShort; String sendStatusLong; String sendStatusClass; - try { - long now = System.currentTimeMillis(); - SimpleFieldSet fs = new SimpleFieldSet(true); - fs.put("type", Node.N2N_TEXT_MESSAGE_TYPE_USERALERT); - fs.putSingle("source_nodename", Base64.encode(node - .getMyName().getBytes())); - fs.putSingle("target_nodename", Base64.encode(pn - .getName().getBytes())); - fs.putSingle("text", Base64.encode(message.getBytes())); - fs.put("composedTime", now); - fs.put("sentTime", now); - Message n2ntm; - n2ntm = DMT.createNodeToNodeMessage( - Node.N2N_TEXT_MESSAGE_TYPE_USERALERT, fs - .toString().getBytes("UTF-8")); - if (!pn.isConnected()) { - sendStatusShort = l10n("queuedTitle"); - sendStatusLong = l10n("queued"); - sendStatusClass = "n2ntm-send-queued"; - fs.removeValue("sentTime"); - pn.queueN2NTM(fs); - Logger.normal(this, "Queued N2NTM to '" - + pn.getName() + "': " + message); - } else if (pn.getPeerNodeStatus() == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { - sendStatusShort = l10n("delayedTitle"); - sendStatusLong = l10n("delayed"); - sendStatusClass = "n2ntm-send-delayed"; - usm.send(pn, n2ntm, null); - Logger.normal(this, "Sent N2NTM to '" - + pn.getName() + "': " + message); - } else { - sendStatusShort = l10n("sentTitle"); - sendStatusLong = l10n("sent"); - sendStatusClass = "n2ntm-send-sent"; - usm.send(pn, n2ntm, null); - Logger.normal(this, "Sent N2NTM to '" - + pn.getName() + "': " + message); - } - } catch (NotConnectedException e) { - sendStatusShort = l10n("failedTitle"); - sendStatusLong = l10n("failed"); - sendStatusClass = "n2ntm-send-failed"; + if(status == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { + sendStatusShort = l10n("delayedTitle"); + sendStatusLong = l10n("delayed"); + sendStatusClass = "n2ntm-send-delayed"; + Logger.normal(this, "Sent N2NTM to '" + + pn.getName() + "': " + message); + } else if(status == PeerManager.PEER_NODE_STATUS_CONNECTED) { + sendStatusShort = l10n("sentTitle"); + sendStatusLong = l10n("sent"); + sendStatusClass = "n2ntm-send-sent"; + Logger.normal(this, "Sent N2NTM to '" + + pn.getName() + "': " + message); + } else { + sendStatusShort = l10n("queuedTitle"); + sendStatusLong = l10n("queued"); + sendStatusClass = "n2ntm-send-queued"; + Logger.normal(this, "Queued N2NTM to '" + + pn.getName() + "': " + message); } HTMLNode peerRow = peerTable.addChild("tr"); peerRow.addChild("td", "class", "peer-name").addChild("#", @@ -267,7 +271,10 @@ messageForm.addChild("textarea", new String[] { "id", "name", "rows", "cols" }, new String[] { "n2ntmtext", "message", "8", "74" }); messageForm.addChild("br"); + messageForm.addChild("#", "You may attach a file:"); messageForm.addChild("input", new String[] { "type", "name", "value" }, + new String[] { "text", "filename", "" }); + messageForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "send", l10n("sendMessageShort") }); } } Modified: trunk/freenet/src/freenet/io/comm/DMT.java =================================================================== --- trunk/freenet/src/freenet/io/comm/DMT.java 2007-06-01 16:45:14 UTC (rev 13444) +++ trunk/freenet/src/freenet/io/comm/DMT.java 2007-06-01 16:45:19 UTC (rev 13445) @@ -425,23 +425,6 @@ return msg; } - // Node-To-Node Instant Message - public static final MessageType nodeToNodeTextMessage = new MessageType("nodeToNodeTextMessage", false) {{ - addField(NODE_TO_NODE_MESSAGE_TYPE, Integer.class); - addField(SOURCE_NODENAME, String.class); - addField(TARGET_NODENAME, String.class); - addField(NODE_TO_NODE_MESSAGE_TEXT, String.class); - }}; - - public static final Message createNodeToNodeTextMessage(int type, String source, String target, String message) { - Message msg = new Message(nodeToNodeTextMessage); - msg.set(NODE_TO_NODE_MESSAGE_TYPE, type); - msg.set(SOURCE_NODENAME, source); - msg.set(TARGET_NODENAME, target); - msg.set(NODE_TO_NODE_MESSAGE_TEXT, message); - return msg; - } - // FNP messages public static final MessageType FNPCHKDataRequest = new MessageType("FNPCHKDataRequest") {{ addField(UID, Long.class); Modified: trunk/freenet/src/freenet/keys/FreenetURI.java =================================================================== --- trunk/freenet/src/freenet/keys/FreenetURI.java 2007-06-01 16:45:14 UTC (rev 13444) +++ trunk/freenet/src/freenet/keys/FreenetURI.java 2007-06-01 16:45:19 UTC (rev 13445) @@ -24,6 +24,7 @@ import freenet.support.URLDecoder; import freenet.support.URLEncodedFormatException; import freenet.support.URLEncoder; +import freenet.support.io.FileUtil; import freenet.client.InsertException; /** @@ -740,7 +741,7 @@ for(int i=0;i') || (c == '<') || (c == ':') || (c == '\'') || (c == '\"')) + continue; + if(Character.isDigit(c)) + sb.append(c); + else if(Character.isLetter(c)) + sb.append(c); + else if(Character.isWhitespace(c)) + sb.append(' '); + else if((c == '-') || (c == '_') || (c == '.')) + sb.append(c); + } + return sb.toString(); + } + + public static String sanitize(String filename, String mimeType) { + filename = sanitize(filename); + if(mimeType == null) return filename; + if(filename.indexOf('.') >= 0) { + String oldExt = filename.substring(filename.lastIndexOf('.')); + if(DefaultMIMETypes.isValidExt(mimeType, oldExt)) return filename; + } + return filename + '.' + DefaultMIMETypes.getExtension(filename); + } + } Added: trunk/freenet/src/freenet/support/io/RandomAccessFileWrapper.java =================================================================== --- trunk/freenet/src/freenet/support/io/RandomAccessFileWrapper.java (rev 0) +++ trunk/freenet/src/freenet/support/io/RandomAccessFileWrapper.java 2007-06-01 16:45:19 UTC (rev 13445) @@ -0,0 +1,41 @@ +package freenet.support.io; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + +public class RandomAccessFileWrapper implements RandomAccessThing { + + // FIXME maybe we should avoid opening these until we are ready to use them + final RandomAccessFile raf; + + public RandomAccessFileWrapper(RandomAccessFile raf) { + this.raf = raf; + } + + public RandomAccessFileWrapper(File filename, String mode) throws FileNotFoundException { + raf = new RandomAccessFile(filename, mode); + } + + public void pread(long fileOffset, byte[] buf, int bufOffset, int length) + throws IOException { + synchronized(this) { + raf.seek(fileOffset); + raf.readFully(buf, bufOffset, length); + } + } + + public void pwrite(long fileOffset, byte[] buf, int bufOffset, int length) + throws IOException { + synchronized(this) { + raf.seek(fileOffset); + raf.write(buf, bufOffset, length); + } + } + + public long size() throws IOException { + return raf.length(); + } + +} Modified: trunk/freenet/src/freenet/support/io/RandomAccessThing.java =================================================================== --- trunk/freenet/src/freenet/support/io/RandomAccessThing.java 2007-06-01 16:45:14 UTC (rev 13444) +++ trunk/freenet/src/freenet/support/io/RandomAccessThing.java 2007-06-01 16:45:19 UTC (rev 13445) @@ -11,7 +11,7 @@ */ public interface RandomAccessThing { - public long size(); + public long size() throws IOException; public void pread(long fileOffset, byte[] buf, int bufOffset, int length) throws IOException; From mkolar at freenetproject.org Fri Jun 1 16:56:01 2007 From: mkolar at freenetproject.org (mkolar at freenetproject.org) Date: Fri, 1 Jun 2007 16:56:01 +0000 (UTC) Subject: [freenet-cvs] r13446 - in trunk/apps: . CppFCPLib Message-ID: <20070601165601.AD7174797DE@emu.freenetproject.org> Author: mkolar Date: 2007-06-01 16:56:01 +0000 (Fri, 01 Jun 2007) New Revision: 13446 Added: trunk/apps/CppFCPLib/ trunk/apps/CppFCPLib/DefaultValues.h trunk/apps/CppFCPLib/Exceptions.cpp trunk/apps/CppFCPLib/Exceptions.h trunk/apps/CppFCPLib/JobTicket.cpp trunk/apps/CppFCPLib/JobTicket.h trunk/apps/CppFCPLib/Log.cpp trunk/apps/CppFCPLib/Log.h trunk/apps/CppFCPLib/Message.cpp trunk/apps/CppFCPLib/Message.h trunk/apps/CppFCPLib/Node.cpp trunk/apps/CppFCPLib/Node.h trunk/apps/CppFCPLib/NodeThread.cpp trunk/apps/CppFCPLib/NodeThread.h trunk/apps/CppFCPLib/Server.cpp trunk/apps/CppFCPLib/Server.h trunk/apps/CppFCPLib/TQueue.h trunk/apps/CppFCPLib/main.cpp Log: Initial import of CppFCPLib to the repository Added: trunk/apps/CppFCPLib/DefaultValues.h =================================================================== --- trunk/apps/CppFCPLib/DefaultValues.h (rev 0) +++ trunk/apps/CppFCPLib/DefaultValues.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,19 @@ + +#ifndef DEFAULTVALUES_H_ +#define DEFAULTVALUES_H_ + +#include +//#include "Log.h" + +const std::string defaultFCPHost = "127.0.0.1"; +const int defaultFCPPort = 9481; +const std::string defaultFProxyHost = "127.0.0.1"; +const int defaultFProxyPort = 8888; +//const FCPLib::verbosityLevel defaultVerbosity = FCPLib::ERROR; +const int inputBufferSize = 64 * 1024; +const int outputBufferSize = 64 * 1024; +const int maxSizeMessage = 8192; +const int pollTimeout = 100; +const int oneyear = 86400 * 365 * 1000; + +#endif Added: trunk/apps/CppFCPLib/Exceptions.cpp =================================================================== --- trunk/apps/CppFCPLib/Exceptions.cpp (rev 0) +++ trunk/apps/CppFCPLib/Exceptions.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,31 @@ +#include "Exceptions.h" + +using namespace FCPLib; + +StdError::StdError() : + std::runtime_error(strerror(errno)), + error(errno) +{ +} + +StdError::StdError(int error_) : + std::runtime_error(strerror(error_)), + error(error_) +{ +} + +StdError::StdError(std::string &func, std::string &message, std::string &errstring) : + std::runtime_error(func + " : " + message + " " + errstring), + error(errno) +{ +} + +StdError::StdError(const char *func, const char *message, const char *errstring) : + std::runtime_error(std::string(func) + " : " + std::string(message) + " " + std::string(errstring)), + error(errno) +{ +} + +StdError::~StdError() throw() +{ +} Added: trunk/apps/CppFCPLib/Exceptions.h =================================================================== --- trunk/apps/CppFCPLib/Exceptions.h (rev 0) +++ trunk/apps/CppFCPLib/Exceptions.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,22 @@ + +#ifndef EXCEPTIONS_H__ +#define EXCEPTIONS_H__ + +#include +#include + +namespace FCPLib { + +class StdError : public std::runtime_error { + int error; +public: + StdError(); + StdError(int error_); + StdError(std::string &func, std::string &message, std::string &errstring); + StdError(const char *func, const char *message, const char *errstring); + ~StdError() throw(); +}; + +} + +#endif Added: trunk/apps/CppFCPLib/JobTicket.cpp =================================================================== --- trunk/apps/CppFCPLib/JobTicket.cpp (rev 0) +++ trunk/apps/CppFCPLib/JobTicket.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,125 @@ + +#include "JobTicket.h" +#include "DefaultValues.h" +#include "zthread/Thread.h" +#include + +using namespace FCPLib; + +JobTicket::JobTicket(std::string id_, Message::MessagePtr &cmd_) + : id(id_), + cmd(cmd_), + async_(false), + keep(false), + waitTillSent_(false), + timeout_(oneyear), + isReprValid(false) +// hasStream(false) +{ + lock.acquire(); + reqSentLock.acquire(); +} + +JobTicket& +JobTicket::async(bool async) +{ + isReprValid = false; + async_ = async; return *this; +} + +inline JobTicket& +JobTicket::keepJob(bool keep_) +{ + isReprValid = false; + keep = keep_; return *this; +} +inline JobTicket& +JobTicket::waitTillSent(bool wait_) +{ + isReprValid = false; + waitTillSent_ = wait_; return *this; +} +inline JobTicket& +JobTicket::timeout(int timeout) +{ + isReprValid = false; + timeout_ = timeout; return *this; +} + +const std::string& +JobTicket::getId() const +{ + return id; +} + +const std::string& +JobTicket::commandName() const +{ + return cmd->getHeader(); +} + +const std::string& +JobTicket::getMessageText() const +{ + return cmd->toString(); +} + +void +JobTicket::wait(unsigned int timeout) +{ + if (!timeout){ + while (!lock.tryAcquire(100)) + ZThread::Thread::sleep(100); + lock.release(); + return; + } + + unsigned int then = (unsigned int) time(0); + unsigned int elapsed; + while (!reqSentLock.tryAcquire(100)){ + elapsed = (unsigned int) time(0) - then; + if (elapsed < timeout){ + Thread::sleep(1000) + log().log(DEBUG, "wait:"+job->commandName()+":"+job->getId()+": job not dispatched, timeout in " + + boost::lexical_cast(timeout-elapsed)); + continue; + } + } +} + +void +JobTicket::waitTillReqSent() +{ + reqSentLock.acquire(); +} + +void +JobTicket::putResult() +{ + lock.release(); +} + +const std::vector& +JobTicket::getResponse() const +{ + return nodeResponse; +} + +const std::string& +JobTicket::toString() +{ + if (isReprValid) + return repr; + + repr = ""; + isReprValid = true; + + repr += "Job id=" + id + "\n"; + repr += getMessageText(); + repr += "async=" + boost::lexical_cast(async_) + "\n"; + repr += "keepJob=" + boost::lexical_cast(keep) + "\n"; + repr += "waitTillSent=" + boost::lexical_cast(waitTillSent_) + "\n"; + repr += "timeout=" + boost::lexical_cast(timeout_) + "\n"; + + return repr; +} Added: trunk/apps/CppFCPLib/JobTicket.h =================================================================== --- trunk/apps/CppFCPLib/JobTicket.h (rev 0) +++ trunk/apps/CppFCPLib/JobTicket.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,60 @@ +#ifndef JOBTICKET_H__ +#define JOBTICKET_H__ + +#include "Log.h" +#include "Message.h" +#include +#include +#include +#include "zthread/FastMutex.h" + +namespace FCPLib { + +class NodeThread; + +class JobTicket { + std::string id; + Message::MessagePtr cmd; + std::vector nodeResponse; + bool async_; + bool keep; + bool waitTillSent_; + int timeout_; + + std::string repr; + bool isReprValid; + +// bool hasStream; +// ostream stream; + + ZThread::FastMutex lock; + ZThread::FastMutex reqSentLock; + int timeQueued; + + void putResult(); +public: + typedef boost::shared_ptr JobTicketPtr; + + JobTicket(std::string id_, Message::MessagePtr &cmd_); + inline JobTicket& async(bool async_); + inline JobTicket& keepJob(bool keep_); + inline JobTicket& waitTillSent(bool wait); + inline JobTicket& timeout(int timeout); + + const std::string& commandName() const; + const std::string& getId() const; + const std::string& getMessageText() const; + + void wait(unsigned int timeout_=0); + void waitTillReqSent(); + + const std::vector& getResponse() const; + const std::string& toString(); + + + friend class NodeThread; +}; + +} + +#endif Added: trunk/apps/CppFCPLib/Log.cpp =================================================================== --- trunk/apps/CppFCPLib/Log.cpp (rev 0) +++ trunk/apps/CppFCPLib/Log.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,44 @@ + +#include "Log.h" +#include "Exceptions.h" +#include "zthread/Guard.h" + +using namespace FCPLib; + +Logger::Logger(ostream &out_, verbosityLevel logLevel_) + : out(out_), + logLevel(logLevel_) +{ +} + +void Logger::log(verbosityLevel logLevel_, const char *message) +{ + ZThread::Guard g(lock); + + if (logLevel_ <= logLevel) { + out << message; + if (message[strlen(message)] != '\n') + out << '\n'; + } + out.flush(); +} + +void Logger::log(verbosityLevel logLevel_, std::string message) +{ + log(logLevel_, message.c_str()); +} + +Logger& +log(ostream &out_, verbosityLevel logLevel_) +{ + static bool firstTime = true; + static Logger* l; + + if (firstTime) { + firstTime = false; + l = new Logger(out_, logLevel_); + } + + return *l; +} + Added: trunk/apps/CppFCPLib/Log.h =================================================================== --- trunk/apps/CppFCPLib/Log.h (rev 0) +++ trunk/apps/CppFCPLib/Log.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,40 @@ + +#ifndef LOG_H_ +#define LOG_H_ + + +#include "zthread/Thread.h" +#include "zthread/Mutex.h" +#include +#include + +using namespace std; + +namespace FCPLib { + +typedef enum { + SILENT, + FATAL, + CRITICAL, + ERROR, + INFO, + DETAIL, + DEBUG, + NOISY, +} verbosityLevel; + +class Logger{ + ZThread::Mutex lock; + ostream &out; + verbosityLevel logLevel; +public: + Logger(ostream &out_, verbosityLevel logLevel_=ERROR); + void log(verbosityLevel logLevel, const char *message); + void log(verbosityLevel logLevel, string message); +}; + +} + +FCPLib::Logger& log(ostream &out_=cerr, FCPLib::verbosityLevel logLevel_=FCPLib::NOISY); + +#endif Added: trunk/apps/CppFCPLib/Message.cpp =================================================================== --- trunk/apps/CppFCPLib/Message.cpp (rev 0) +++ trunk/apps/CppFCPLib/Message.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,94 @@ +#include "Message.h" + + +using namespace std; +using namespace FCPLib; + +Message::Message() { + isDataType = false; + isReprValid = false; +} + +Message::MessagePtr +Message::factory(std::string &header){ + Message::MessagePtr m( new Message() ); + + m->header = header; + + return m; +} + +Message::MessagePtr +Message::factory(const char *header){ + std::string hdr(header); + + return factory(hdr); +} + +Message::MessagePtr +Message::factory(Server &s){ + Message::MessagePtr m( new Message() ); + static char line[1000]; + + s.readln(line, 1000); + line[strlen(line)-1] = 0; + m->header = string(line); + + for (;;) { + s.readln(line, 1000); + line[strlen(line)-1] = 0; + + if (!strcmp(line, "End") || !strcmp(line, "EndMessage")) + break; + + char *val = strchr(line, '='); + *val++ = 0; + m->fields[string(line)] = string(val); + } + + return m; +} + +void +Message::setField(std::string key, std::string value) { + // TODO: should i check if a message can contain certain field? + isReprValid = false; + fields[key] = value; +} + +std::string +Message::getField(const std::string &key) { + return fields[key]; +} + + +const std::string& +Message::toString() { + static char intToString[30]; + if (isReprValid) + return repr; + repr = header + "\n"; + for (map::iterator it = fields.begin(); it != fields.end(); ++it) + if (isDataType && it->first == "Data") + continue; + else + repr += it->first + "=" + it->second + "\n"; + if (isDataType) { + repr += "DataLength="; + sprintf(intToString, "%d", fields["Data"].size()); + repr += string(intToString); + repr += "\n"; + repr += "Data\n"; + repr += fields["Data"]; + } else { + repr += "EndMessage\n"; + } + isReprValid = true; + return repr; +} + +const std::string& +Message::getHeader() const +{ + return header; +} Added: trunk/apps/CppFCPLib/Message.h =================================================================== --- trunk/apps/CppFCPLib/Message.h (rev 0) +++ trunk/apps/CppFCPLib/Message.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,40 @@ + + +#ifndef MESSAGE_H_ +#define MESSAGE_H_ + +#include +#include +#include +#include "Server.h" + +namespace FCPLib { + +class Message { + std::string repr; + std::string header; + + std::map fields; + + bool isDataType; + bool isReprValid; + + Message(); +public: + typedef boost::shared_ptr MessagePtr; + static MessagePtr factory(std::string &header); + static MessagePtr factory(const char *header); + static MessagePtr factory(Server &s); + + void setField(std::string key, std::string value); + inline std::string getField(const std::string &key); + const std::string& getHeader() const; + + const std::string& toString(); +}; + +} + +#endif + + Added: trunk/apps/CppFCPLib/Node.cpp =================================================================== --- trunk/apps/CppFCPLib/Node.cpp (rev 0) +++ trunk/apps/CppFCPLib/Node.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,44 @@ + +#include "Node.h" +#include "Message.h" +#include "Log.h" + +using namespace FCPLib; + +std::string +Node::_getUniqueId() { + char newid[100]; + sprintf(newid, "id%d", (int) time(0)); + return string(newid); +} + +Node::Node(std::string name_, std::string host, int port) + : name(name_), + clientReqQueue( new TQueue() ) +{ + if (!name.size()) + name = Node::_getUniqueId(); + log().log(DEBUG, "Node started name=" + name + "\n"); + + nodeThread = new NodeThread(host, port, clientReqQueue); + executor.execute( nodeThread ); + + Message::MessagePtr m = Message::factory("ClientHello"); + m->setField("Name", name); + m->setField("ExpectedVersion", "2.0"); + + log().log(DEBUG, "Creating ClientHello\n"); + JobTicket::JobTicketPtr job( new JobTicket("__hello", m) ); + log().log(DEBUG, job->toString()); + clientReqQueue->put(job); + + log().log(DEBUG, "waiting for the NodeHello"); + job->wait(0); + log().log(DEBUG, "NodeHello arrived"); +// cout << "Izlaz:\n" << job->getResponse()[0]->toString(); +} + +Node::~Node() +{ + executor.interrupt(); +} Added: trunk/apps/CppFCPLib/Node.h =================================================================== --- trunk/apps/CppFCPLib/Node.h (rev 0) +++ trunk/apps/CppFCPLib/Node.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,26 @@ +#ifndef NODE_H__ +#define NODE_H__ + +#include +#include +#include "zthread/Thread.h" +#include "zthread/ThreadedExecutor.h" +#include "TQueue.h" +#include "NodeThread.h" + +namespace FCPLib { +class Node { + std::string name; + ZThread::CountedPtr< JobTicketQueue > clientReqQueue; + NodeThread *nodeThread; + ZThread::ThreadedExecutor executor; + + static std::string _getUniqueId(); + +public: + Node(std::string name, std::string host, int port); + ~Node(); +}; +} + +#endif Added: trunk/apps/CppFCPLib/NodeThread.cpp =================================================================== --- trunk/apps/CppFCPLib/NodeThread.cpp (rev 0) +++ trunk/apps/CppFCPLib/NodeThread.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,114 @@ + + +#include "NodeThread.h" +#include "Log.h" +#include + +using namespace FCPLib; +using namespace ZThread; + +NodeThread::NodeThread(std::string &host, + int port, + ZThread::CountedPtr > &clientReqQueue_) throw() + : clientReqQueue(clientReqQueue_), + s(host, port), + jobs( new std::map() ) +{ +} + +void NodeThread::run(){ + Message::MessagePtr m; + JobTicket::JobTicketPtr job; + log().log(DETAIL, "FCPNode: manager thread starting"); + try { + while (!Thread::interrupted()) { + //check for incoming message from node + log().log(NOISY, "_mgrThread: Testing for incoming message"); + if (s.dataAvailable()){ + log().log(DEBUG, "_mgrThread: Retrieving incoming message"); + m = Message::factory(s); + log().log(DEBUG, "_mgrThread: Got incoming message, dispatching"); + // dispatch the message + doMessage(m); + } + //check for incoming message from client + if (!clientReqQueue->empty()){ + log().log(DEBUG, "_mgrThread: Got incoming client req"); + job = clientReqQueue->get(); + log().log(DEBUG, "_mgrThread: Got incoming client req from the queue"); + log().log(DEBUG, job->toString()); + sendClientReq(job); + } + } + } catch (ZThread::Synchronization_Exception& e) { + // do some cleanup + } +} + +void +NodeThread::sendClientReq(JobTicket::JobTicketPtr &job) +{ + log().log(NOISY, "sendClientReq : top"); + if (job->commandName() != "WatchGlobal") { + log().log(NOISY, "sendClientReq : about to add the job to the map"); + (*jobs)[job->getId()] = job; + log().log(NOISY, "sendClientReq : added the job to the map"); + } + + s.send(job->getMessageText()); + job->timeQueued = (unsigned int) time(0); + job->reqSentLock.release(); +} + +// +//void NodeThread::_hello(){ +// string message; +// message = Message::toString("ClientHello", 2, "Name", this->name.c_str(), "ExpectedVersion", "2.0"); +// messageQSend->put(message); +// logfile->log(DETAIL, message); +// +// message = this->_rxMsg(); +// Message* nodeHello = new Message(message); +// const char * tmp; +// if ((tmp = nodeHello->getField("FCPVersion")) != NULL){ +// this->nodeFCPVersion = string(tmp); +// } +// if ((tmp = nodeHello->getField("Version")) != NULL){ +// this->nodeVersion = string(tmp); +// } +// if ((tmp = nodeHello->getField("Testnet")) != NULL){ +// this->nodeIsTestnet = (string(tmp) == "true") ? true : false; +// } +// if ((tmp = nodeHello->getField("CompressionCodes")) != NULL){ +// this->compressionCodes = atoi(tmp); +// } +// +// delete nodeHello; +//} + + +// +//string NodeThread::_rxMsg(){ +// string message = messageQReceive->get(); +// logfile->log(DETAIL, message); +// return message; +//} +// +//void NodeThread::_on_rxMsg(std::string& message){ +// Message m(message); +// +// logfile->log(DEBUG, m.toString()); +//} + +void +NodeThread::doMessage(Message::MessagePtr &message) +{ + JobTicket::JobTicketPtr job; + if (message->getHeader() == "NodeHello"){ + job = jobs->find("__hello")->second; + job->nodeResponse.push_back(message); + job->putResult(); + return; + } +} + Added: trunk/apps/CppFCPLib/NodeThread.h =================================================================== --- trunk/apps/CppFCPLib/NodeThread.h (rev 0) +++ trunk/apps/CppFCPLib/NodeThread.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,40 @@ +#ifndef NODETHREAD_H__ +#define NODETHREAD_H__ + +#include "zthread/Thread.h" +#include "TQueue.h" +#include "Log.h" +#include "Server.h" +#include +#include +#include "JobTicket.h" + +namespace FCPLib { + +class Node; + +typedef TQueue JobTicketQueue; + +class NodeThread : public ZThread::Runnable { +// ZThread::CountedPtr logfile; + ZThread::CountedPtr< JobTicketQueue > clientReqQueue; + FCPLib::Server s; + ZThread::CountedPtr< std::map > jobs; + +// void _hello(); +// static std::string _getUniqueId(); +// std::string _rxMsg(); +// void _on_rxMsg(std::string &message); + + friend class Node; + NodeThread(std::string &host, int port, ZThread::CountedPtr< JobTicketQueue > &clientReqQueue_) throw(); + + void sendClientReq(JobTicket::JobTicketPtr &job); + void doMessage(Message::MessagePtr &message); +public: + void run(); +}; + +} +#endif + Added: trunk/apps/CppFCPLib/Server.cpp =================================================================== --- trunk/apps/CppFCPLib/Server.cpp (rev 0) +++ trunk/apps/CppFCPLib/Server.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,150 @@ + +#include "Server.h" +#include "Exceptions.h" +#include "DefaultValues.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Log.h" + +using namespace FCPLib; + + +Server::Server(std::string &host, int port){ + /* Use local host as default address */ + if (!host.size()) + host = "127.0.0.1"; + + /* Use default port */ + if (port<=0) + port = 9481; + + struct hostent *he; + struct sockaddr_in addr; + + /* Resolve hostname */ + if ((he = gethostbyname(host.c_str())) == NULL) + throw StdError(__FUNCTION__, "Failed to resolve", strerror(errno)); + + /* Snag socket */ + if ((sockfd = socket(PF_INET, SOCK_STREAM, 0))<0) + throw StdError(__FUNCTION__, "Failed to get socket", strerror(errno)); + + addr.sin_family = AF_INET; + addr.sin_port = htons(port); + addr.sin_addr = *((struct in_addr *)he->h_addr); + memset(&(addr.sin_zero), '\0', 8); + + /* Connect */ + if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr))<0) { + close(sockfd); + throw StdError(__FUNCTION__, "Failed to connect", strerror(errno)); + } +} + +Server::~Server(){ + close(sockfd); +} + +ssize_t Server::readn(void *vptr, size_t n){ + size_t nleft; + ssize_t nread; + char *ptr; + + ptr = (char*) vptr; + nleft = n; + while (nleft > 0) { + if ((nread = read(sockfd, ptr, nleft)) < 0) { + if (errno == EINTR) + nread = 0; + else + throw StdError(__FUNCTION__, "", strerror(errno)); + } else if (nread == 0) { + break; // EOF + } + nleft -= nread; + ptr += nread; + } + + return (n - nleft); +} + +ssize_t Server::writen(const void *vptr, size_t n){ + size_t nleft; + ssize_t nwritten; + const char *ptr; + + ptr = (const char*) vptr; + nleft = n; + while (nleft > 0) { + if ((nwritten = write(sockfd, ptr, nleft)) <= 0) { + if (errno == EINTR) + nwritten = 0; + else + throw StdError(__FUNCTION__, "", strerror(errno)); + } + nleft -= nwritten; + ptr += nwritten; + } + + return (n); +} + +ssize_t Server::readln(void *vptr, size_t maxlen){ + ssize_t n, rc; + char c, *ptr; + + ptr = (char *)vptr; + for (n = 1; n < maxlen; n++) { + if ((rc = read(sockfd, &c, 1)) == 1) { + *ptr++ = c; + if (c == '\n') + break; + } else if (!rc) { + if (n == 1) + return 0; + else + break; + } + } + *ptr = 0; + return n; +} + +void Server::send(const std::string &s){ + log().log(DEBUG, "Sending:\n"+s+"-----------------\n"); + writen(s.c_str(), s.length()); +} + +bool Server::dataAvailable(){ + int pollret; + struct pollfd mypol; + mypol.fd = sockfd; + mypol.events = POLLERR | POLLHUP | POLLIN; + + pollret = poll(&mypol, 1, pollTimeout); + + if (pollret<0) + throw new StdError(__FUNCTION__, "poll error", strerror(errno)); + + if (!pollret) + return false; + + /* if we get an error, die */ + if (mypol.revents&POLLERR) + throw new StdError(__FUNCTION__, "poll error", strerror(errno)); + + if (mypol.revents&POLLHUP) + throw new StdError(__FUNCTION__, "poll hangup", strerror(errno)); + + if (mypol.revents&POLLIN) + return true; + + return false; +} Added: trunk/apps/CppFCPLib/Server.h =================================================================== --- trunk/apps/CppFCPLib/Server.h (rev 0) +++ trunk/apps/CppFCPLib/Server.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,25 @@ + +#ifndef SERVER_H__ +#define SERVER_H__ + +#include + +namespace FCPLib { + +class Server { + friend class NodeThread; + int sockfd; + Server(std::string &host, int port=-1); +public: + ~Server(); + ssize_t readn(void *vptr, size_t n); + ssize_t readln(void *vptr, size_t maxlen); + ssize_t writen(const void *vptr, size_t n); + void send(const std::string &s); + bool dataAvailable(); +}; + +} + + +#endif Added: trunk/apps/CppFCPLib/TQueue.h =================================================================== --- trunk/apps/CppFCPLib/TQueue.h (rev 0) +++ trunk/apps/CppFCPLib/TQueue.h 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,38 @@ +#ifndef TQUEUE_H__ +#define TQUEUE_H__ + +#include +#include "zthread/Thread.h" +#include "zthread/Condition.h" +#include "zthread/Mutex.h" +#include "zthread/Guard.h" + +namespace FCPLib { + +template class TQueue { + ZThread::Mutex lock; + ZThread::Condition cond; + std::deque data; +public: + TQueue() : cond(lock) {} + void put(T item) { + ZThread::Guard g(lock); + data.push_back(item); + cond.signal(); + } + T get() { + ZThread::Guard g(lock); + while(data.empty()) + cond.wait(); + T returnVal = data.front(); + data.pop_front(); + return returnVal; + } + bool empty() { + ZThread::Guard g(lock); + return data.empty(); + } +}; + +} +#endif Added: trunk/apps/CppFCPLib/main.cpp =================================================================== --- trunk/apps/CppFCPLib/main.cpp (rev 0) +++ trunk/apps/CppFCPLib/main.cpp 2007-06-01 16:56:01 UTC (rev 13446) @@ -0,0 +1,22 @@ +#include +#include +#include "Server.h" +#include "Node.h" + +using namespace std; +using namespace FCPLib; + +int main() +{ +// char line[100]; +// Server s; +// s.send("ClientHello\nName=123\nExpectedVersion=2.0\nEndMessage\n"); +// +// for(;;){ +// s.readln(line, 100); +// cout << line; +// } + + Node("123", "", -1); + return 0; +} From toad at freenetproject.org Fri Jun 1 17:13:16 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 17:13:16 +0000 (UTC) Subject: [freenet-cvs] r13447 - trunk/freenet/src/freenet/clients/http Message-ID: <20070601171316.A27134796D8@emu.freenetproject.org> Author: toad Date: 2007-06-01 17:13:16 +0000 (Fri, 01 Jun 2007) New Revision: 13447 Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java Log: Assume keep-alive if HTTP/1.1. Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java =================================================================== --- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java 2007-06-01 16:56:01 UTC (rev 13446) +++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java 2007-06-01 17:13:16 UTC (rev 13447) @@ -392,7 +392,9 @@ } if(isHTTP10 == true) return true; - return true; + else + // HTTP 1.1 + return false; } static class ParseException extends Exception { From kryptos at freenetproject.org Fri Jun 1 17:16:09 2007 From: kryptos at freenetproject.org (kryptos at freenetproject.org) Date: Fri, 1 Jun 2007 17:16:09 +0000 (UTC) Subject: [freenet-cvs] r13448 - branches Message-ID: <20070601171609.3EF244797E3@emu.freenetproject.org> Author: kryptos Date: 2007-06-01 17:16:09 +0000 (Fri, 01 Jun 2007) New Revision: 13448 Added: branches/freenet-jfk/ Log: Kryptos working on Freenet's link level encryption using JFK Copied: branches/freenet-jfk (from rev 13447, trunk/freenet) From nextgens at freenetproject.org Fri Jun 1 17:30:40 2007 From: nextgens at freenetproject.org (nextgens at freenetproject.org) Date: Fri, 1 Jun 2007 17:30:40 +0000 (UTC) Subject: [freenet-cvs] r13449 - trunk/freenet/src/freenet/l10n Message-ID: <20070601173040.35E7047A0CD@emu.freenetproject.org> Author: nextgens Date: 2007-06-01 17:30:40 +0000 (Fri, 01 Jun 2007) New Revision: 13449 Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.fr.properties Log: l10n: update of french keys by batosai Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.fr.properties =================================================================== --- trunk/freenet/src/freenet/l10n/freenet.l10n.fr.properties 2007-06-01 17:16:09 UTC (rev 13448) +++ trunk/freenet/src/freenet/l10n/freenet.l10n.fr.properties 2007-06-01 17:30:40 UTC (rev 13449) @@ -301,6 +301,28 @@ FetchException.shortError.7=Trop de niveaux de m?ta-donn?es FetchException.shortError.8=Trop de red?marrages FetchException.shortError.9=Trop de r?cursivit? +FirstTimeWizardToadlet.bandwidthLimit=Limites de bande passante +FirstTimeWizardToadlet.bandwidthLimitLong=Veuillez choisir le type et la vitesse de votre connexion dans la liste ci-dessous. +FirstTimeWizardToadlet.chooseNodeName=Vous devez choisir un nom ! +FirstTimeWizardToadlet.chooseNodeNameLong=Veuillez entrer un nom ci dessous. Ce nom ne sera visible que des personnes avec qui vous ?tes connect?. Nous recommandons de mettr un nom ou un pseudo IRC, ainsi que des informations permettant de vous contacter en cas de probl?me ("Thomas Durand ). +FirstTimeWizardToadlet.congratz=Bienvenue ? bord ! +FirstTimeWizardToadlet.congratzLong=F?licitations, la configuration de votre noeud est termin?e. Vous pouvez modifier cette configuration ? tout moment en cliquant sur le lien "Configuration" dans le menu de gauche. Bienvenue sur Freenet. +FirstTimeWizardToadlet.datastoreSize=Taille du store +FirstTimeWizardToadlet.datastoreSizeLong=Veuillez chosir une taille pour votre datastore. Le datastore sert ? stocker les donn?es du r?seau. Plus vous stockez de donn?es, plus vous aidez la communaut? et plus votre noeud sera rapide. +FirstTimeWizardToadlet.homepageTitle=Assistant premiers pas sur Freenet ! +FirstTimeWizardToadlet.iDoTrust=Faire confiance aux personnes connect?s par ${interface} (${ip}) ? +FirstTimeWizardToadlet.isNetworkTrusted=Faire confiance au r?seau local ? +FirstTimeWizardToadlet.isNetworkTrustedLong=Faire confiance au r?seau local ? Si vous r?pondez oui, tous les services de notre noeud seront accessibles depuis ce r?seau. Vous pourrez contr?ler pr?cisemment les droits d'acc?s depuis la page de configuration. +FirstTimeWizardToadlet.noNetworkIF=Pas de carte r?seau suppl?mentaire trouv?e +FirstTimeWizardToadlet.noNetworkIFLong=Freenet n'a pas trouv? d'autre carte r?seau. Il consid?rera que vous vous y connectez seulement depuis votre ordinateur. +FirstTimeWizardToadlet.skipWizard=Je ne suis pas un d?butant, passer l'assistant ! +FirstTimeWizardToadlet.step1Title=Assistant premiers pas sur Freenet ! - Choisissez le nom de votre noeud +FirstTimeWizardToadlet.step2Title=Assistant premiers pas sur Freenet ! - Limites de bande-passante +FirstTimeWizardToadlet.step3Title=Assistant premiers pas sur Freenet ! - Taille du store +FirstTimeWizardToadlet.step4Title=Assistant premiers pas sur Freenet ! - Configuration r?seau +FirstTimeWizardToadlet.step5Title=Assistant premiers pas sur Freenet ! - F?licitations, votre noeud est configur? +FirstTimeWizardToadlet.welcomeInfoboxContent1=Bienvenue dans l'assistant premiers pas sur Freenet . Cet outil vous permettra de configurer rapidement et facilement votre noeud. Veuillez +FirstTimeWizardToadlet.welcomeInfoboxTitle=Bienvenue sur l'assistant premiers pas sur Freenet ! GIFFilter.invalidHeader=Ce fichier ne contient pas d'en-t?te GIF valide. GIFFilter.invalidHeaderTitle=En-t?te invalide GIFFilter.notGif=Ce fichier n'est pas un GIF. Il peut s'agir de n'importe quoi et votre navigateur risque de faire n'importe quoi avec. Nous l'avons donc bloqu?. @@ -343,6 +365,7 @@ InsertException.longError.1=L'appelant a fourni une URI inutilisable " InsertException.longError.10=Annul? par l'utilisateur InsertException.longError.11=Cha?ne en trop (surement un '/') utilis?e dans l'URI +InsertException.longError.12=Erreur de format binaire InsertException.longError.2=Erreur interne : disque plein ou probl?me de permissions ? InsertException.longError.3=Erreur interne InsertException.longError.4=Un noeud sur le trajet retour ne r?pond pas ou est surcharg? @@ -354,6 +377,7 @@ InsertException.shortError.1=URI invalide InsertException.shortError.10=Annul? InsertException.shortError.11=La cl? contient une cha?ne en trop +InsertException.shortError.12=Erreur de format binaire InsertException.shortError.2=Erreur de fichiers temporaires InsertException.shortError.3=Erreur interne InsertException.shortError.4=D?lai d?pass? ou surcharge @@ -491,6 +515,9 @@ NodeClientCore.ignoreTooManyPathComponentsLong=Si activ?, le noeud ne g?n?rera plus d'erreurs TOO_MANY_PATH_COMPONENTS quand on lui soumet une URL avec trop de noms de dossiers ? la fin (/bla/bla/), inutiles pour r?cup?rer la cl? (par exemple, les anciennes CHK avaient souvent des noms de fichiers coll?es ? la fin qui ne faisaient pas partie de l'insertion originale ; ?a ne sert plus ? rien car on peut ajouter le nom de fichier maintenant). N'activez ceci que si vous en avez besoin pour utiliser de vieilles applications ; cette option sera retir?e bient?t. NodeClientCore.lazyResume=Terminer le chargement des requ?tes persistantes apr?s le d?marrage ? (Utilise plus de m?moire) NodeClientCore.lazyResumeLong=Le noeud peut charger les requ?tes persistantes en attente pendant le d?marrage, ou il peut lire les infos en m?moire et relancer les requ?tes apr?s le d?marrage. Le d?marrage est plus rapide mais cela consomme plus de m?moire. +NodeClientCore.maxUSKFetchers=Nombre maximum de r?cup?rateurs d'USK +NodeClientCore.maxUSKFetchersLong=Nombre maximum de r?cup?rateurs d'USK +NodeClientCore.maxUSKFetchersMustBeGreaterThanZero=Doit ?tre sup?rieur ? z?ro NodeClientCore.movingTempDirOnTheFlyNotSupported=D?placer le dossier temporaire ? la vol?e n'est pas possible pour le moment NodeClientCore.persistentTempDir=Dossier pour les fichiers temporaires persistants NodeClientCore.persistentTempDirLong=Dossier o? placer les fichiers temporaires persistants @@ -671,6 +698,7 @@ QueueToadlet.progressbarAccurate=Cette valeur est pr?cise QueueToadlet.progressbarNotAccurate=Cette valeur risque de changer car le traitement du fichier n'est pas termin?e QueueToadlet.reason=Raison +QueueToadlet.remove=Supprimer QueueToadlet.requestNavigation=Parcours des requ?tes QueueToadlet.restart=Red?marrer QueueToadlet.size=Taille @@ -704,6 +732,8 @@ SimpleToadletServer.cssOverrideCantRead=Le fichier CSS personnalis? est introuvable : ${filename} SimpleToadletServer.cssOverrideLong=Ce param?tre vous permet d'utiliser un CSS personnalis?. ATTENTION : les CSS peuvent ?tre dangereux et ne sont pas filtr?s ! Utilisez-le ? vos risques et p?rils. (vous devriez contacter devl at freenetproject pour qu'il soit inclus dans la distribution principale ;) ) SimpleToadletServer.cssOverrideNotInUploads=Vous de pouvez pas configurer ce param?tre : "${filename} n'est pas un r?pertoire d'o? l'upload est autoris? ! +SimpleToadletServer.doRobots=Exclure les robots dans robots.txt ? +SimpleToadletServer.doRobotsLong=Pr?senter un fichier robots.txt disant ? Google, aux spiders et ? wget d'aller voir ailleurs SimpleToadletServer.enableJS=Autoriser FProxy ? utiliser du Javascript ? SimpleToadletServer.enableJSLong=FProxy doit-il utiliser le Javascript ou non. Ce param?tre devrait ?tre sur faux dans la plupart des cas. Les freesites ne pourront pas utiliser de Javascript, m?me si ceci est activ?. SimpleToadletServer.enabled=Activer FProxy ? @@ -761,8 +791,10 @@ TextModeClientInterfaceServer.telnetPortNumberLong=Num?ro de port telnet Toadlet.cancel=Annuler Toadlet.clickHere=Cliquez ici +Toadlet.homepage=Page d'accueil Toadlet.internalErrorPleaseReport=Erreur interne : merci de pr?venir les d?veloppeurs Toadlet.internalErrorTitle=Erreur interne +Toadlet.no=Non Toadlet.nodeHomepage=Page d'accueil Toadlet.notSupportedTitle=Non support? Toadlet.notSupportedWithClass=Votre navigateur a envoy? une requ?te que Freenet (${class}) ne comprend pas. @@ -771,6 +803,7 @@ Toadlet.returnToPrevPage=Retour ? la page pr?c?dente Toadlet.tempRedirectWithReason=Redirection temporaire : ${reason} Toadlet.unauthorized=Vous n'?tes pas autoris? ? acc?der ? cette page. +Toadlet.yes=Oui ToadletContextImpl.cannotParseContentLength=Erreur de content-length : ${error} ToadletContextImpl.headersLineTooLong=L'analyse des en-t?tes a rencontr? une ligne trop longue ToadletContextImpl.methodNotAllowed=La m?thode HTTP n'est pas autoris?e From toad at freenetproject.org Fri Jun 1 17:43:26 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 17:43:26 +0000 (UTC) Subject: [freenet-cvs] r13450 - in trunk/freenet/src/freenet: clients/http node Message-ID: <20070601174326.01E9A47993F@emu.freenetproject.org> Author: toad Date: 2007-06-01 17:43:25 +0000 (Fri, 01 Jun 2007) New Revision: 13450 Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java trunk/freenet/src/freenet/node/PeerNode.java Log: Only queue it if we get a NotConnectedException Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java =================================================================== --- trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 17:30:40 UTC (rev 13449) +++ trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java 2007-06-01 17:43:25 UTC (rev 13450) @@ -10,20 +10,15 @@ import java.util.Iterator; import freenet.client.HighLevelSimpleClient; -import freenet.io.comm.DMT; -import freenet.io.comm.Message; -import freenet.io.comm.NotConnectedException; import freenet.io.comm.UdpSocketManager; import freenet.l10n.L10n; import freenet.node.Node; import freenet.node.NodeClientCore; import freenet.node.PeerManager; import freenet.node.PeerNode; -import freenet.support.Base64; import freenet.support.HTMLNode; import freenet.support.Logger; import freenet.support.MultiValueTable; -import freenet.support.SimpleFieldSet; import freenet.support.api.HTTPRequest; public class N2NTMToadlet extends Toadlet { @@ -158,7 +153,7 @@ PeerNode[] peerNodes = node.getDarknetConnections(); String fnam = request.getPartAsString("filename", 1024); File filename = null; - if(fnam != null) { + if(fnam != null && fnam.length() > 0) { filename = new File(fnam); if(!(filename.exists() && filename.canRead())) { peerTableInfobox.addChild("#", l10n("noSuchFileOrCannotRead")); Modified: trunk/freenet/src/freenet/node/PeerNode.java =================================================================== --- trunk/freenet/src/freenet/node/PeerNode.java 2007-06-01 17:30:40 UTC (rev 13449) +++ trunk/freenet/src/freenet/node/PeerNode.java 2007-06-01 17:43:25 UTC (rev 13450) @@ -3289,25 +3289,19 @@ fs.put("composedTime", now); fs.put("sentTime", now); Message n2ntm; - int status = getPeerNodeStatus(); - if(status == PeerManager.PEER_NODE_STATUS_CONNECTED || - status == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { - n2ntm = DMT.createNodeToNodeMessage( - Node.N2N_MESSAGE_TYPE_FPROXY, fs - .toString().getBytes("UTF-8")); - try { - sendAsync(n2ntm, null, 0, null); - } catch (NotConnectedException e) { - fs.removeValue("sentTime"); - queueN2NTM(fs); - setPeerNodeStatus(System.currentTimeMillis()); - return getPeerNodeStatus(); - } - } else { + n2ntm = DMT.createNodeToNodeMessage( + Node.N2N_MESSAGE_TYPE_FPROXY, fs + .toString().getBytes("UTF-8")); + try { + sendAsync(n2ntm, null, 0, null); + } catch (NotConnectedException e) { fs.removeValue("sentTime"); queueN2NTM(fs); + setPeerNodeStatus(System.currentTimeMillis()); + return getPeerNodeStatus(); } - return status; + this.setPeerNodeStatus(System.currentTimeMillis()); + return getPeerNodeStatus(); } catch (UnsupportedEncodingException e) { throw new Error("Impossible: "+e, e); } @@ -3326,25 +3320,19 @@ fs.put("sentTime", now); fs.put("uid", uid); Message n2ntm; - int status = getPeerNodeStatus(); - if(status == PeerManager.PEER_NODE_STATUS_CONNECTED || - status == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { - n2ntm = DMT.createNodeToNodeMessage( - Node.N2N_MESSAGE_TYPE_FPROXY, fs - .toString().getBytes("UTF-8")); - try { - sendAsync(n2ntm, null, 0, null); - } catch (NotConnectedException e) { - fs.removeValue("sentTime"); - queueN2NTM(fs); - setPeerNodeStatus(System.currentTimeMillis()); - return getPeerNodeStatus(); - } - } else { + n2ntm = DMT.createNodeToNodeMessage( + Node.N2N_MESSAGE_TYPE_FPROXY, fs + .toString().getBytes("UTF-8")); + try { + sendAsync(n2ntm, null, 0, null); + } catch (NotConnectedException e) { fs.removeValue("sentTime"); queueN2NTM(fs); + setPeerNodeStatus(System.currentTimeMillis()); + return getPeerNodeStatus(); } - return status; + this.setPeerNodeStatus(System.currentTimeMillis()); + return getPeerNodeStatus(); } catch (UnsupportedEncodingException e) { throw new Error("Impossible: "+e, e); } @@ -3372,22 +3360,16 @@ fo.toFieldSet(fs); Message n2ntm; int status = getPeerNodeStatus(); - if(status == PeerManager.PEER_NODE_STATUS_CONNECTED || - status == PeerManager.PEER_NODE_STATUS_ROUTING_BACKED_OFF) { - n2ntm = DMT.createNodeToNodeMessage( - Node.N2N_MESSAGE_TYPE_FPROXY, fs - .toString().getBytes("UTF-8")); - try { - sendAsync(n2ntm, null, 0, null); - } catch (NotConnectedException e) { - fs.removeValue("sentTime"); - queueN2NTM(fs); - setPeerNodeStatus(System.currentTimeMillis()); - return getPeerNodeStatus(); - } - } else { + n2ntm = DMT.createNodeToNodeMessage( + Node.N2N_MESSAGE_TYPE_FPROXY, fs + .toString().getBytes("UTF-8")); + try { + sendAsync(n2ntm, null, 0, null); + } catch (NotConnectedException e) { fs.removeValue("sentTime"); queueN2NTM(fs); + setPeerNodeStatus(System.currentTimeMillis()); + return getPeerNodeStatus(); } return status; } catch (UnsupportedEncodingException e) { From toad at freenetproject.org Fri Jun 1 18:25:12 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 18:25:12 +0000 (UTC) Subject: [freenet-cvs] r13451 - trunk/freenet/src/freenet/node Message-ID: <20070601182512.F16C847A2E2@emu.freenetproject.org> Author: toad Date: 2007-06-01 18:25:12 +0000 (Fri, 01 Jun 2007) New Revision: 13451 Modified: trunk/freenet/src/freenet/node/Node.java trunk/freenet/src/freenet/node/PeerNode.java Log: Bugfixes, not there yet... Modified: trunk/freenet/src/freenet/node/Node.java =================================================================== --- trunk/freenet/src/freenet/node/Node.java 2007-06-01 17:43:25 UTC (rev 13450) +++ trunk/freenet/src/freenet/node/Node.java 2007-06-01 18:25:12 UTC (rev 13451) @@ -422,7 +422,7 @@ /** Identifier within fproxy messages for an offer to transfer a file */ public static final int N2N_TEXT_MESSAGE_TYPE_FILE_OFFER = 2; /** Identifier within fproxy messages for accepting an offer to transfer a file */ - public static final int N2N_TEXT_MESSAGE_TYPE_FILE_OFFER_ACCEPTED = 2; + public static final int N2N_TEXT_MESSAGE_TYPE_FILE_OFFER_ACCEPTED = 3; public static final int EXTRA_PEER_DATA_TYPE_N2NTM = 1; public static final int EXTRA_PEER_DATA_TYPE_PEER_NOTE = 2; public static final int EXTRA_PEER_DATA_TYPE_QUEUED_TO_SEND_N2NTM = 3; @@ -2628,10 +2628,10 @@ Logger.error(this, "IOException while parsing node to node message data", e); return; } - if(fs.get("type") != null) { - fs.removeValue("type"); + if(fs.get("n2nType") != null) { + fs.removeValue("n2nType"); } - fs.putOverwrite("type", Integer.toString(type)); + fs.putOverwrite("n2nType", Integer.toString(type)); if(fs.get("receivedTime") != null) { fs.removeValue("receivedTime"); } @@ -2661,7 +2661,10 @@ * @throws FSParseException */ public void handleNodeToNodeTextMessageSimpleFieldSet(SimpleFieldSet fs, PeerNode source, int fileNumber) throws FSParseException { + if(logMINOR) + Logger.minor(this, "Got node to node message: \n"+fs); int overallType = fs.getInt("n2nType", 1); // FIXME remove default + fs.removeValue("n2nType"); if(overallType == Node.N2N_MESSAGE_TYPE_FPROXY) { handleFproxyNodeToNodeTextMessageSimpleFieldSet(fs, source, fileNumber); } else { Modified: trunk/freenet/src/freenet/node/PeerNode.java =================================================================== --- trunk/freenet/src/freenet/node/PeerNode.java 2007-06-01 17:43:25 UTC (rev 13450) +++ trunk/freenet/src/freenet/node/PeerNode.java 2007-06-01 18:25:12 UTC (rev 13451) @@ -3319,6 +3319,8 @@ fs.put("composedTime", now); fs.put("sentTime", now); fs.put("uid", uid); + if(logMINOR) + Logger.minor(this, "Sending node to node message (file offer accepted):\n"+fs); Message n2ntm; n2ntm = DMT.createNodeToNodeMessage( Node.N2N_MESSAGE_TYPE_FPROXY, fs @@ -3358,6 +3360,8 @@ fs.put("composedTime", now); fs.put("sentTime", now); fo.toFieldSet(fs); + if(logMINOR) + Logger.minor(this, "Sending node to node message (file offer):\n"+fs); Message n2ntm; int status = getPeerNodeStatus(); n2ntm = DMT.createNodeToNodeMessage( From toad at freenetproject.org Fri Jun 1 19:25:45 2007 From: toad at freenetproject.org (toad at freenetproject.org) Date: Fri, 1 Jun 2007 19:25:45 +0000 (UTC) Subject: [freenet-cvs] r13452 - in trunk/freenet/src/freenet: io/xfer node support support/io Message-ID: <20070601192545.168DC479F51@emu.freenetproject.org> Author: toad Date: 2007-06-01 19:25:44 +0000 (Fri, 01 Jun 2007) New Revision: 13452 Modified: trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java trunk/freenet/src/freenet/node/PeerNode.java trunk/freenet/src/freenet/support/BitArray.java trunk/freenet/src/freenet/support/ShortBuffer.java trunk/freenet/src/freenet/support/io/FileUtil.java Log: More bugfixes. Maybe working now... Modified: trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java =================================================================== --- trunk/freenet/src/freenet/io/xfer/PartiallyReceivedBulk.java 2007-06-01 18:25:12 UTC (