Files
i2p.itoopie/apps/sam/python/doc/guide/i2p.tunnel.html
2004-08-02 13:50:21 +00:00

124 lines
3.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head><title>User's Guide:i2p.tunnel - Wikipedia</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="robots" content="index,follow">
<link rel="shortcut icon" href="/favicon.ico">
<style type='text/css'><!--
/*/*/
a.new, #quickbar a.new { color: #CC2200; }
#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }
#article { margin-left: 152px; margin-right: 4px; }
/* */
//--></style>
</head>
<body bgcolor='#FFFFFF' onload=''>
<h1 class='pagetitle'>User's Guide:i2p.tunnel</h1><p class='subtitle'>From Python-I2P.
<div class='bodytext'>
Module <code >i2p.tunnel</code > allows data to be exchanged between traditional TCP sockets and I2P sockets.
<p>
<h2><a name="Tunnels"> Tunnels </a></h2>
<p>
Tunnels allow stream sockets to be joined, so that connections to a listening socket are relayed to one or more sending sockets. This allows an ordinary web server to be exposed as an I2P Destination, or an I2P Destination to be bound as a local port, and so on.
<p>
class <strong>Tunnel</strong>(self, receive, make_send, nconnect=-1, timeout=60.0)
<ul ><pre>
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 i2p.socket.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.
</pre>
</ul >
<p>
<strong>close</strong>()
<ul >
<pre> Close all connections made for this tunnel.
</pre>
</ul >
<p>
<h3><a name="Tunnel_Server"> Tunnel Server </a></h3>
<p>
class <strong>TunnelServer</strong>(session, port, samaddr='127.0.0.1:7656', nconnect=-1, timeout=None, **kwargs)
<ul ><pre>
Tunnels incoming SAM streams --&gt; localhost:port.
nconnect and timeout are the maximum number of connections
and maximum time per connection. All other arguments are
passed to i2p.socket.socket(). This call blocks until the
tunnel is ready.
</pre>
</ul >
<p>
<strong>TunnelServer</strong> properties:
<ul ><pre>
dest - I2P Destination of server.
session - Session name for server.
</pre>
</ul >
<p>
<h3><a name="Tunnel_Client"> Tunnel Client </a></h3>
<p>
class <strong>TunnelClient</strong>(session, port, dest, samaddr='127.0.0.1:7656', nconnect=-1, timeout=None, **kwargs)
<ul ><pre>
Derived from Tunnel.
Tunnels localhost:port --&gt; 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 i2p.socket.socket(). This call
blocks until the tunnel is ready.
</pre>
</ul >
<p>
<strong>TunnelClient</strong> properties:
<ul ><pre>
dest - Local Destination used for routing.
remotedest - Remote Destination.
session - Session name for local Destination.
</pre>
</ul >
<p>
</div>
</body></html>