gowalk-cicd 1.0.111 → 1.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -143,6 +143,8 @@ node /path/to/gowalk-cicd/bin/cli.mjs
143
143
  Crashlytics Buildtools reads them first and rejects authenticated proxy URLs. HTTPS is tunneled
144
144
  without TLS interception; no upstream failure may fall back to the destination.
145
145
  The wrapper disables Gradle daemons and closes its relay when the command ends.
146
+ The relay's idle deadline covers the whole tunnel: traffic in either direction
147
+ keeps downloads/uploads alive. An idle direction alone must never end a transfer.
146
148
  - Flutter bootstrap is part of that boundary: before the Flutter setup action,
147
149
  `play_store_proxy.py --bootstrap-env` validates the Google account pin and writes
148
150
  both proxy/bypass spellings to the private job environment without console output.
@@ -1 +1 @@
1
- 1.0.111
1
+ 1.0.112
@@ -1 +1 @@
1
- 1.0.111
1
+ 1.0.112
@@ -13,8 +13,8 @@ import threading
13
13
  from urllib.parse import unquote, urlsplit
14
14
 
15
15
 
16
- # A tunnel carries whole SDK/NDK/CMake downloads and Gradle's keep-alive pools; an
17
- # idle read is not a failure, so pumps wait long and the tunnel closes cleanly.
16
+ # A tunnel carries whole SDK/NDK/CMake downloads and Gradle's keep-alive pools.
17
+ # Only inactivity in both directions expires it; a download may send no requests.
18
18
  IDLE_TIMEOUT = 900.0
19
19
 
20
20
 
@@ -63,11 +63,16 @@ class Relay:
63
63
  await writer.drain()
64
64
  return reader, writer
65
65
 
66
- async def _pump(self, reader, writer):
67
- while data := await asyncio.wait_for(reader.read(65536), timeout=IDLE_TIMEOUT):
66
+ async def _pump(self, reader, writer, activity):
67
+ while data := await reader.read(65536):
68
+ activity[0] = self.loop.time()
68
69
  writer.write(data)
69
70
  await writer.drain()
70
71
 
72
+ async def _idle(self, activity):
73
+ while remaining := max(0.0, activity[0] + IDLE_TIMEOUT - self.loop.time()):
74
+ await asyncio.sleep(remaining)
75
+
71
76
  async def _handle(self, reader, writer):
72
77
  upstream = None
73
78
  pumps = []
@@ -82,8 +87,10 @@ class Relay:
82
87
  writer.write(b"HTTP/1.1 200 Connection established\r\n\r\n")
83
88
  await writer.drain()
84
89
  established = True
85
- pumps = [asyncio.create_task(self._pump(reader, upstream)),
86
- asyncio.create_task(self._pump(upstream_reader, writer))]
90
+ activity = [self.loop.time()]
91
+ pumps = [asyncio.create_task(self._pump(reader, upstream, activity)),
92
+ asyncio.create_task(self._pump(upstream_reader, writer, activity)),
93
+ asyncio.create_task(self._idle(activity))]
87
94
  await asyncio.wait(pumps, return_when=asyncio.FIRST_COMPLETED)
88
95
  except (OSError, ValueError, IndexError, asyncio.TimeoutError,
89
96
  asyncio.IncompleteReadError, asyncio.LimitOverrunError):
@@ -0,0 +1,106 @@
1
+ """A live tunnel stays open for one-way traffic and closes on total inactivity."""
2
+ from contextlib import contextmanager
3
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
4
+ import socket
5
+ import threading
6
+ import unittest
7
+ from unittest import mock
8
+
9
+ import jvm_proxy_relay as relay
10
+
11
+
12
+ PAYLOAD = bytes(range(24))
13
+ INTERVAL = 0.075
14
+
15
+
16
+ @contextmanager
17
+ def tunnel(mode):
18
+ stop = threading.Event()
19
+ finished = threading.Event()
20
+ received = []
21
+
22
+ class Proxy(BaseHTTPRequestHandler):
23
+ def do_CONNECT(self):
24
+ self.send_response(200)
25
+ self.end_headers()
26
+ try:
27
+ if mode == "download":
28
+ for value in PAYLOAD:
29
+ self.wfile.write(bytes([value]))
30
+ if stop.wait(INTERVAL):
31
+ break
32
+ else:
33
+ value = self.rfile.read(len(PAYLOAD))
34
+ received.append(value)
35
+ if mode == "upload":
36
+ self.wfile.write(value)
37
+ except OSError:
38
+ pass
39
+ finally:
40
+ finished.set()
41
+
42
+ def log_message(self, *_):
43
+ pass
44
+
45
+ server = ThreadingHTTPServer(("127.0.0.1", 0), Proxy)
46
+ server.daemon_threads = True
47
+ thread = threading.Thread(target=server.serve_forever, daemon=True)
48
+ thread.start()
49
+ try:
50
+ yield f"http://127.0.0.1:{server.server_port}", finished, received
51
+ finally:
52
+ stop.set()
53
+ server.shutdown()
54
+ server.server_close()
55
+ thread.join(timeout=5)
56
+
57
+
58
+ @contextmanager
59
+ def client(port):
60
+ with socket.create_connection(("127.0.0.1", port), timeout=5) as connection:
61
+ with connection.makefile("rb") as stream:
62
+ connection.sendall(b"CONNECT unresolvable.invalid:443 HTTP/1.1\r\nHost: ignored\r\n\r\n")
63
+ assert b"200" in stream.readline()
64
+ while stream.readline() != b"\r\n":
65
+ pass
66
+ yield connection, stream
67
+
68
+
69
+ class TunnelActivityTests(unittest.TestCase):
70
+ def test_download_outlives_idle_deadline_without_client_traffic(self):
71
+ with tunnel("download") as (proxy, finished, _), mock.patch.object(relay, "IDLE_TIMEOUT", 1.0):
72
+ with relay.running(proxy) as port, client(port) as (_, stream):
73
+ self.assertEqual(stream.read(len(PAYLOAD)), PAYLOAD)
74
+ self.assertTrue(finished.wait(5))
75
+
76
+ def test_upload_outlives_idle_deadline_without_server_traffic(self):
77
+ with tunnel("upload") as (proxy, finished, received), mock.patch.object(relay, "IDLE_TIMEOUT", 1.0):
78
+ with relay.running(proxy) as port, client(port) as (connection, stream):
79
+ for value in PAYLOAD:
80
+ connection.sendall(bytes([value]))
81
+ threading.Event().wait(INTERVAL)
82
+ self.assertEqual(stream.read(len(PAYLOAD)), PAYLOAD)
83
+ self.assertTrue(finished.wait(5))
84
+ self.assertEqual(received, [PAYLOAD])
85
+
86
+ def test_wholly_idle_tunnel_closes_without_http_bytes(self):
87
+ with tunnel("idle") as (proxy, finished, received), mock.patch.object(relay, "IDLE_TIMEOUT", 0.2):
88
+ with relay.running(proxy) as port, client(port) as (_, stream):
89
+ self.assertEqual(stream.read(), b"")
90
+ self.assertTrue(finished.wait(5))
91
+ self.assertEqual(received, [b""])
92
+
93
+ def test_owner_exit_closes_active_clients_and_upstream(self):
94
+ with tunnel("idle") as (proxy, finished, received):
95
+ with relay.running(proxy) as port:
96
+ connection = socket.create_connection(("127.0.0.1", port), timeout=5)
97
+ connection.sendall(b"CONNECT unresolvable.invalid:443 HTTP/1.1\r\n\r\n")
98
+ self.assertIn(b"200", connection.recv(4096))
99
+ with connection:
100
+ self.assertEqual(connection.recv(4096), b"")
101
+ self.assertTrue(finished.wait(5))
102
+ self.assertEqual(received, [b""])
103
+
104
+
105
+ if __name__ == "__main__":
106
+ unittest.main()
@@ -1 +1 @@
1
- 1.0.111
1
+ 1.0.112
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gowalk-cicd",
3
- "version": "1.0.111",
3
+ "version": "1.0.112",
4
4
  "description": "Zero-config GitHub Actions delivery for iOS TestFlight and Android Google Play.",
5
5
  "type": "module",
6
6
  "bin": {