Class I2PSessionMuxedImpl

  • All Implemented Interfaces:
    I2PSession, I2CPMessageReader.I2CPMessageEventListener
    Direct Known Subclasses:
    SubSession

    class I2PSessionMuxedImpl
    extends I2PSessionImpl2
    I2PSession with protocol and ports Streaming lib has been modified to send I2PSession.PROTO_STREAMING but still receives all. It sends with fromPort and toPort = 0, and receives on all ports. No datagram apps have been modified yet. Therefore the compatibility situation is as follows: Compatibility: old streaming -> new streaming: sends proto anything, rcvs proto anything new streaming -> old streaming: sends PROTO_STREAMING, ignores rcvd proto old datagram -> new datagram: sends proto anything, rcvs proto anything new datagram -> old datagram: sends PROTO_DATAGRAM, ignores rcvd proto In all the above cases, streaming and datagram receive traffic for the other protocol, same as before. old datagram -> new muxed: doesn't work because the old sends proto 0 but the udp side of the mux registers with PROTO_DATAGRAM, so the datagrams go to the streaming side, same as before. old streaming -> new muxed: works Typical Usage: Streaming + datagrams: I2PSocketManager sockMgr = getSocketManager(); I2PSession session = sockMgr.getSession(); session.addMuxedSessionListener(myI2PSessionMuxedListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY); * or * session.addSessionListener(myI2PSessionListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY); session.sendMessage(dest, payload, I2PSession.PROTO_DATAGRAM, fromPort, toPort); Datagrams only, with multiple ports: I2PClient client = I2PClientFactory.createClient(); ... I2PSession session = client.createSession(...); session.addMuxedSessionListener(myI2PSessionMuxedListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY); * or * session.addSessionListener(myI2PSessionListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY); session.sendMessage(dest, payload, I2PSession.PROTO_DATAGRAM, fromPort, toPort); Multiple streaming ports: Needs some streaming lib hacking
    Since:
    0.7.1
    Author:
    zzz
    • Method Detail

      • addSessionListener

        public void addSessionListener​(I2PSessionListener lsnr,
                                       int proto,
                                       int port)
        Listen on specified protocol and port. An existing listener with the same proto and port is replaced. Only the listener with the best match is called back for each message.
        Specified by:
        addSessionListener in interface I2PSession
        Overrides:
        addSessionListener in class I2PSessionImpl2
        Parameters:
        proto - 1-254 or PROTO_ANY (0) for all; recommended: I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowed
        port - 1-65535 or PORT_ANY (0) for all
      • sendMessage

        public boolean sendMessage​(Destination dest,
                                   byte[] payload,
                                   int offset,
                                   int size,
                                   SessionKey keyUsed,
                                   Set<SessionTag> tagsSent,
                                   int proto,
                                   int fromport,
                                   int toport)
                            throws I2PSessionException
        Description copied from interface: I2PSession
        See I2PSessionMuxedImpl for proto/port details. End-to-End Crypto is disabled, tags and keys are ignored.
        Specified by:
        sendMessage in interface I2PSession
        Overrides:
        sendMessage in class I2PSessionImpl2
        Parameters:
        keyUsed - unused - no end-to-end crypto
        tagsSent - unused - no end-to-end crypto
        proto - 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowed
        fromport - 1-65535 or 0 for unset
        toport - 1-65535 or 0 for unset
        Returns:
        success
        Throws:
        I2PSessionException
      • sendMessage

        public boolean sendMessage​(Destination dest,
                                   byte[] payload,
                                   int offset,
                                   int size,
                                   SessionKey keyUsed,
                                   Set<SessionTag> tagsSent,
                                   long expires,
                                   int proto,
                                   int fromPort,
                                   int toPort)
                            throws I2PSessionException
        Description copied from interface: I2PSession
        See I2PSessionMuxedImpl for proto/port details. End-to-End Crypto is disabled, tags and keys are ignored.
        Specified by:
        sendMessage in interface I2PSession
        Overrides:
        sendMessage in class I2PSessionImpl2
        Parameters:
        keyUsed - unused - no end-to-end crypto
        tagsSent - unused - no end-to-end crypto
        proto - 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowed
        fromPort - 1-65535 or 0 for unset
        toPort - 1-65535 or 0 for unset
        expires - absolute expiration timestamp, NOT interval from now
        Returns:
        success
        Throws:
        I2PSessionException
        Since:
        0.7.1
      • sendMessage

        public boolean sendMessage​(Destination dest,
                                   byte[] payload,
                                   int offset,
                                   int size,
                                   SessionKey keyUsed,
                                   Set<SessionTag> tagsSent,
                                   long expires,
                                   int proto,
                                   int fromPort,
                                   int toPort,
                                   int flags)
                            throws I2PSessionException
        Description copied from interface: I2PSession
        See I2PSessionMuxedImpl for proto/port details. End-to-End Crypto is disabled, tags and keys are ignored.
        Specified by:
        sendMessage in interface I2PSession
        Overrides:
        sendMessage in class I2PSessionImpl2
        Parameters:
        keyUsed - unused - no end-to-end crypto
        tagsSent - unused - no end-to-end crypto
        proto - 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowed
        fromPort - 1-65535 or 0 for unset
        toPort - 1-65535 or 0 for unset
        flags - to be passed to the router
        expires - absolute expiration timestamp, NOT interval from now
        Returns:
        success
        Throws:
        I2PSessionException
        Since:
        0.8.4
      • sendMessage

        public boolean sendMessage​(Destination dest,
                                   byte[] payload,
                                   int offset,
                                   int size,
                                   int proto,
                                   int fromPort,
                                   int toPort,
                                   SendMessageOptions options)
                            throws I2PSessionException
        See SendMessageOptions for option details. Always uses sendNoEffort for now.
        Specified by:
        sendMessage in interface I2PSession
        Overrides:
        sendMessage in class I2PSessionImpl2
        Parameters:
        proto - 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowed
        fromPort - 1-65535 or 0 for unset
        toPort - 1-65535 or 0 for unset
        options - to be passed to the router
        Returns:
        success
        Throws:
        I2PSessionException
        Since:
        0.9.2
      • sendMessage

        public long sendMessage​(Destination dest,
                                byte[] payload,
                                int offset,
                                int size,
                                int proto,
                                int fromPort,
                                int toPort,
                                SendMessageOptions options,
                                SendMessageStatusListener listener)
                         throws I2PSessionException
        Send a message and request an asynchronous notification of delivery status. See I2PSessionMuxedImpl for proto/port details. See SendMessageOptions for option details.
        Specified by:
        sendMessage in interface I2PSession
        Overrides:
        sendMessage in class I2PSessionImpl2
        proto - 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowed
        fromPort - 1-65535 or 0 for unset
        toPort - 1-65535 or 0 for unset
        options - to be passed to the router
        Returns:
        the message ID to be used for later notification to the listener
        Throws:
        I2PSessionException - on all errors
        Since:
        0.9.14