diff --git a/ampg/install_plan.py b/ampg/install_plan.py index 1b10ebe..d9b38df 100644 --- a/ampg/install_plan.py +++ b/ampg/install_plan.py @@ -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 """ 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} """ diff --git a/ampg/plan.py b/ampg/plan.py index 367c87e..0cce417 100644 --- a/ampg/plan.py +++ b/ampg/plan.py @@ -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) diff --git a/ampg/state_contract.py b/ampg/state_contract.py index 305bc0a..3b05a09 100644 --- a/ampg/state_contract.py +++ b/ampg/state_contract.py @@ -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, diff --git a/examples/ampgateway-online.gateway.toml b/examples/ampgateway-online.gateway.toml index 08406dd..2c1633d 100644 --- a/examples/ampgateway-online.gateway.toml +++ b/examples/ampgateway-online.gateway.toml @@ -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" diff --git a/sites/ampgateway-online/index.html b/sites/ampgateway-online/index.html index 2f91536..1f15d06 100644 --- a/sites/ampgateway-online/index.html +++ b/sites/ampgateway-online/index.html @@ -204,7 +204,7 @@
@@ -217,7 +217,7 @@
diff --git a/sites/ampgateway-site/index.html b/sites/ampgateway-site/index.html index 376f620..388f32b 100644 --- a/sites/ampgateway-site/index.html +++ b/sites/ampgateway-site/index.html @@ -181,9 +181,9 @@ Tor onion fy2zosxp4oqqcacxcegvwshtmsiiyztnwoinbm46yoig4o3kveidotyd.onion - + I2P b32 - zajoo4f5dso64tvtazas27se2galkihgpfgoy636uxm7loo42cdq.b32.i2p + ipahplmdbdwa23wpslqfylghlbqdlmsh23cj64fsvbp3lftxozka.b32.i2p diff --git a/tests/test_install_plan.py b/tests/test_install_plan.py index da24fe2..ce5aeb3 100644 --- a/tests/test_install_plan.py +++ b/tests/test_install_plan.py @@ -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) diff --git a/tests/test_plan_artifacts.py b/tests/test_plan_artifacts.py index 805bcd1..543cccb 100644 --- a/tests/test_plan_artifacts.py +++ b/tests/test_plan_artifacts.py @@ -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()) diff --git a/tests/test_state_contract.py b/tests/test_state_contract.py index f4d3e20..235fbdc 100644 --- a/tests/test_state_contract.py +++ b/tests/test_state_contract.py @@ -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)