forked from I2P_Developers/i2p.i2p
SAM:
- Don't map keys to upper case in parser, corrupts I2CP options - Register SSL and UDP ports with PortMapper
This commit is contained in:
@ -709,7 +709,9 @@ public class SAMBridge implements Runnable, ClientApp {
|
||||
changeState(RUNNING);
|
||||
if (_mgr != null)
|
||||
_mgr.register(this);
|
||||
I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_SAM, _listenPort);
|
||||
I2PAppContext.getGlobalContext().portMapper().register(_useSSL ? PortMapper.SVC_SAM_SSL : PortMapper.SVC_SAM,
|
||||
_listenHost != null ? _listenHost : "127.0.0.1",
|
||||
_listenPort);
|
||||
try {
|
||||
while (acceptConnections) {
|
||||
SocketChannel s = serverSocket.accept();
|
||||
@ -775,7 +777,7 @@ public class SAMBridge implements Runnable, ClientApp {
|
||||
if (serverSocket != null)
|
||||
serverSocket.close();
|
||||
} catch (IOException e) {}
|
||||
I2PAppContext.getGlobalContext().portMapper().unregister(PortMapper.SVC_SAM);
|
||||
I2PAppContext.getGlobalContext().portMapper().unregister(_useSSL ? PortMapper.SVC_SAM_SSL : PortMapper.SVC_SAM);
|
||||
stopHandlers();
|
||||
changeState(STOPPED);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class SAMUtils {
|
||||
* Parse SAM parameters, and put them into a Propetries object
|
||||
*
|
||||
* Modified from EepGet.
|
||||
* All keys, major, and minor are mapped to upper case.
|
||||
* COMMAND and OPCODE are mapped to upper case; keys, values, and ping data are not.
|
||||
* Double quotes around values are stripped.
|
||||
*
|
||||
* Possible input:
|
||||
@ -241,8 +241,9 @@ class SAMUtils {
|
||||
key = null;
|
||||
} else if (buf.length() > 0) {
|
||||
// key without value
|
||||
String k = buf.toString().trim().toUpperCase(Locale.US);
|
||||
String k = buf.toString();
|
||||
if (rv.isEmpty()) {
|
||||
k = k.toUpperCase(Locale.US);
|
||||
rv.setProperty(COMMAND, k);
|
||||
if (k.equals("PING") || k.equals("PONG")) {
|
||||
// eat the rest of the line
|
||||
@ -254,7 +255,7 @@ class SAMUtils {
|
||||
i = length + 1;
|
||||
}
|
||||
} else if (rv.size() == 1) {
|
||||
rv.setProperty(OPCODE, k);
|
||||
rv.setProperty(OPCODE, k.toUpperCase(Locale.US));
|
||||
} else {
|
||||
if (rv.setProperty(k, "true") != null)
|
||||
throw new SAMException("Duplicate parameter " + k);
|
||||
@ -273,7 +274,7 @@ class SAMUtils {
|
||||
} else {
|
||||
if (buf.length() == 0)
|
||||
throw new SAMException("Empty parameter name");
|
||||
key = buf.toString().toUpperCase(Locale.US);
|
||||
key = buf.toString();
|
||||
buf.setLength(0);
|
||||
}
|
||||
break;
|
||||
|
@ -24,6 +24,7 @@ import net.i2p.client.I2PSession;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.PortMapper;
|
||||
|
||||
/**
|
||||
* This is the thread listening on 127.0.0.1:7655 or as specified by
|
||||
@ -90,7 +91,7 @@ class SAMv3DatagramServer implements Handler {
|
||||
/** @since 0.9.24 */
|
||||
public int getPort() { return _port; }
|
||||
|
||||
private static class Listener implements Runnable {
|
||||
private class Listener implements Runnable {
|
||||
|
||||
private final DatagramChannel server;
|
||||
|
||||
@ -98,8 +99,17 @@ class SAMv3DatagramServer implements Handler {
|
||||
{
|
||||
this.server = server ;
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
|
||||
public void run() {
|
||||
I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_SAM_UDP, _host, _port);
|
||||
try {
|
||||
run2();
|
||||
} finally {
|
||||
I2PAppContext.getGlobalContext().portMapper().unregister(PortMapper.SVC_SAM_UDP);
|
||||
}
|
||||
}
|
||||
|
||||
private void run2() {
|
||||
ByteBuffer inBuf = ByteBuffer.allocateDirect(SAMRawSession.RAW_SIZE_MAX+1024);
|
||||
|
||||
while (!Thread.interrupted())
|
||||
|
@ -69,7 +69,7 @@ public class SAMStreamSend {
|
||||
String port = "7656";
|
||||
String user = null;
|
||||
String password = null;
|
||||
String opts = "";
|
||||
String opts = "inbound.length=0 outbound.length=0";
|
||||
int c;
|
||||
while ((c = g.getopt()) != -1) {
|
||||
switch (c) {
|
||||
|
@ -77,7 +77,7 @@ public class SAMStreamSink {
|
||||
String port = "7656";
|
||||
String user = null;
|
||||
String password = null;
|
||||
String opts = "";
|
||||
String opts = "inbound.length=0 outbound.length=0";
|
||||
int c;
|
||||
while ((c = g.getopt()) != -1) {
|
||||
switch (c) {
|
||||
|
Reference in New Issue
Block a user