mirror of https://github.com/zlatinb/muwire
connect more aggressively, send more pongs, fix destination parsing and header check
parent
4e09b4ad71
commit
837b8d8213
|
@ -35,7 +35,7 @@ abstract class Connection implements Closeable {
|
||||||
private static final long INTERVAL = 1000
|
private static final long INTERVAL = 1000
|
||||||
|
|
||||||
private static final MAX_PONGS_V1 = 2
|
private static final MAX_PONGS_V1 = 2
|
||||||
private static final MAX_PONGS_V2 = 3
|
private static final MAX_PONGS_V2 = 4
|
||||||
|
|
||||||
final EventBus eventBus
|
final EventBus eventBus
|
||||||
final Endpoint endpoint
|
final Endpoint endpoint
|
||||||
|
|
|
@ -23,7 +23,7 @@ import net.i2p.util.ConcurrentHashSet
|
||||||
@Log
|
@Log
|
||||||
class ConnectionEstablisher {
|
class ConnectionEstablisher {
|
||||||
|
|
||||||
private static final int CONCURRENT = 4
|
private static final int CONCURRENT = 8
|
||||||
|
|
||||||
final EventBus eventBus
|
final EventBus eventBus
|
||||||
final I2PConnector i2pConnector
|
final I2PConnector i2pConnector
|
||||||
|
|
|
@ -51,7 +51,7 @@ class MessageUtil {
|
||||||
byte count = dis.readByte()
|
byte count = dis.readByte()
|
||||||
List<Destination> destinations = new ArrayList<>(count)
|
List<Destination> destinations = new ArrayList<>(count)
|
||||||
count.times {
|
count.times {
|
||||||
destinations << Destination.create(dis)
|
destinations << Destination.create(dis).toBase64()
|
||||||
}
|
}
|
||||||
rv.pongs = destinations
|
rv.pongs = destinations
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class PeerConnection extends Connection {
|
||||||
protected void read() {
|
protected void read() {
|
||||||
dis.readFully(readHeader)
|
dis.readFully(readHeader)
|
||||||
int length = DataUtil.readLength(readHeader)
|
int length = DataUtil.readLength(readHeader)
|
||||||
log.fine("$name read length $length")
|
log.fine("$name read length $length read header ${readHeader[0]}")
|
||||||
|
|
||||||
if (length > MAX_PAYLOAD_SIZE)
|
if (length > MAX_PAYLOAD_SIZE)
|
||||||
throw new Exception("Rejecting large message $length")
|
throw new Exception("Rejecting large message $length")
|
||||||
|
@ -52,7 +52,7 @@ class PeerConnection extends Connection {
|
||||||
dis.readFully(payload)
|
dis.readFully(payload)
|
||||||
|
|
||||||
def json
|
def json
|
||||||
if ((readHeader[0] & (byte)0x80) == 0x80) {
|
if ((readHeader[0] & (byte)0x80) == (byte)0x80) {
|
||||||
json = MessageUtil.parseBinaryMessage(payload)
|
json = MessageUtil.parseBinaryMessage(payload)
|
||||||
} else {
|
} else {
|
||||||
json = slurper.parse(payload)
|
json = slurper.parse(payload)
|
||||||
|
|
Loading…
Reference in New Issue