public void gotDateTime(long time) { if (_log.shouldDebug()) _log.debug("Got updated datetime block"); receiveTimestamp((time + 500) / 1000); // update skew }
/** * @param keyData using first 24 bytes */ public NTCP2ReadState(CipherState rcvr, byte[] keyData) { _rcvr = rcvr; _sipk1 = fromLong8LE(keyData, 0); _sipk2 = fromLong8LE(keyData, 8); System.arraycopy(keyData, 16, _sipIV, 0, SIP_IV_LENGTH); if (_log.shouldDebug()) _log.debug("Recv SipHash keys: " + _sipk1 + ' ' + _sipk2 + ' ' + Base64.encode(_sipIV)); }
/** * EventListener callback - * unused for now - supported in miniupnpd as of 1.1 */ public void eventNotifyReceived(String uuid, long seq, String varName, String value) { if (uuid == null || varName == null || value == null) return; if (varName.length() > 128 || value.length() > 128) return; String old = null; synchronized(lock) { if (_service == null || !uuid.equals(_service.getSID())) return; if (_eventVars.size() >= 20 && !_eventVars.containsKey(varName)) return; old = _eventVars.put(varName, value); } // The following four variables are "evented": // PossibleConnectionTypes: {Unconfigured IP_Routed IP_Bridged} // ConnectionStatus: {Unconfigured Connecting Connected PendingDisconnect Disconnecting Disconnected} // ExternalIPAddress: string // PortMappingNumberOfEntries: int if (!value.equals(old)) { if (_log.shouldDebug()) _log.debug("Event: " + varName + " changed from " + old + " to " + value); } // call callback... }
public void gotI2NP(I2NPMessage msg) { if (_log.shouldDebug()) _log.debug("Got I2NP msg: " + msg); long timeToRecv = 0; // _context.clock().now() - _stateBegin; int size = 100; // FIXME _transport.messageReceived(msg, _remotePeer, null, timeToRecv, size); _lastReceiveTime = _context.clock().now(); _messagesRead.incrementAndGet(); }
public void gotPadding(int paddingLength, int frameLength) { if (_log.shouldDebug()) _log.debug("Got " + paddingLength + " bytes padding in " + frameLength + " byte frame; ratio: " + (((float) paddingLength) / ((float) frameLength)) + " configured min: " + _paddingConfig.getRecvMin() + " configured max: " + _paddingConfig.getRecvMax()); } }
/** * Notify the listeners * * @since stratum param added in 0.7.12 */ private void stampTime(long now, int stratum) { long before = _context.clock().now(); for (UpdateListener lsnr : _listeners) { lsnr.setNow(now, stratum); } if (_log != null && _log.shouldDebug()) _log.debug("Stamped the time as " + now + " (delta=" + (now-before) + ")"); }
public void gotOptions(byte[] options, boolean isHandshake) { NTCP2Options hisPadding = NTCP2Options.fromByteArray(options); if (hisPadding == null) { if (_log.shouldWarn()) _log.warn("Got options length " + options.length + " on: " + this); return; } _paddingConfig = OUR_PADDING.merge(hisPadding); if (_log.shouldDebug()) _log.debug("Got padding options:" + "\nhis padding options: " + hisPadding + "\nour padding options: " + OUR_PADDING + "\nmerged config is: " + _paddingConfig); }
/** * Open a GeoIP2 database * @since 0.9.38 */ private DatabaseReader openGeoIP2(File geoFile) throws IOException { DatabaseReader.Builder b = new DatabaseReader.Builder(geoFile); b.withCache(new CHMCache(256)); DatabaseReader rv = b.build(); if (_log.shouldDebug()) _log.debug("Opened GeoIP2 Database, Metadata: " + rv.getMetadata()); return rv; }
/** * Opens the given URL with the given browser. * As of 0.9.38, the browser parameter will be parsed into arguments * separated by spaces or tabs. * %1, if present, will be replaced with the url. * Arguments may be surrounded by single or double quotes if * they contain spaces or tabs. * There is no mechanism to escape quotes or other chars with backslashes. * * BLOCKING. However, this does NOT probe the server port to see if it is ready. * * @param url The URL to open. * @param browser The browser to use. See above for quoting rules. * @return <code>true</code> if the operation was successful, * otherwise <code>false</code>. * * @throws IOException */ public boolean openUrl(String url, String browser) throws IOException { waitForServer(url); if (validateUrlFormat(url)) { String[] args = parseArgs(browser, url); if (args.length > 0) { if (_log.shouldDebug()) _log.debug("Execute: " + Arrays.toString(args)); if (_shellCommand.executeSilentAndWaitTimed(args, 5)) return true; } } return false; }
void receivePacketDirect(Packet packet, boolean queueIfNoConn) { //if (_log.shouldLog(Log.DEBUG)) // _log.debug("packet received: " + packet); long sendId = packet.getSendStreamId(); Connection con = (sendId > 0 ? _manager.getConnectionByInboundId(sendId) : null); if (con != null) { if (_log.shouldDebug()) displayPacket(packet, "RECV", "wsize " + con.getOptions().getWindowSize() + " rto " + con.getOptions().getRTO()); receiveKnownCon(con, packet); } else { if (_log.shouldDebug()) displayPacket(packet, "UNKN", null); receiveUnknownCon(packet, sendId, queueIfNoConn); } // Don't log here, wait until we have the conn to make the dumps easier to follow //((PacketLocal)packet).logTCPDump(true); }
public void gotRI(RouterInfo ri, boolean isHandshake, boolean flood) throws DataFormatException { if (_log.shouldDebug()) _log.debug("Got updated RI"); _messagesRead.incrementAndGet(); try { Hash h = ri.getHash(); RouterInfo old = _context.netDb().store(h, ri); if (flood && !ri.equals(old)) { FloodfillNetworkDatabaseFacade fndf = (FloodfillNetworkDatabaseFacade) _context.netDb(); if (fndf.floodConditional(ri)) { if (_log.shouldDebug()) _log.debug("Flooded the RI: " + h); } else { if (_log.shouldInfo()) _log.info("Flood request but we didn't: " + h); } } } catch (IllegalArgumentException iae) { throw new DataFormatException("RI store fail: " + ri, iae); } }
public void stop() { if (_log.shouldDebug()) _log.debug("Snark stop() begin", new Exception("I did it")); if (_umgr != null && _uhandler != null) { //_uhandler.shutdown(); _umgr.unregister(_uhandler, UpdateType.ROUTER_SIGNED, UpdateMethod.TORRENT); _umgr.unregister(_uhandler, UpdateType.ROUTER_SIGNED_SU3, UpdateMethod.TORRENT); } _running = false; _monitor.interrupt(); _connectionAcceptor.halt(); _idleChecker.cancel(); stopAllTorrents(true); if ("i2psnark".equals(_contextName)) { // only if default instance ClientAppManager cmgr = _context.clientAppManager(); if (cmgr != null) cmgr.unregister(this); } if (_log.shouldWarn()) _log.warn("Snark stop() end"); }
/** * Update our IPv4 or IPv6 address and optionally tell the router to rebuild and republish the router info. * * @param ip new ip valid IPv4 or IPv6 or null * @param port new valid port or -1 * @param allowRebuildRouterInfo whether to tell the router * @return the new address if changed, else null * @since IPv6 */ private RouterAddress rebuildExternalAddress(byte[] ip, int port, boolean allowRebuildRouterInfo) { if (_log.shouldDebug()) _log.debug("REA3 " + Addresses.toString(ip, port)); if (ip == null) return rebuildExternalAddress((String) null, port, allowRebuildRouterInfo); if (isValid(ip)) return rebuildExternalAddress(Addresses.toString(ip), port, allowRebuildRouterInfo); return null; }
if (_log.shouldDebug()) _log.debug("Sending router info for: " + ri.getHash() + " flood? " + shouldFlood); List<Block> blocks = new ArrayList<Block>(2);
/** * KDF for data phase, * then calls con.finishOutboundEstablishment(), * passing over the final keys and states to the con. * * Caller must synch */ private void setDataPhase() { // Data phase ChaChaPoly keys CipherStatePair ckp = _handshakeState.split(); CipherState rcvr = ckp.getReceiver(); CipherState sender = ckp.getSender(); // Data phase SipHash keys byte[][] sipkeys = generateSipHashKeys(_context, _handshakeState); byte[] sip_ab = sipkeys[0]; byte[] sip_ba = sipkeys[1]; if (_log.shouldDebug()) { _log.debug("Finished establishment for " + this + "\nGenerated SipHash key for A->B: " + Base64.encode(sip_ab) + "\nGenerated SipHash key for B->A: " + Base64.encode(sip_ba)); } // skew in seconds _con.finishOutboundEstablishment(sender, rcvr, sip_ab, sip_ba, _peerSkew); changeState(State.VERIFIED); // no extra data possible releaseBufs(true); _handshakeState.destroy(); Arrays.fill(sip_ab, (byte) 0); Arrays.fill(sip_ba, (byte) 0); }
_sendSipIV = new byte[SIP_IV_LENGTH]; System.arraycopy(sip_send, 16, _sendSipIV, 0, SIP_IV_LENGTH); if (_log.shouldDebug()) _log.debug("Send SipHash keys: " + _sendSipk1 + ' ' + _sendSipk2 + ' ' + Base64.encode(_sendSipIV)); _clockSkew = clockSkew;
public void runJob() { File configFile = new File(getContext().router().getConfigFilename()); if (shouldReread(configFile)) { getContext().router().readConfig(); _lastRead = getContext().clock().now(); Log log = getContext().logManager().getLog(ReadConfigJob.class); if (log.shouldDebug()) log.debug("Reloaded " + configFile); } requeue(DELAY); }
/** * Inject a DatabaseStoreMessage with our RouterInfo. NTCP 1 only. */ private void enqueueInfoMessageNTCP1() { int priority = INFO_PRIORITY; if (_log.shouldDebug()) _log.debug("SENDING INFO message pri. " + priority + ": " + toString()); DatabaseStoreMessage dsm = new DatabaseStoreMessage(_context); dsm.setEntry(_context.router().getRouterInfo()); // We are injecting directly, so we can use a null target. OutNetMessage infoMsg = new OutNetMessage(_context, dsm, _context.clock().now()+10*1000, priority, null); infoMsg.beginSend(); send(infoMsg); }
if (hisPadding != null) { _paddingConfig = OUR_PADDING.merge(hisPadding); if (_log.shouldDebug()) _log.debug("Got padding options:" + "\nhis padding options: " + hisPadding +
public void runJob() { Hash hash = _peer.getIdentity().getHash(); MessageWrapper.WrappedMessage wm = _state.getPendingMessage(hash); if (wm != null) wm.acked(); long howLong = _state.confirmed(hash); if (_log.shouldLog(Log.INFO)) _log.info(StoreJob.this.getJobId() + ": Marking store of " + _state.getTarget() + " to " + hash.toBase64() + " successful after " + howLong); getContext().profileManager().dbStoreSent(hash, howLong); getContext().statManager().addRateData("netDb.ackTime", howLong, howLong); if ( (_sendThrough != null) && (_msgSize > 0) ) { if (_log.shouldDebug()) _log.debug("sent a " + _msgSize + " byte netDb message through tunnel " + _sendThrough + " after " + howLong); for (int i = 0; i < _sendThrough.getLength(); i++) getContext().profileManager().tunnelDataPushed(_sendThrough.getPeer(i), howLong, _msgSize); _sendThrough.incrementVerifiedBytesTransferred(_msgSize); } if (_sendThrough == null) { // advise comm system, to reduce lifetime of direct connections to floodfills getContext().commSystem().mayDisconnect(_peer.getHash()); } if (_state.getCompleteCount() >= getRedundancy()) { succeed(); } else { sendNext(); } }