Search in sources :

Example 1 with ClientInstanceTracked

use of com.biglybt.core.instancemanager.ClientInstanceTracked in project BiglyBT by BiglySoftware.

the class NetworkAdminImpl method runInitialChecks.

@Override
public void runInitialChecks(Core core) {
    ClientInstanceManager i_man = core.getInstanceManager();
    final ClientInstance my_instance = i_man.getMyInstance();
    i_man.addListener(new ClientInstanceManagerListener() {

        private InetAddress external_address;

        @Override
        public void instanceFound(ClientInstance instance) {
        }

        @Override
        public void instanceChanged(ClientInstance instance) {
            if (instance == my_instance) {
                InetAddress address = instance.getExternalAddress();
                if (external_address == null || !external_address.equals(address)) {
                    external_address = address;
                    try {
                        lookupCurrentASN(address);
                    } catch (Throwable e) {
                        Debug.printStackTrace(e);
                    }
                }
            }
        }

        @Override
        public void instanceLost(ClientInstance instance) {
        }

        @Override
        public void instanceTracked(ClientInstanceTracked instance) {
        }
    });
    if (COConfigurationManager.getBooleanParameter("Proxy.Check.On.Start")) {
        NetworkAdminSocksProxy[] socks = getSocksProxies();
        for (int i = 0; i < socks.length; i++) {
            NetworkAdminSocksProxy sock = socks[i];
            try {
                sock.getVersionsSupported();
            } catch (Throwable e) {
                Debug.printStackTrace(e);
                Logger.log(new LogAlert(true, LogAlert.AT_WARNING, "Socks proxy " + sock.getName() + " check failed: " + Debug.getNestedExceptionMessage(e)));
            }
        }
        NetworkAdminHTTPProxy http_proxy = getHTTPProxy();
        if (http_proxy != null) {
            try {
                http_proxy.getDetails();
            } catch (Throwable e) {
                Debug.printStackTrace(e);
                Logger.log(new LogAlert(true, LogAlert.AT_WARNING, "HTTP proxy " + http_proxy.getName() + " check failed: " + Debug.getNestedExceptionMessage(e)));
            }
        }
    }
    if (COConfigurationManager.getBooleanParameter("Check Bind IP On Start")) {
        checkBindAddresses(true);
    }
    NetworkAdminSpeedTestScheduler nast = NetworkAdminSpeedTestSchedulerImpl.getInstance();
    nast.initialise();
}
Also used : ClientInstanceManagerListener(com.biglybt.core.instancemanager.ClientInstanceManagerListener) ClientInstanceTracked(com.biglybt.core.instancemanager.ClientInstanceTracked) ClientInstance(com.biglybt.core.instancemanager.ClientInstance) LogAlert(com.biglybt.core.logging.LogAlert) ClientInstanceManager(com.biglybt.core.instancemanager.ClientInstanceManager)

Aggregations

ClientInstance (com.biglybt.core.instancemanager.ClientInstance)1 ClientInstanceManager (com.biglybt.core.instancemanager.ClientInstanceManager)1 ClientInstanceManagerListener (com.biglybt.core.instancemanager.ClientInstanceManagerListener)1 ClientInstanceTracked (com.biglybt.core.instancemanager.ClientInstanceTracked)1 LogAlert (com.biglybt.core.logging.LogAlert)1