mirror of
https://github.com/Such-Software/adaptive-multi-protocol-gateway.git
synced 2026-10-17 07:31:32 +02:00
Fix I2P web tunnel deployment shape
This commit is contained in:
@@ -685,14 +685,16 @@ Log notice file {state_dir / "tor.log"}
|
||||
"""
|
||||
if protocol.name == "i2p":
|
||||
port = int(protocol.options.get("local_port", 18081))
|
||||
inport = int(protocol.options.get("inport", 80))
|
||||
key_file = protocol.options.get("keys_file", f"{site.id}-web.dat")
|
||||
tunnel_name = protocol.options.get("tunnel_name", f"{site.id}-web")
|
||||
return f"""# Generated by AMPG. Review before installing.
|
||||
[{tunnel_name}]
|
||||
type = server
|
||||
type = http
|
||||
host = 127.0.0.1
|
||||
port = {port}
|
||||
keys = {state_dir / str(key_file)}
|
||||
inport = {inport}
|
||||
keys = {key_file}
|
||||
"""
|
||||
if protocol.name == "gemini":
|
||||
port = int(protocol.options.get("port", 1965))
|
||||
@@ -837,10 +839,12 @@ WantedBy=multi-user.target
|
||||
</plist>
|
||||
"""
|
||||
shell = "/data/data/com.termux/files/usr/bin/sh" if provider.name == "android-termux" else "/bin/sh"
|
||||
state_dir = _state_dir(config, provider, site, protocol)
|
||||
data_dir_setup = f"\nmkdir -p {state_dir / 'data'}" if protocol.name == "i2p" else ""
|
||||
return f"""#!{shell}
|
||||
# Generated by AMPG. Review before installing.
|
||||
set -eu
|
||||
mkdir -p {_state_dir(config, provider, site, protocol)}
|
||||
mkdir -p {state_dir}{data_dir_setup}
|
||||
{command}
|
||||
"""
|
||||
|
||||
|
||||
+3
-1
@@ -148,14 +148,16 @@ HiddenServicePort 80 127.0.0.1:{port}
|
||||
|
||||
def _i2pd_artifact(site: SiteConfig, protocol: ProtocolConfig) -> PlanArtifact:
|
||||
port = int(protocol.options.get("local_port", 18081))
|
||||
inport = int(protocol.options.get("inport", 80))
|
||||
key_file = protocol.options.get("keys_file", f"{site.id}-web.dat")
|
||||
tunnel_name = protocol.options.get("tunnel_name", f"{site.id}-web")
|
||||
path = _protocol_plan_dir(site, protocol) / "i2pd-tunnel.conf"
|
||||
content = f"""# Generated by AMPG. Review before installing.
|
||||
[{tunnel_name}]
|
||||
type = server
|
||||
type = http
|
||||
host = 127.0.0.1
|
||||
port = {port}
|
||||
inport = {inport}
|
||||
keys = {key_file}
|
||||
"""
|
||||
return PlanArtifact(path=path, content=content)
|
||||
|
||||
@@ -210,7 +210,7 @@ def _i2p_contract(
|
||||
site,
|
||||
protocol,
|
||||
role="identity-key",
|
||||
path=state_dir / key_file,
|
||||
path=state_dir / "data" / key_file,
|
||||
owner="daemon",
|
||||
required=True,
|
||||
sensitive=True,
|
||||
|
||||
@@ -59,7 +59,7 @@ daemon_policy = "auto"
|
||||
local_port = 18181
|
||||
keys_file = "ampgateway-online-web.dat"
|
||||
tunnel_name = "ampgateway-online-web"
|
||||
i2p_url = "http://vfhcumcxtbysxr6wvbpdytb6jpslcqlo3j6e35w7s63el5vsorca.b32.i2p/"
|
||||
i2p_url = "http://veyotzzzjal5acfkjsoeuzvt45s3hynr55rmrt6hotwcdlwmbfia.b32.i2p/"
|
||||
max_asset_bytes = 1048576
|
||||
script_policy = "strip"
|
||||
|
||||
@@ -125,7 +125,7 @@ daemon_policy = "auto"
|
||||
local_port = 18281
|
||||
keys_file = "ampgateway-site-web.dat"
|
||||
tunnel_name = "ampgateway-site-web"
|
||||
i2p_url = "http://zajoo4f5dso64tvtazas27se2galkihgpfgoy636uxm7loo42cdq.b32.i2p/"
|
||||
i2p_url = "http://ipahplmdbdwa23wpslqfylghlbqdlmsh23cj64fsvbp3lftxozka.b32.i2p/"
|
||||
max_asset_bytes = 1048576
|
||||
script_policy = "strip"
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
<div class="transport-links" aria-label="ampgateway.online transport links">
|
||||
<a class="transport-link" href="https://ampgateway.online/">Clearnet</a>
|
||||
<a class="transport-link" href="http://bn5uppe4zrop2ljsmjtoxtc4bhzs42kj4c6zvme565gz6x6l32ico3id.onion/">Tor onion</a>
|
||||
<a class="transport-link" href="http://vfhcumcxtbysxr6wvbpdytb6jpslcqlo3j6e35w7s63el5vsorca.b32.i2p/">I2P b32</a>
|
||||
<a class="transport-link" href="http://veyotzzzjal5acfkjsoeuzvt45s3hynr55rmrt6hotwcdlwmbfia.b32.i2p/">I2P b32</a>
|
||||
</div>
|
||||
</article>
|
||||
<article class="domain-card">
|
||||
@@ -217,7 +217,7 @@
|
||||
<div class="transport-links" aria-label="ampgateway.site transport links">
|
||||
<a class="transport-link" href="https://ampgateway.site/">Clearnet</a>
|
||||
<a class="transport-link" href="http://fy2zosxp4oqqcacxcegvwshtmsiiyztnwoinbm46yoig4o3kveidotyd.onion/">Tor onion</a>
|
||||
<a class="transport-link" href="http://zajoo4f5dso64tvtazas27se2galkihgpfgoy636uxm7loo42cdq.b32.i2p/">I2P b32</a>
|
||||
<a class="transport-link" href="http://ipahplmdbdwa23wpslqfylghlbqdlmsh23cj64fsvbp3lftxozka.b32.i2p/">I2P b32</a>
|
||||
</div>
|
||||
</article>
|
||||
<article class="domain-card">
|
||||
|
||||
@@ -181,9 +181,9 @@
|
||||
<span>Tor onion</span>
|
||||
<strong>fy2zosxp4oqqcacxcegvwshtmsiiyztnwoinbm46yoig4o3kveidotyd.onion</strong>
|
||||
</a>
|
||||
<a href="http://zajoo4f5dso64tvtazas27se2galkihgpfgoy636uxm7loo42cdq.b32.i2p/">
|
||||
<a href="http://ipahplmdbdwa23wpslqfylghlbqdlmsh23cj64fsvbp3lftxozka.b32.i2p/">
|
||||
<span>I2P b32</span>
|
||||
<strong>zajoo4f5dso64tvtazas27se2galkihgpfgoy636uxm7loo42cdq.b32.i2p</strong>
|
||||
<strong>ipahplmdbdwa23wpslqfylghlbqdlmsh23cj64fsvbp3lftxozka.b32.i2p</strong>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -226,12 +226,12 @@ tunnel_name = "example-web"
|
||||
set(by_name),
|
||||
)
|
||||
self.assertIn("[example-web]", by_name["i2pd-tunnels.conf"].content)
|
||||
self.assertIn(
|
||||
f"keys = {root / '.ampg/state/example/i2p/example-web.dat'}",
|
||||
by_name["i2pd-tunnels.conf"].content,
|
||||
)
|
||||
self.assertIn("type = http", by_name["i2pd-tunnels.conf"].content)
|
||||
self.assertIn("inport = 80", by_name["i2pd-tunnels.conf"].content)
|
||||
self.assertIn("keys = example-web.dat", by_name["i2pd-tunnels.conf"].content)
|
||||
self.assertIn("listen 127.0.0.1:19081", by_name["nginx-loopback.conf"].content)
|
||||
self.assertIn(f"mkdir -p {root / '.ampg/state/example/i2p'}", by_name["i2pd.run"].content)
|
||||
self.assertIn(f"mkdir -p {root / '.ampg/state/example/i2p/data'}", by_name["i2pd.run"].content)
|
||||
self.assertIn("exec i2pd", by_name["i2pd.run"].content)
|
||||
self.assertIn("exec nginx", by_name["nginx-loopback.run"].content)
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ port = 1965
|
||||
self.assertIn("HiddenServicePort 80 127.0.0.1:19080", torrc.read_text())
|
||||
self.assertIn("listen 127.0.0.1:19080;", tor_nginx.read_text())
|
||||
self.assertIn("[example-web]", i2p_tunnel.read_text())
|
||||
self.assertIn("type = http", i2p_tunnel.read_text())
|
||||
self.assertIn("inport = 80", i2p_tunnel.read_text())
|
||||
self.assertIn("keys = example-web.dat", i2p_tunnel.read_text())
|
||||
self.assertIn("listen 127.0.0.1:19081;", i2p_nginx.read_text())
|
||||
self.assertIn("daemon = agate", agate_plan.read_text())
|
||||
|
||||
@@ -64,7 +64,7 @@ keys_file = "example-web.dat"
|
||||
|
||||
by_role_path = {(contract.role, contract.path) for contract in contracts}
|
||||
self.assertIn(("daemon-config", root / "state/example/i2p/i2pd-tunnels.conf"), by_role_path)
|
||||
self.assertIn(("identity-key", root / "state/example/i2p/example-web.dat"), by_role_path)
|
||||
self.assertIn(("identity-key", root / "state/example/i2p/data/example-web.dat"), by_role_path)
|
||||
self.assertIn(("address-file", root / "state/example/i2p/hostname.txt"), by_role_path)
|
||||
sensitive = {contract.role for contract in contracts if contract.sensitive}
|
||||
self.assertEqual({"identity-key"}, sensitive)
|
||||
|
||||
Reference in New Issue
Block a user