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