Safe Haskell | None |
---|---|
Language | Haskell2010 |
Protocol description
Defines functions that handle the advancing of the SAMv3 protocol.
Warning: This function is used internally by I2P
and using these functions directly is unsupported. The
interface of these functions might change at any time without
prior notice.
- connect :: (MonadIO m, MonadMask m) => HostName -> ServiceName -> ((Socket, SockAddr) -> m r) -> m r
- version :: (MonadIO m, MonadMask m) => Socket -> m [Integer]
- versionWithConstraint :: (MonadIO m, MonadMask m) => ([Integer], [Integer]) -> Socket -> m [Integer]
- createDestination :: (MonadIO m, MonadMask m) => Maybe SignatureType -> Socket -> m (PrivateDestination, PublicDestination)
- createSession :: (MonadIO m, MonadMask m) => SocketType -> Socket -> m (String, PrivateDestination, PublicDestination)
- createSessionWith :: (MonadIO m, MonadMask m, Acceptable d, Destination d) => Maybe String -> d -> SocketType -> Socket -> m String
- acceptStream :: (MonadIO m, MonadMask m) => String -> Socket -> m (Socket, PublicDestination)
- connectStream :: (MonadIO m, MonadMask m, Connectable d, Destination d) => String -> d -> Socket -> m ()
- sendDatagram :: (MonadIO m, MonadMask m, Connectable d, Destination d) => EndPoint -> String -> d -> ByteString -> m ()
- receiveDatagram :: (MonadIO m, MonadMask m) => Socket -> m (ByteString, Maybe PublicDestination)
Documentation
:: forall (m :: * -> *). (MonadIO m, MonadMask m) | |
=> HostName | Server hostname. |
-> ServiceName | Server service port. |
-> ((Socket, SockAddr) -> m r) | Computation taking the communication socket and the server address. |
-> m r |
Connect to a TCP server and use the connection.
The connection socket is closed when done or in case of exceptions.
If you prefer to acquire and close the socket yourself, then use
connectSock
and closeSock
.
:: (MonadIO m, MonadMask m) | |
=> Socket | Our connection with SAM bridge |
-> m [Integer] | Version agreed upon, stores as a list of integers; for example, [3,1] means version 3.1 |
Announces ourselves with SAM bridge and negotiates protocol version
Defaults to protocol version 3.1, which is the only one we support at the moment.
:: (MonadIO m, MonadMask m) | |
=> ([Integer], [Integer]) | Min/max version we want to agree on, stored as a list of integers. For example, ([3,0], [3,1]) means min version 3.0, max version 3.1 |
-> Socket | Our connection with SAM bridge |
-> m [Integer] | Version agreed upon, stores as a list of integers; for example, [3,1] means version 3.1 |
Performs same handshake as version
, but with an explicit min/max supported
version provided.
createDestination :: (MonadIO m, MonadMask m) => Maybe SignatureType -> Socket -> m (PrivateDestination, PublicDestination) Source
Creates a new I2P public/private destination pair
:: (MonadIO m, MonadMask m) | |
=> SocketType | I2P socket type to create |
-> Socket | Our connection with SAM bridge |
-> m (String, PrivateDestination, PublicDestination) | Our session id and our private destination key |
Create a session with default parameters provided.
:: (MonadIO m, MonadMask m, Acceptable d, Destination d) | |
=> Maybe String | Session id to use. If none is provided, a new unique session id is created. |
-> d | Destination to use. |
-> SocketType | I2P socket type to create |
-> Socket | Our connection with SAM bridge |
-> m String | Our session id |
Create a session, and explicitly provide all parameters to use
:: (MonadIO m, MonadMask m) | |
=> String | Our session id |
-> Socket | Our connection with SAM bridge |
-> m (Socket, PublicDestination) | Returns as soon as connection has been accepted |
For VirtualStream sockets, accepts one new connection
:: (MonadIO m, MonadMask m, Connectable d, Destination d) | |
=> String | Our session id |
-> d | Destination we wish to connect to |
-> Socket | Our connection with SAM bridge |
-> m () | Returning state |
For VirtualStream sockets, establishes connection with a remote
:: (MonadIO m, MonadMask m, Connectable d, Destination d) | |
=> EndPoint | SAM UDP endpoint |
-> String | Our session id |
-> d | Destination we wish to send message to |
-> ByteString | Message we wish to send |
-> m () | Returning state |
For DatagramRepliable and DatagramAnonymous, send a message
:: (MonadIO m, MonadMask m) | |
=> Socket | Our connection with SAM bridge |
-> m (ByteString, Maybe PublicDestination) | Received buffer, possibly with a reply destination |
For DatagramRepliable and DatagramAnonymous, receive a message