Search in sources :

Example 26 with I2PAppThread

use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.

the class Reseeder method requestReseed.

/**
 *  Start a reseed using the default reseed URLs.
 *  Supports su3 and directories.
 *  Threaded, nonblocking.
 */
void requestReseed() {
    ReseedRunner reseedRunner = new ReseedRunner();
    // set to daemon so it doesn't hang a shutdown
    Thread reseed = new I2PAppThread(reseedRunner, "Reseed", true);
    reseed.start();
}
Also used : I2PAppThread(net.i2p.util.I2PAppThread) I2PAppThread(net.i2p.util.I2PAppThread)

Example 27 with I2PAppThread

use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.

the class I2PSOCKSIRCTunnel method clientConnectionRun.

/**
 *  Same as in I2PSOCKSTunnel, but run the filters from I2PTunnelIRCClient
 *  instead of I2PTunnelRunner
 */
@Override
protected void clientConnectionRun(Socket s) {
    I2PSocket destSock = null;
    try {
        // _log.error("SOCKS IRC Tunnel Start");
        try {
            s.setSoTimeout(INITIAL_SO_TIMEOUT);
        } catch (SocketException ioe) {
        }
        SOCKSServer serv = SOCKSServerFactory.createSOCKSServer(_context, s, getTunnel().getClientOptions());
        Socket clientSock = serv.getClientSocket();
        try {
            s.setSoTimeout(0);
        } catch (SocketException ioe) {
        }
        destSock = serv.getDestinationI2PSocket(this);
        StringBuffer expectedPong = new StringBuffer();
        int id = __clientId.incrementAndGet();
        Thread in = new I2PAppThread(new IrcInboundFilter(clientSock, destSock, expectedPong, _log), "SOCKS IRC Client " + id + " in", true);
        in.start();
        // Thread out = new I2PAppThread(new IrcOutboundFilter(clientSock, destSock, expectedPong, _log),
        // "SOCKS IRC Client " + id + " out", true);
        Runnable out = new IrcOutboundFilter(clientSock, destSock, expectedPong, _log);
        // we are called from an unlimited thread pool, so run inline
        // out.start();
        out.run();
    } catch (SOCKSException e) {
        if (_log.shouldLog(Log.WARN))
            _log.warn("Error from SOCKS connection", e);
    } finally {
        // only because we are running it inline
        closeSocket(s);
        if (destSock != null)
            try {
                destSock.close();
            } catch (IOException ioe) {
            }
    }
}
Also used : SocketException(java.net.SocketException) I2PSocket(net.i2p.client.streaming.I2PSocket) SOCKSException(net.i2p.socks.SOCKSException) IOException(java.io.IOException) I2PAppThread(net.i2p.util.I2PAppThread) I2PAppThread(net.i2p.util.I2PAppThread) IrcOutboundFilter(net.i2p.i2ptunnel.irc.IrcOutboundFilter) IrcInboundFilter(net.i2p.i2ptunnel.irc.IrcInboundFilter) Socket(java.net.Socket) I2PSocket(net.i2p.client.streaming.I2PSocket)

Example 28 with I2PAppThread

use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.

the class WebMail method processGenericButtons.

/**
 * @param sessionObject
 * @param request
 * @return new state
 */
private static State processGenericButtons(SessionObject sessionObject, RequestWrapper request, State state) {
    /**
     ** All RELOAD buttons are commented out
     *		if( buttonPressed( request, RELOAD ) ) {
     *			Config.reloadConfiguration();
     *			int oldPageSize = sessionObject.folder.getPageSize();
     *			int pageSize = Config.getProperty( Folder.PAGESIZE, Folder.DEFAULT_PAGESIZE );
     *			if( pageSize != oldPageSize )
     *				sessionObject.folder.setPageSize( pageSize );
     *			sessionObject.info = _t("Configuration reloaded");
     *		}
     ***
     */
    if (buttonPressed(request, REFRESH)) {
        POP3MailBox mailbox = sessionObject.mailbox;
        if (mailbox == null) {
            sessionObject.error += _t("Internal error, lost connection.") + '\n';
            return State.AUTH;
        }
        if (sessionObject.isFetching) {
            // shouldn't happen, button disabled
            return state;
        }
        sessionObject.isFetching = true;
        ConnectWaiter cw = new ConnectWaiter(sessionObject);
        if (mailbox.connectToServer(cw)) {
            // Start a thread to wait for results
            Debug.debug(Debug.DEBUG, "Already connected, running CW");
            Thread t = new I2PAppThread(cw, "Email fetcher");
            t.start();
        } else {
            sessionObject.error += _t("Cannot connect") + '\n';
            sessionObject.isFetching = false;
        }
        // wait if it's going to be quick
        try {
            sessionObject.wait(3000);
        } catch (InterruptedException ie) {
            Debug.debug(Debug.DEBUG, "Interrupted waiting for connect", ie);
        }
    }
    return state;
}
Also used : POP3MailBox(i2p.susi.webmail.pop3.POP3MailBox) I2PAppThread(net.i2p.util.I2PAppThread) I2PAppThread(net.i2p.util.I2PAppThread)

Example 29 with I2PAppThread

use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.

the class MailCache method loadFromDisk.

/**
 * Threaded. Returns immediately.
 * This will not access the mailbox. Mailbox need not be ready.
 *
 * @return success false if in progress already and nml will NOT be called back, true if nml will be called back
 * @since 0.9.13
 */
public synchronized boolean loadFromDisk(NewMailListener nml) {
    if (_loadInProgress != null)
        return false;
    Thread t = new I2PAppThread(new LoadMailRunner(nml), "Email loader");
    _loadInProgress = nml;
    try {
        t.start();
    } catch (Throwable e) {
        _loadInProgress = null;
        return false;
    }
    return true;
}
Also used : I2PAppThread(net.i2p.util.I2PAppThread) I2PAppThread(net.i2p.util.I2PAppThread)

Example 30 with I2PAppThread

use of net.i2p.util.I2PAppThread in project i2p.i2p by i2p.

the class I2PTunnelClientBase method startup.

private void startup() {
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("startup " + _clientId, new Exception("I did it"));
    // prevent JVM exit when running outside the router
    boolean isDaemon = getTunnel().getContext().isRouterContext();
    open = true;
    Thread t = new I2PAppThread(this, "I2PTunnel Client " + getTunnel().listenHost + ':' + localPort, isDaemon);
    t.start();
    synchronized (this) {
        while (!listenerReady && open) {
            try {
                wait();
            } catch (InterruptedException e) {
            // ignore
            }
        }
    }
    if (open && listenerReady) {
        boolean openNow = !Boolean.parseBoolean(getTunnel().getClientOptions().getProperty("i2cp.delayOpen"));
        if (openNow || chained)
            l.log("Client ready, listening on " + getTunnel().listenHost + ':' + localPort);
        else
            l.log("Client ready, listening on " + getTunnel().listenHost + ':' + localPort + ", delaying tunnel open until required");
        notifyEvent("openBaseClientResult", "ok");
    } else {
        l.log("Client error for " + getTunnel().listenHost + ':' + localPort + ", check logs");
        notifyEvent("openBaseClientResult", "error");
    }
    synchronized (startLock) {
        startRunning = true;
        startLock.notify();
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) I2PSessionException(net.i2p.client.I2PSessionException) UnknownHostException(java.net.UnknownHostException) I2PException(net.i2p.I2PException) NoRouteToHostException(java.net.NoRouteToHostException) I2PAppThread(net.i2p.util.I2PAppThread) I2PAppThread(net.i2p.util.I2PAppThread)

Aggregations

I2PAppThread (net.i2p.util.I2PAppThread)52 IOException (java.io.IOException)18 I2PException (net.i2p.I2PException)9 I2PSocket (net.i2p.client.streaming.I2PSocket)7 InterruptedIOException (java.io.InterruptedIOException)6 ConnectException (java.net.ConnectException)5 Socket (java.net.Socket)5 I2PSessionException (net.i2p.client.I2PSessionException)5 Destination (net.i2p.data.Destination)5 File (java.io.File)3 InputStream (java.io.InputStream)3 OutputStream (java.io.OutputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 ServerSocket (java.net.ServerSocket)3 SocketTimeoutException (java.net.SocketTimeoutException)3 UnknownHostException (java.net.UnknownHostException)3 Properties (java.util.Properties)3 I2PServerSocket (net.i2p.client.streaming.I2PServerSocket)3 DataFormatException (net.i2p.data.DataFormatException)3 FileNotFoundException (java.io.FileNotFoundException)2