| |
- i2p.Error(exceptions.Exception)
-
- Error
-
- BlockError
- ClosedError
- NetworkError
- Timeout
- Poll
- Socket
- Tunnel
-
- TunnelClient
- TunnelServer
class Poll |
|
Class implementing poll interface. Works for Python sockets
and SAM sockets. |
|
Methods defined here:
- __init__(self)
- poll(self, timeout=None)
- register(self, fd, eventmask=13)
- unregister(self, fd)
|
class Socket |
|
A socket object. |
|
Methods defined here:
- __deepcopy__(self, memo)
- __init__(self, session, type, samaddr='127.0.0.1:7656', **kwargs)
- Equivalent to socket().
- accept(self)
- bind(self, address)
- close(self)
- connect(self, address)
- connect_ex(self, address)
- getpeername(self)
- getsockname(self)
- gettimeout(self)
- listen(self, backlog)
- makefile(self, mode='r', bufsize=-1)
- recv(self, bufsize, flags=0)
- recvfrom(self, bufsize, flags=0)
- For a datagram or raw socket, bufsize = -1 indicates that the
entire packet should be retrieved.
- send(self, string, flags=0)
- sendall(self, string, flags=0)
- sendto(self, string, flags, address)
- setblocking(self, flag)
- settimeout(self, value)
Properties defined here:
- dest
- Local I2P Destination of socket
- session
- Session name
- type
- Socket type: SOCK_STREAM, SOCK_DGRAM, or SOCK_RAW.
|
class Tunnel |
| |
Methods defined here:
- __init__(self, receive, make_send, nconnect=-1, timeout=60.0)
- A Tunnel relays connections from a 'receive' socket to one
or more 'send' sockets. The receive socket must be bound
and listening. For each incoming connection, a new send
socket is created by calling make_send(). Data is then
exchanged between the created streams until one socket is
closed. nconnect is the maximum number of simultaneous
connections (-1 for infinite), and timeout is the time that
a single connection can last for (None allows a connection
to last forever).
Sockets must accept stream traffic and support the Python
socket interface. A separate daemonic thread is created to
manage the tunnel. For high performance, make_send() should
make a socket and connect in non-blocking mode (you should
catch and discard the sam.BlockError or socket.error due to
executing connect on a non-blocking socket).
Security Note:
A firewall is needed to maintain the end user's anonymity.
An attacker could keep a tunnel socket open by pinging it
regularly. The accepted sockets from 'receive' must prevent
this by closing down eventually.
Socket errors do not cause the Tunnel to shut down.
- close(self)
- Close all connections made for this tunnel.
|
class TunnelClient(Tunnel) |
| |
Methods defined here:
- __init__(self, session, port, dest, samaddr='127.0.0.1:7656', nconnect=-1, timeout=None, **kwargs)
- Tunnels localhost:port --> I2P Destination dest.
A session named 'session' is created locally, for purposes
of routing to 'dest'. nconnect and timeout are the maximum
number of connections and maximum time per connection. All
other arguments are passed to sam.socket(). This call blocks
until the tunnel is ready.
Properties defined here:
- dest
- get = 'Local Destination used for routing.'
- remotedest
- Remote Destination.
- session
- get = 'Session name for local Destination.'
Methods inherited from Tunnel:
- close(self)
- Close all connections made for this tunnel.
|
class TunnelServer(Tunnel) |
| |
Methods defined here:
- __init__(self, session, port, samaddr='127.0.0.1:7656', nconnect=-1, timeout=None, **kwargs)
- Tunnels incoming SAM streams --> localhost:port.
nconnect and timeout are the maximum number of connections
and maximum time per connection. All other arguments are
passed to sam.socket(). This call blocks until the tunnel
is ready.
Properties defined here:
- dest
- I2P Destination of server.
- session
- Session name for server.
Methods inherited from Tunnel:
- close(self)
- Close all connections made for this tunnel.
| |