* I2PTunnelUDPClientBase: Fix client close, client target host

* I2CP Mux: Fix UDP sends
This commit is contained in:
zzz
2009-02-27 21:24:40 +00:00
parent 6648e182ae
commit 3733b78ccf
8 changed files with 22 additions and 18 deletions

View File

@ -213,8 +213,15 @@ public class TunnelController implements Logging {
_tunnel.runStreamrClient(new String[] { targetHost, targetPort, dest }, this); _tunnel.runStreamrClient(new String[] { targetHost, targetPort, dest }, this);
} }
/** Streamr server is a UDP client, use the targetPort field for listenPort */ /**
* Streamr server is a UDP client, use the targetPort field for listenPort
* and the targetHost field for the listenOnInterface
*/
private void startStreamrServer() { private void startStreamrServer() {
String listenOn = getTargetHost();
if ( (listenOn != null) && (listenOn.length() > 0) ) {
_tunnel.runListenOn(new String[] { listenOn }, this);
}
String listenPort = getTargetPort(); String listenPort = getTargetPort();
String privKeyFile = getPrivKeyFile(); String privKeyFile = getPrivKeyFile();
_tunnel.runStreamrServer(new String[] { listenPort, privKeyFile }, this); _tunnel.runStreamrServer(new String[] { listenPort, privKeyFile }, this);

View File

@ -42,6 +42,7 @@ public class StreamrConsumer extends I2PTunnelUDPClientBase {
super.startRunning(); super.startRunning();
// send subscribe-message // send subscribe-message
this.pinger.start(); this.pinger.start();
l.log("Streamr client ready");
} }
public boolean close(boolean forced) { public boolean close(boolean forced) {

View File

@ -48,6 +48,7 @@ public class StreamrProducer extends I2PTunnelUDPServerBase {
public final void startRunning() { public final void startRunning() {
super.startRunning(); super.startRunning();
this.server.start(); this.server.start();
l.log("Streamr server ready");
} }
public boolean close(boolean forced) { public boolean close(boolean forced) {

View File

@ -27,6 +27,7 @@ public class I2PSinkAnywhere implements Sink {
this.raw = raw; this.raw = raw;
// create maker // create maker
if (!raw)
this.maker = new I2PDatagramMaker(this.sess); this.maker = new I2PDatagramMaker(this.sess);
} }

View File

@ -141,9 +141,6 @@ public abstract class I2PTunnelUDPClientBase extends I2PTunnelTask implements So
} else { } else {
_i2pSink = new I2PSinkAnywhere(_session, false); _i2pSink = new I2PSinkAnywhere(_session, false);
} }
//configurePool(tunnel);
} }
/** /**
@ -165,13 +162,7 @@ public abstract class I2PTunnelUDPClientBase extends I2PTunnelTask implements So
startRunning = true; startRunning = true;
startLock.notify(); startLock.notify();
} }
open = true;
if (open && listenerReady) {
notifyEvent("openBaseClientResult", "ok");
} else {
l.log("Error listening - please see the logs!");
notifyEvent("openBaseClientResult", "error");
}
} }
/** /**
@ -187,6 +178,7 @@ public abstract class I2PTunnelUDPClientBase extends I2PTunnelTask implements So
} catch (I2PSessionException ise) {} } catch (I2PSessionException ise) {}
} }
l.log("Closing client " + toString()); l.log("Closing client " + toString());
open = false;
return true; return true;
} }

View File

@ -41,7 +41,7 @@ public class I2PTunnelUDPServerBase extends I2PTunnelTask implements Source, Sin
private static volatile long __serverId = 0; private static volatile long __serverId = 0;
private Logging l; protected Logging l;
private static final long DEFAULT_READ_TIMEOUT = -1; // 3*60*1000; private static final long DEFAULT_READ_TIMEOUT = -1; // 3*60*1000;
/** default timeout to 3 minutes - override if desired */ /** default timeout to 3 minutes - override if desired */
@ -137,7 +137,6 @@ public class I2PTunnelUDPServerBase extends I2PTunnelTask implements Source, Sin
start(); start();
//} //}
l.log("Ready!");
notifyEvent("openServerResult", "ok"); notifyEvent("openServerResult", "ok");
open = true; open = true;
} }

View File

@ -88,14 +88,16 @@
<label>Target:</label> <label>Target:</label>
<% } %> <% } %>
</div> </div>
<% if (!"streamrserver".equals(tunnelType)) { %>
<div id="hostField" class="rowItem"> <div id="hostField" class="rowItem">
<label for="targetHost" accesskey="H"> <label for="targetHost" accesskey="H">
<% if ("streamrserver".equals(tunnelType)) { %>
<span class="accessKey">R</span>eachable by:
<% } else { %>
<span class="accessKey">H</span>ost: <span class="accessKey">H</span>ost:
<% } %>
</label> </label>
<input type="text" size="20" id="targetHost" name="targetHost" title="Target Hostname or IP" value="<%=editBean.getTargetHost(curTunnel)%>" class="freetext" /> <input type="text" size="20" id="targetHost" name="targetHost" title="Target Hostname or IP" value="<%=editBean.getTargetHost(curTunnel)%>" class="freetext" />
</div> </div>
<% } // !streamrserver %>
<div id="portField" class="rowItem"> <div id="portField" class="rowItem">
<label for="targetPort" accesskey="P"> <label for="targetPort" accesskey="P">
<span class="accessKey">P</span>ort: <span class="accessKey">P</span>ort:

View File

@ -118,12 +118,13 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 implements I2PSession {
@Override @Override
public boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException { public boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException {
return sendMessage(dest, payload, 0, 0, null, null, 0, PROTO_UNSPECIFIED, PORT_UNSPECIFIED, PORT_UNSPECIFIED); return sendMessage(dest, payload, 0, payload.length, null, null,
0, PROTO_UNSPECIFIED, PORT_UNSPECIFIED, PORT_UNSPECIFIED);
} }
@Override @Override
public boolean sendMessage(Destination dest, byte[] payload, int proto, int fromport, int toport) throws I2PSessionException { public boolean sendMessage(Destination dest, byte[] payload, int proto, int fromport, int toport) throws I2PSessionException {
return sendMessage(dest, payload, 0, 0, null, null, 0, proto, fromport, toport); return sendMessage(dest, payload, 0, payload.length, null, null, 0, proto, fromport, toport);
} }
@Override @Override