A Python port of the Invisible Internet Project (I2P)
at main 27 lines 681 B view raw
1"""Server tunnel — exposes a local service through I2P. 2 3Ported from net.i2p.i2ptunnel.I2PTunnelServer. 4""" 5 6from __future__ import annotations 7 8from dataclasses import dataclass, field 9 10 11@dataclass 12class ServerTunnel: 13 """Exposes a local service as an I2P destination. 14 15 Incoming I2P connections are forwarded to local_host:local_port. 16 """ 17 18 name: str 19 local_host: str 20 local_port: int 21 i2p_port: int = 0 # 0 = auto-assign 22 running: bool = False 23 bytes_forwarded: int = field(default=0, repr=False) 24 25 def record_forwarded(self, nbytes: int) -> None: 26 """Record bytes forwarded through the tunnel.""" 27 self.bytes_forwarded += nbytes