use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UDPConnectionManager method failed.
public void failed(UDPConnectionSet set) {
synchronized (connection_sets) {
String key = set.getKey();
if (connection_sets.remove(key) != null) {
set.removed();
recently_dead_keys.put(key, new Long(SystemTime.getCurrentTime()));
if (Logger.isEnabled()) {
Logger.log(new LogEvent(LOGID, "Connection set " + key + " failed"));
}
}
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UDPConnectionManager method registerOutgoing.
protected UDPConnection registerOutgoing(UDPTransportHelper helper) throws IOException {
int local_port = UDPNetworkManager.getSingleton().getUDPListeningPortNumber();
InetSocketAddress address = helper.getAddress();
String key = local_port + ":" + address.getAddress().getHostAddress() + ":" + address.getPort();
synchronized (connection_sets) {
UDPSelector current_selector = checkThreadCreation();
UDPConnectionSet connection_set = (UDPConnectionSet) connection_sets.get(key);
if (connection_set == null) {
timeoutDeadKeys();
connection_set = new UDPConnectionSet(this, key, current_selector, local_port, address);
if (Logger.isEnabled()) {
Logger.log(new LogEvent(LOGID, "Created new set - " + connection_set.getName() + ", outgoing"));
}
connection_sets.put(key, connection_set);
}
UDPConnection connection = new UDPConnection(connection_set, allocationConnectionID(), helper);
connection_set.add(connection);
return (connection);
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UDPConnectionManager method rateLimitIncoming.
protected boolean rateLimitIncoming(InetSocketAddress s_address) {
long now = SystemTime.getCurrentTime();
byte[] address = s_address.getAddress().getAddress();
long delay;
synchronized (this) {
int hit_count = incoming_bloom.add(address);
if (incoming_bloom.getSize() / incoming_bloom.getEntryCount() < 10) {
incoming_bloom = BloomFilterFactory.createAddRemove4Bit(incoming_bloom.getSize() + BLOOM_INCREASE);
incoming_bloom_create_time = now;
Logger.log(new LogEvent(LOGID, "UDP connnection bloom: size increased to " + incoming_bloom.getSize()));
} else if (now < incoming_bloom_create_time || now - incoming_bloom_create_time > BLOOM_RECREATE) {
incoming_bloom = BloomFilterFactory.createAddRemove4Bit(incoming_bloom.getSize());
incoming_bloom_create_time = now;
}
if (hit_count >= 15) {
Logger.log(new LogEvent(LOGID, "UDP incoming: too many recent connection attempts from " + s_address));
return (false);
}
long since_last = now - last_incoming;
delay = 100 - since_last;
last_incoming = now;
}
if (delay > 0 && delay < 100) {
try {
Thread.sleep(delay);
} catch (Throwable e) {
}
}
return (true);
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class UDPConnectionSet method logStats.
protected void logStats() {
if (Logger.isEnabled()) {
synchronized (this) {
String str = "sent: tot=" + total_packets_sent + ",uni=" + total_packets_unique_sent + ",ds=" + total_data_sent + ",dr=" + total_data_resent + ",ps=" + total_protocol_sent + ",pr=" + total_protocol_resent + ",rt=" + total_packets_resent_via_timer + ",ra=" + total_packets_resent_via_ack;
str += " recv: tot=" + total_packets_received + ",uni=" + total_packets_unique_received + ",du=" + total_packets_duplicates + ",oo=" + total_packets_out_of_order;
str += " timer=" + current_timer_base + ",adj=" + timer_is_adjusting;
Logger.log(new LogEvent(LOGID, "UDP " + getName() + " - " + str));
}
}
}
use of com.biglybt.core.logging.LogEvent in project BiglyBT by BiglySoftware.
the class ProtocolDecoderInitial method isComplete.
@Override
public boolean isComplete(long now) {
if (transport == null) {
return (false);
}
if (!processing_complete) {
if (start_time > now) {
start_time = now;
}
if (last_read_time > now) {
last_read_time = now;
}
if (phe_decoder != null) {
last_read_time = phe_decoder.getLastReadTime();
}
long timeout;
long time;
if (last_read_time == 0) {
timeout = transport.getConnectTimeout();
time = start_time;
} else {
timeout = transport.getReadTimeout();
time = last_read_time;
}
if (now - time > timeout) {
try {
transport.cancelReadSelects();
transport.cancelWriteSelects();
} catch (Throwable e) {
}
String phe_str = "";
if (phe_decoder != null) {
phe_str = ", crypto: " + phe_decoder.getString();
}
if (Logger.isEnabled()) {
Logger.log(new LogEvent(LOGID, "Connection [" + transport.getAddress() + "] forcibly timed out after " + timeout / 1000 + "sec due to socket inactivity"));
}
failed(new Throwable("Protocol decode aborted: timed out after " + timeout / 1000 + "sec: " + decode_read + " bytes read" + phe_str));
}
}
return (processing_complete);
}
Aggregations