public static boolean isPlatformHost(String host) { Object[] domains = getPlatformHosts().toArray(); host = host.toLowerCase(); for (int i = 0; i < domains.length; i++) { String domain = (String) domains[i]; if (domain.equals(host)) { return (true); } if (host.endsWith("." + domain)) { return (true); } } if (Constants.isCVSVersion()) { // allow local addresses for testing try { InetAddress ia = InetAddress.getByName(host); return (ia.isLoopbackAddress() || ia.isLinkLocalAddress() || ia.isSiteLocalAddress()); } catch (Throwable e) { } } return (false); }
protected void addDropTest(MdiEntry entry) { if (!Constants.isCVSVersion()) { return; } entry.addListener( new MdiEntryDropListener() { public boolean mdiEntryDrop(MdiEntry entry, Object droppedObject) { String s = "You just dropped " + droppedObject.getClass() + "\n" + droppedObject + "\n\n"; if (droppedObject.getClass().isArray()) { Object[] o = (Object[]) droppedObject; for (int i = 0; i < o.length; i++) { s += "" + i + ": "; Object object = o[i]; if (object == null) { s += "null"; } else { s += object.getClass() + ";" + object; } s += "\n"; } } new MessageBoxShell(SWT.OK, "test", s).open(null); return true; } }); }
public SpeedManagerImpl(AzureusCore _core, SpeedManagerAdapter _adapter) { core = _core; adapter = _adapter; AEDiagnostics.addEvidenceGenerator(this); logger = AEDiagnostics.getLogger("SpeedMan"); ping_mapper = new SpeedManagerPingMapperImpl(this, "Var", LONG_PERIOD_TICKS, true, false); if (Constants.isCVSVersion()) { SpeedManagerPingMapperImpl pm2 = new SpeedManagerPingMapperImpl(this, "Abs", LONG_PERIOD_TICKS, false, false); ping_mappers = new SpeedManagerPingMapperImpl[] {pm2, ping_mapper}; } else { ping_mappers = new SpeedManagerPingMapperImpl[] {ping_mapper}; } final File config_dir = new File(SystemProperties.getUserPath(), "net"); if (!config_dir.exists()) { config_dir.mkdirs(); } NetworkAdmin.getSingleton() .addAndFirePropertyChangeListener( new NetworkAdminPropertyChangeListener() { public void propertyChanged(String property) { if (property == NetworkAdmin.PR_AS) { NetworkAdminASN net_asn = NetworkAdmin.getSingleton().getCurrentASN(); String as = net_asn.getAS(); if (as.length() == 0) { as = "default"; } File history = new File(config_dir, "pm_" + FileUtil.convertOSSpecificChars(as) + ".dat"); ping_mapper.loadHistory(history); asn = net_asn.getASName(); if (asn.length() == 0) { asn = "Unknown"; } informListeners(SpeedManagerListener.PR_ASN); } } }); core.addLifecycleListener( new AzureusCoreLifecycleAdapter() { public void stopping(AzureusCore core) { ping_mapper.saveHistory(); } }); COConfigurationManager.addAndFireParameterListener( CONFIG_VERSION, new ParameterListener() { public void parameterChanged(final String name) { dispatcher.dispatch( new AERunnable() { public void runSupport() { boolean do_reset = provider_version == -1; int version = COConfigurationManager.getIntParameter(name); if (version != provider_version) { provider_version = version; if (isEnabled()) { setEnabledSupport(false); setEnabledSupport(true); } } if (do_reset) { enableOrAlgChanged(); } } }); } }); COConfigurationManager.setParameter(CONFIG_AVAIL, false); SimpleTimer.addPeriodicEvent( "SpeedManager:timer", UPDATE_PERIOD_MILLIS, new TimerEventPerformer() { private int tick_count; public void perform(TimerEvent event) { // if enabled the ping stream drives the stats update for the ping mappers // When not enabled we do it here instead if (!enabled || contacts_array.length == 0) { int x = (adapter.getCurrentDataUploadSpeed(SPEED_AVERAGE_PERIOD) + adapter.getCurrentProtocolUploadSpeed(SPEED_AVERAGE_PERIOD)); int y = (adapter.getCurrentDataDownloadSpeed(SPEED_AVERAGE_PERIOD) + adapter.getCurrentProtocolDownloadSpeed(SPEED_AVERAGE_PERIOD)); for (int i = 0; i < ping_mappers.length; i++) { ping_mappers[i].addSpeed(x, y); } } tick_count++; if (tick_count % SAVE_PERIOD_TICKS == 0) { ping_mapper.saveHistory(); } } }); emulated_ping_source = false; if (emulated_ping_source) { Debug.out("Emulated ping source!!!!"); setSpeedTester(new TestPingSourceRandom(this)); } }