forked from I2P_Developers/i2p.i2p
merge of '4ae3e891f8510b146feae122bacc862468db060e'
and '666d27bab7047baeaa2c753159098eda75635c5e'
This commit is contained in:
@@ -247,10 +247,15 @@ public class SummaryHelper extends HelperBase {
|
||||
case IPV4_UNKNOWN_IPV6_OK:
|
||||
case IPV4_DISABLED_IPV6_OK:
|
||||
case IPV4_SNAT_IPV6_OK:
|
||||
RouterAddress ra = routerInfo.getTargetAddress("NTCP");
|
||||
if (ra == null)
|
||||
List<RouterAddress> ras = routerInfo.getTargetAddresses("NTCP", "NTCP2");
|
||||
if (ras.isEmpty())
|
||||
return new NetworkStateMessage(NetworkState.RUNNING, _t(status.toStatusString()));
|
||||
byte[] ip = ra.getIP();
|
||||
byte[] ip = null;
|
||||
for (RouterAddress ra : ras) {
|
||||
ip = ra.getIP();
|
||||
if (ip != null)
|
||||
break;
|
||||
}
|
||||
if (ip == null)
|
||||
return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-Unresolved TCP Address"));
|
||||
// TODO set IPv6 arg based on configuration?
|
||||
@@ -287,7 +292,7 @@ public class SummaryHelper extends HelperBase {
|
||||
case IPV4_UNKNOWN_IPV6_FIREWALLED:
|
||||
case IPV4_DISABLED_IPV6_UNKNOWN:
|
||||
default:
|
||||
ra = routerInfo.getTargetAddress("SSU");
|
||||
RouterAddress ra = routerInfo.getTargetAddress("SSU");
|
||||
if (ra == null && _context.router().getUptime() > 5*60*1000) {
|
||||
if (getActivePeers() <= 0)
|
||||
return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-No Active Peers, Check Network Connection and Firewall"));
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
2019-05-02 zzz
|
||||
* GeoIP Maxmind 2019-04-29
|
||||
* NTCP: Rare EventPumper 100% CPU fix (ticket #2476)
|
||||
* UPnP: Remove finalize() in HTTPSocket (ticket #2490)
|
||||
|
||||
2019-04-25 zzz
|
||||
* Build: Drop unmaintained sample apparmor script (ticket #2319)
|
||||
* i2ptunnel: Force connect delay and bulk profile for most
|
||||
client tunnel types, and hide from UI
|
||||
* Transport: Disable NTCP 1 by default
|
||||
|
||||
2019-04-24 zzz
|
||||
|
||||
Binary file not shown.
@@ -18,10 +18,10 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 8;
|
||||
public final static long BUILD = 11;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
public final static String EXTRA = "-rc";
|
||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + FULL_VERSION);
|
||||
|
||||
@@ -268,6 +268,7 @@ class EventPumper implements Runnable {
|
||||
_log.info("Removing invalid key for " + con);
|
||||
// this will cancel the key, and it will then be removed from the keyset
|
||||
con.close();
|
||||
key.cancel();
|
||||
failsafeInvalid++;
|
||||
continue;
|
||||
}
|
||||
@@ -298,6 +299,7 @@ class EventPumper implements Runnable {
|
||||
con.getTimeSinceReceive(now) > expire) {
|
||||
// we haven't sent or received anything in a really long time, so lets just close 'er up
|
||||
con.sendTerminationAndClose();
|
||||
key.cancel();
|
||||
if (_log.shouldInfo())
|
||||
_log.info("Failsafe or expire close for " + con);
|
||||
failsafeCloses++;
|
||||
@@ -536,9 +538,9 @@ class EventPumper implements Runnable {
|
||||
}
|
||||
|
||||
private void processConnect(SelectionKey key) {
|
||||
NTCPConnection con = (NTCPConnection)key.attachment();
|
||||
final NTCPConnection con = (NTCPConnection)key.attachment();
|
||||
final SocketChannel chan = con.getChannel();
|
||||
try {
|
||||
SocketChannel chan = con.getChannel();
|
||||
boolean connected = chan.finishConnect();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("processing connect for " + con + ": connected? " + connected);
|
||||
@@ -587,7 +589,8 @@ class EventPumper implements Runnable {
|
||||
* High-frequency path in thread.
|
||||
*/
|
||||
private void processRead(SelectionKey key) {
|
||||
NTCPConnection con = (NTCPConnection)key.attachment();
|
||||
final NTCPConnection con = (NTCPConnection)key.attachment();
|
||||
final SocketChannel chan = con.getChannel();
|
||||
ByteBuffer buf = null;
|
||||
try {
|
||||
while (true) {
|
||||
@@ -595,7 +598,7 @@ class EventPumper implements Runnable {
|
||||
int read = 0;
|
||||
int readThisTime;
|
||||
int readCount = 0;
|
||||
while ((readThisTime = con.getChannel().read(buf)) > 0) {
|
||||
while ((readThisTime = chan.read(buf)) > 0) {
|
||||
read += readThisTime;
|
||||
readCount++;
|
||||
}
|
||||
@@ -605,7 +608,7 @@ class EventPumper implements Runnable {
|
||||
_log.debug("Read " + read + " bytes total in " + readCount + " times from " + con);
|
||||
if (read < 0) {
|
||||
if (con.isInbound() && con.getMessagesReceived() <= 0) {
|
||||
InetAddress addr = con.getChannel().socket().getInetAddress();
|
||||
InetAddress addr = chan.socket().getInetAddress();
|
||||
int count;
|
||||
if (addr != null) {
|
||||
byte[] ip = addr.getAddress();
|
||||
@@ -685,7 +688,7 @@ class EventPumper implements Runnable {
|
||||
if (buf != null)
|
||||
releaseBuf(buf);
|
||||
if (con.isInbound() && con.getMessagesReceived() <= 0) {
|
||||
InetAddress addr = con.getChannel().socket().getInetAddress();
|
||||
InetAddress addr = chan.socket().getInetAddress();
|
||||
int count;
|
||||
if (addr != null) {
|
||||
byte[] ip = addr.getAddress();
|
||||
@@ -731,7 +734,8 @@ class EventPumper implements Runnable {
|
||||
* High-frequency path in thread.
|
||||
*/
|
||||
private void processWrite(SelectionKey key) {
|
||||
NTCPConnection con = (NTCPConnection)key.attachment();
|
||||
final NTCPConnection con = (NTCPConnection)key.attachment();
|
||||
final SocketChannel chan = con.getChannel();
|
||||
try {
|
||||
while (true) {
|
||||
ByteBuffer buf = con.getNextWriteBuf();
|
||||
@@ -740,7 +744,7 @@ class EventPumper implements Runnable {
|
||||
con.removeWriteBuf(buf);
|
||||
continue;
|
||||
}
|
||||
int written = con.getChannel().write(buf);
|
||||
int written = chan.write(buf);
|
||||
//totalWritten += written;
|
||||
if (written == 0) {
|
||||
if ( (buf.remaining() > 0) || (!con.isWriteBufEmpty()) ) {
|
||||
@@ -845,8 +849,9 @@ class EventPumper implements Runnable {
|
||||
}
|
||||
|
||||
while ((con = _wantsConRegister.poll()) != null) {
|
||||
final SocketChannel schan = con.getChannel();
|
||||
try {
|
||||
SelectionKey key = con.getChannel().register(_selector, SelectionKey.OP_CONNECT);
|
||||
SelectionKey key = schan.register(_selector, SelectionKey.OP_CONNECT);
|
||||
key.attach(con);
|
||||
con.setKey(key);
|
||||
RouterAddress naddr = con.getRemoteAddress();
|
||||
@@ -857,7 +862,7 @@ class EventPumper implements Runnable {
|
||||
if (port <= 0 || ip == null)
|
||||
throw new IOException("Invalid NTCP address: " + naddr);
|
||||
InetSocketAddress saddr = new InetSocketAddress(InetAddress.getByAddress(ip), port);
|
||||
boolean connected = con.getChannel().connect(saddr);
|
||||
boolean connected = schan.connect(saddr);
|
||||
if (connected) {
|
||||
// Never happens, we use nonblocking
|
||||
key.interestOps(SelectionKey.OP_READ);
|
||||
|
||||
@@ -288,14 +288,14 @@ public class NTCPConnection implements Closeable {
|
||||
/**
|
||||
* Valid for inbound; valid for outbound shortly after creation
|
||||
*/
|
||||
public SocketChannel getChannel() { return _chan; }
|
||||
public synchronized SocketChannel getChannel() { return _chan; }
|
||||
|
||||
/**
|
||||
* Valid for inbound; valid for outbound shortly after creation
|
||||
*/
|
||||
public SelectionKey getKey() { return _conKey; }
|
||||
public void setChannel(SocketChannel chan) { _chan = chan; }
|
||||
public void setKey(SelectionKey key) { _conKey = key; }
|
||||
public synchronized SelectionKey getKey() { return _conKey; }
|
||||
public synchronized void setChannel(SocketChannel chan) { _chan = chan; }
|
||||
public synchronized void setKey(SelectionKey key) { _conKey = key; }
|
||||
|
||||
public boolean isInbound() { return _isInbound; }
|
||||
public boolean isEstablished() { return _establishState.isComplete(); }
|
||||
@@ -1125,7 +1125,12 @@ public class NTCPConnection implements Closeable {
|
||||
* async callback after the outbound connection was completed (this should NOT block,
|
||||
* as it occurs in the selector thread)
|
||||
*/
|
||||
void outboundConnected() {
|
||||
synchronized void outboundConnected() {
|
||||
if (_establishState == EstablishBase.FAILED) {
|
||||
_conKey.cancel();
|
||||
try {_chan.close(); } catch (IOException ignored) {}
|
||||
return;
|
||||
}
|
||||
_conKey.interestOps(_conKey.interestOps() | SelectionKey.OP_READ);
|
||||
// schedule up the beginning of our handshaking by calling prepareNextWrite on the
|
||||
// writer thread pool
|
||||
|
||||
@@ -40,15 +40,18 @@ public class HTTPServerThread extends Thread
|
||||
public void run()
|
||||
{
|
||||
HTTPSocket httpSock = new HTTPSocket(sock);
|
||||
if (httpSock.open() == false)
|
||||
return;
|
||||
HTTPRequest httpReq = new HTTPRequest();
|
||||
httpReq.setSocket(httpSock);
|
||||
while (httpReq.read() == true) {
|
||||
httpServer.performRequestListener(httpReq);
|
||||
if (httpReq.isKeepAlive() == false)
|
||||
break;
|
||||
try {
|
||||
if (httpSock.open() == false)
|
||||
return;
|
||||
HTTPRequest httpReq = new HTTPRequest();
|
||||
httpReq.setSocket(httpSock);
|
||||
while (httpReq.read() == true) {
|
||||
httpServer.performRequestListener(httpReq);
|
||||
if (httpReq.isKeepAlive() == false)
|
||||
break;
|
||||
}
|
||||
} finally {
|
||||
httpSock.close();
|
||||
}
|
||||
httpSock.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
package org.cybergarage.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
@@ -51,11 +52,6 @@ public class HTTPSocket
|
||||
setOutputStream(socket.getOutputStream());
|
||||
}
|
||||
|
||||
public void finalize()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Socket
|
||||
////////////////////////////////////////////////
|
||||
@@ -133,17 +129,18 @@ public class HTTPSocket
|
||||
|
||||
public boolean close()
|
||||
{
|
||||
try {
|
||||
if (sockIn != null)
|
||||
if (sockIn != null)
|
||||
try {
|
||||
sockIn.close();
|
||||
if (sockOut != null)
|
||||
} catch (IOException e) {}
|
||||
if (sockOut != null)
|
||||
try {
|
||||
sockOut.close();
|
||||
getSocket().close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
//Debug.warning(e);
|
||||
return false;
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
if (socket != null)
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user