Search in sources :

Example 16 with LogEvent

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"));
            }
        }
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent)

Example 17 with LogEvent

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);
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) InetSocketAddress(java.net.InetSocketAddress) ProtocolEndpoint(com.biglybt.core.networkmanager.ProtocolEndpoint) ConnectionEndpoint(com.biglybt.core.networkmanager.ConnectionEndpoint)

Example 18 with LogEvent

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);
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) ProtocolEndpoint(com.biglybt.core.networkmanager.ProtocolEndpoint) ConnectionEndpoint(com.biglybt.core.networkmanager.ConnectionEndpoint)

Example 19 with LogEvent

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));
        }
    }
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent)

Example 20 with LogEvent

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);
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent)

Aggregations

LogEvent (com.biglybt.core.logging.LogEvent)172 LogAlert (com.biglybt.core.logging.LogAlert)20 IOException (java.io.IOException)14 File (java.io.File)11 URL (java.net.URL)11 ArrayList (java.util.ArrayList)9 InetSocketAddress (java.net.InetSocketAddress)8 InputStream (java.io.InputStream)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 ZipInputStream (java.util.zip.ZipInputStream)7 CacheFileManagerException (com.biglybt.core.diskmanager.cache.CacheFileManagerException)6 TOTorrent (com.biglybt.core.torrent.TOTorrent)6 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)6 ResourceDownloader (com.biglybt.pif.utils.resourcedownloader.ResourceDownloader)6 UIFunctions (com.biglybt.ui.UIFunctions)6 SocketChannel (java.nio.channels.SocketChannel)6 Iterator (java.util.Iterator)6 ConnectionEndpoint (com.biglybt.core.networkmanager.ConnectionEndpoint)5 ClientIDException (com.biglybt.pif.clientid.ClientIDException)5 ParameterListener (com.biglybt.core.config.ParameterListener)4