"""Server tunnel — exposes a local service through I2P. Ported from net.i2p.i2ptunnel.I2PTunnelServer. """ from __future__ import annotations from dataclasses import dataclass, field @dataclass class ServerTunnel: """Exposes a local service as an I2P destination. Incoming I2P connections are forwarded to local_host:local_port. """ name: str local_host: str local_port: int i2p_port: int = 0 # 0 = auto-assign running: bool = False bytes_forwarded: int = field(default=0, repr=False) def record_forwarded(self, nbytes: int) -> None: """Record bytes forwarded through the tunnel.""" self.bytes_forwarded += nbytes