Search in sources :

Example 11 with Socks5BytestreamSession

use of org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession in project Smack by igniterealtime.

the class Socks5TransferNegotiator method negotiateIncomingStream.

@Override
InputStream negotiateIncomingStream(Stanza streamInitiation) throws InterruptedException, SmackException, XMPPErrorException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager, (Bytestream) streamInitiation);
    // always accept the request
    Socks5BytestreamSession session = request.accept();
    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    } catch (IOException e) {
        throw new SmackException.SmackWrappedException("Error establishing input stream", e);
    }
}
Also used : Socks5BytestreamRequest(org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest) PushbackInputStream(java.io.PushbackInputStream) SmackException(org.jivesoftware.smack.SmackException) IOException(java.io.IOException) Socks5BytestreamSession(org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession)

Aggregations

TimeoutException (java.util.concurrent.TimeoutException)8 XMPPException (org.jivesoftware.smack.XMPPException)8 IOException (java.io.IOException)7 Socks5BytestreamSession (org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession)7 Socks5BytestreamRequest (org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest)5 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)5 Socket (java.net.Socket)4 XMPPConnection (org.jivesoftware.smack.XMPPConnection)4 StreamHost (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost)4 InputStream (java.io.InputStream)3 OutputStream (java.io.OutputStream)3 SynchronousQueue (java.util.concurrent.SynchronousQueue)3 SmackException (org.jivesoftware.smack.SmackException)3 Socks5BytestreamListener (org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamListener)3 Socks5BytestreamManager (org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager)3 PushbackInputStream (java.io.PushbackInputStream)2 ArrayList (java.util.ArrayList)2 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)2 StreamHostUsed (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHostUsed)2 HashMap (java.util.HashMap)1