/** * Get the registered port for a service * @return -1 if not registered */ public int getPort(String service) { int port = getPort(service, -1); return port; }
/** * Remove the service, * only if it is registered with the supplied port. * * @since 0.9.34 */ public void unregister(String service, int port) { // not synched if (getPort(service) == port) _dir.remove(service); }
/** * @return https URL unless console is http only. Default http://127.0.0.1:7657/ * @since 0.9.34 */ private String getHTTPSConsoleURL() { String unset = "*unset*"; String httpHost = getActualHost(SVC_CONSOLE, unset); String httpsHost = getActualHost(SVC_HTTPS_CONSOLE, unset); int httpPort = getPort(SVC_CONSOLE); int httpsPort = getPort(SVC_HTTPS_CONSOLE, DEFAULT_HTTPS_CONSOLE_PORT); boolean httpOnly = httpPort > 0 && httpsHost.equals(unset) && !httpHost.equals(unset); if (httpOnly) return "http://" + httpHost + ':' + httpPort + '/'; if (httpsHost.equals(unset)) return "http://" + DEFAULT_HOST + ':' + DEFAULT_CONSOLE_PORT + '/'; return "https://" + httpsHost + ':' + httpsPort + '/'; }
/** * @return http URL unless console is https only. Default http://127.0.0.1:7657/ */ private String getHTTPConsoleURL() { String unset = "*unset*"; String httpHost = getActualHost(SVC_CONSOLE, unset); String httpsHost = getActualHost(SVC_HTTPS_CONSOLE, unset); int httpPort = getPort(SVC_CONSOLE, DEFAULT_CONSOLE_PORT); int httpsPort = getPort(SVC_HTTPS_CONSOLE); boolean httpsOnly = httpsPort > 0 && httpHost.equals(unset) && !httpsHost.equals(unset); if (httpsOnly) return "https://" + httpsHost + ':' + httpsPort + '/'; if (httpHost.equals(unset)) httpHost = DEFAULT_HOST; return "http://" + httpHost + ':' + httpPort + '/'; }
public void run() { for (LifeCycle lc : _jettys) { if (lc.isRunning()) { try { lc.stop(); } catch (Exception e) { changeState(STOPPING, e); } } } if (_context != null) { PortMapper pm = _context.portMapper(); if (_port > 0 && pm.getPort(PortMapper.SVC_EEPSITE) == _port) { _port = 0; pm.unregister(PortMapper.SVC_EEPSITE); } if (_sslPort > 0 && pm.getPort(PortMapper.SVC_HTTPS_EEPSITE) == _sslPort) { _sslPort = 0; pm.unregister(PortMapper.SVC_HTTPS_EEPSITE); } } changeState(STOPPED); } }
if (sproxyType == SSLEepGet.ProxyType.INTERNAL) { _sproxyHost = "localhost"; _sproxyPort = _context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY, 4444); } else { _sproxyHost = _context.getProperty(PROP_SPROXY_HOST);
@Override public boolean close(boolean forced) { int reg = _context.portMapper().getPort(PortMapper.SVC_HTTPS_PROXY); if (reg == getLocalPort()) _context.portMapper().unregister(PortMapper.SVC_HTTPS_PROXY); return super.close(forced); }
/** * Overridden to close internal socket too. */ @Override public boolean close(boolean forced) { int port = getLocalPort(); int reg = _context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY); if (reg == port) { _context.portMapper().unregister(PortMapper.SVC_HTTP_PROXY); } reg = _context.portMapper().getPort(PortMapper.SVC_HTTPS_PROXY); if (reg == port) { _context.portMapper().unregister(PortMapper.SVC_HTTPS_PROXY); } boolean rv = super.close(forced); if(this.isr != null) { this.isr.stopRunning(); } return rv; }
/** * Overridden to unregister with port mapper * * @since 0.9.27 */ @Override public boolean close(boolean forced) { int port = getLocalPort(); int reg = _context.portMapper().getPort(PortMapper.SVC_SMTP); if (reg == port) { _context.portMapper().unregister(PortMapper.SVC_SMTP); } reg = _context.portMapper().getPort(PortMapper.SVC_POP); if (reg == port) { _context.portMapper().unregister(PortMapper.SVC_POP); } boolean rv = super.close(forced); if (_isr != null) { _isr.stopRunning(); } return rv; } }
/** * Yes, the EepGet fetch() is done in here in next(). * * see java.util.Iterator#next() * @return non-null AddressBook (empty if the minimum delay has not been met, * or there is no proxy tunnel, or the fetch otherwise fails) */ public AddressBook next() { Subscription sub = this.subIterator.next(); if (sub.getLocation().startsWith("file:")) { // test only return new AddressBook(sub.getLocation().substring(5)); } else if (sub.getLastFetched() + this.delay < I2PAppContext.getGlobalContext().clock().now() && I2PAppContext.getGlobalContext().portMapper().getPort(PortMapper.SVC_HTTP_PROXY) >= 0 && !I2PAppContext.getGlobalContext().getBooleanProperty("i2p.vmCommSystem")) { //System.err.println("Fetching addressbook from " + sub.getLocation()); return new AddressBook(sub, this.proxyHost, this.proxyPort); } else { //System.err.println("Addressbook " + sub.getLocation() + " was last fetched " + // DataHelper.formatDuration(I2PAppContext.getGlobalContext().clock().now() - sub.getLastFetched()) + // " ago but the minimum delay is " + // DataHelper.formatDuration(this.delay)); return new AddressBook(Collections.<String, HostTxtEntry>emptyMap()); } }
svc = PortMapper.SVC_EEPSITE; if (pm.getPort(svc) <= 0) pm.register(svc, host, port);
@Override public boolean close(boolean forced) { int reg = _context.portMapper().getPort(PortMapper.SVC_IRC); if (reg == getLocalPort()) _context.portMapper().unregister(PortMapper.SVC_IRC); synchronized(this) { if (_DCCServer != null) { _DCCServer.close(forced); _DCCServer = null; } if (_DCCClientManager != null) { _DCCClientManager.close(forced); _DCCClientManager = null; } } return super.close(forced); }