Commit Graph

131 Commits

Author SHA1 Message Date
testercengdong
d69b95dbbc fix(macos,process_info): tighten error handling and add endian assert
- Guard against `getProcess` returning null in the macOS FFI path
  (`proc_pidpath` can fail with EPERM or for an already-exited PID).
  Stop unwrapping with `!` and only populate the ProcessInfoCache on
  success; the previous code threw NullThrownError there, which the
  outer try/catch silently swallowed and prevented caching of valid
  later results.
- Add a 5-second negative cache for ports whose owner can't be
  resolved (typical for short-lived clients that exited before we
  scanned). Without it every such request triggered a full PID list
  rescan, defeating the point of the pid cache for the failure path.
- Add a debug-only assert that the host is little-endian. The libproc
  parsing reads `(int)htons(port)` by treating the low two bytes as a
  big-endian uint16, which requires a little-endian host. All shipping
  macOS hardware satisfies this; the assert fails loudly if the
  assumption is ever broken (stripped from release builds).

Re-verified on macOS 26.4: 500 concurrent curl through the proxy,
single ProxyPin process throughout, 9099 freed immediately on exit.
2026-05-12 10:16:42 +08:00
testercengdong
ad89ec6aec fix(macos,process_info): address Copilot review feedback
- Add 30s (host:port) -> pid cache in ProcessInfoUtils so the synchronous
  libproc scan stays off the request hot path for keep-alive flows
  (typical HTTP client reuses the same source port across requests in
  a connection).
- Lift sockView ByteData out of the inner fd loop so the buffer wrapper
  is reused across all fds in a scan (saves per-fd allocations).
- Bail out of the scan after 16 consecutive proc_pidfdinfo size
  mismatches, in case a future macOS bumps the socket_fdinfo layout --
  avoids wasted syscalls instead of scanning every fd just to return
  null at the end.

Re-verified end-to-end on macOS 26.4: 500 concurrent curl, 0 fork
leaks, 9099 freed immediately on app exit, no errors in logs.
2026-05-12 09:38:02 +08:00
testercengdong
202050b35f fix(macos): use libproc FFI for process info to eliminate fork leak
Replace Process.run('lsof') and Process.run('ps') in the request hot
path with direct libproc syscalls (proc_listpids, proc_pidinfo,
proc_pidfdinfo, proc_pidpath) via dart:ffi.

Each Process.run on macOS goes through fork()+execvp(). In a
multi-threaded Dart VM the forked child can deadlock before exec on
mutexes that were held by other threads at fork time (POSIX fork()
only clones the calling thread, leaving cloned mutex state with no
owners in the child). Under proxy load (~500 concurrent requests),
roughly 2% of the fork()s deadlock; the orphaned children inherit the
listening proxy fd and pin it for the lifetime of the system, so the
port stays bound even after the parent app exits.

libproc syscalls do not spawn child processes, so they avoid the fork
problem entirely. They are also about an order of magnitude faster
than spawning lsof per request.

Windows and Linux paths are unchanged (independent follow-up).

Verified end-to-end on macOS 26.4 / Darwin 25.4:
- 500 concurrent curl through the proxy: 0 fork leaks (was ~2% before)
- Process icons still resolve correctly for .app bundles (Chrome,
  Safari, Lark, etc.)
- 9099 frees immediately on app exit (no orphan listeners)

Fixes #763
2026-05-11 15:23:59 +08:00
wanghongenpin
654d27667a feat: implement batch processing for remote history sharing 2026-03-30 03:12:41 +08:00
wanghongenpin
1aff89ed8c feat: implement quick share functionality for remote devices 2026-03-29 02:14:19 +08:00
wanghongenpin
69cc1aff8d refactor: enhance auto-read request management 2026-03-25 01:29:50 +08:00
wanghongenpin
3c4b97380d Refactor request breakpoint handling to use ExpiringCache for paused requests and responses 2026-02-28 21:22:25 +08:00
wanghongenpin
d4465bcd29 implement request and response breakpoint functionality with UI integration (#669)(#660)(#386) 2026-02-18 22:59:01 +08:00
wanghongenpin
c4d3421373 ios proxy pass domains (#527) 2026-02-15 01:25:05 +08:00
wanghongenpin
a3e744ee2e android proxy pass domains (#527) 2026-02-08 12:45:24 +08:00
wanghongenpin
b838bf73b9 fix mac set system proxy (#672) 2026-02-06 16:15:03 +08:00
wanghongenpin
e9574e7abc Add zlib decoding support and fix encoding order in HTTP response handling 2026-01-30 12:14:19 +08:00
wanghongenpin
0012116fa0 Add localization support for remote script management 2026-01-17 07:07:38 +08:00
wanghongenpin
b1220e18ef macos set system proxy with osascript privileges 2026-01-14 23:49:07 +08:00
wanghongenpin
f37330a517 The script supports multiple URL matching 2025-09-23 22:43:28 +08:00
wanghongenpin
3cc7d8d303 IOS certificate installation detection and guidance 2025-09-21 20:09:40 +08:00
wanghongenpin
4e44921775 initCAConfig 2025-09-19 19:55:22 +08:00
wanghongenpin
f861beaa88 Windows Automatic Install Certificate 2025-09-18 23:55:23 +08:00
wanghongenpin
95dbae3684 cert cache 2025-08-26 06:47:25 +08:00
wanghongenpin
3382c06311 certs 2025-08-11 01:45:54 +08:00
wanghongenpin
6018b92a3c http2 authority 2025-05-31 03:57:58 +08:00
wanghongenpin
ae095b121e h2 stream dependency Sequential exec (#388)(#51) 2025-05-15 20:13:13 +08:00
wanghongenpin
c94ff7eba9 http2 streamDependency (#388)(#51) 2025-05-12 19:20:07 +08:00
wanghongenpin
493fcc3ea0 support proxy http2 (#388)(#51) 2025-05-07 14:50:55 +08:00
wanghongenpin
ea07881b6f encoding support zstd (#459)(#455)(#404) 2025-05-05 18:05:24 +08:00
wanghongenpin
c40a61a288 FLV live stream directly forward (#432) 2025-04-06 02:40:58 +08:00
wanghongenpin
b663b2d1ef image save 2025-01-16 18:16:10 +08:00
wanghongenpin
827e6fe0d8 socks5 (#291) 2025-01-15 01:36:00 +08:00
wanghongenpin
12ab378ced fix history record import (#400) 2025-01-13 01:49:42 +08:00
wanghongenpin
8738e5643d fix script url query convert 2024-11-12 09:29:15 +08:00
wanghongenpin
7a00960d71 Fixed script URL encoding issue 2024-11-11 17:46:55 +08:00
wanghongenpin
06918b4621 rewrite、script、block Interceptor 2024-11-03 02:01:19 +08:00
wanghongenpin
47e6c51813 Remove basic_utils dependency 2024-10-29 01:31:50 +08:00
wanghongenpin
4588d829f6 Change the project name to 'proxypin' 2024-10-25 17:57:20 +08:00
wanghongenpin
6069cf7233 iOS Generate new root certificate 2024-10-21 17:55:48 +08:00
wanghongenpin
26db48c02a js script Integrate md5('xxxx') method #307 2024-10-18 10:57:40 +08:00
wanghongenpin
a942460110 request rewrites file select suffix 2024-10-16 00:10:33 +08:00
wanghongenpin
65c8d24a70 CA Hash Name 2024-10-15 01:20:42 +08:00
wanghongenpin
76d844f65e qr code encode 2024-10-13 12:32:41 +08:00
wanghongenpin
05667189a8 ios IP Layer Proxy, Support capturing Flutter applications (#215) 2024-10-10 18:58:47 +08:00
wanghongenpin
be81174f9f Custom repeat supports sending at a specified time 2024-09-27 17:27:54 +08:00
wanghongenpin
330cc7e7fb Fix request rewrite batch import rule confusion (#311) 2024-09-27 11:08:37 +08:00
wanghongenpin
eef651d286 http body charset && script add rawBody byte array (#304) 2024-09-14 00:47:31 +08:00
wanghongenpin
5979bd5c7e external proxy support authentication (#303) 2024-09-11 23:42:04 +08:00
wanghongenpin
861f7238af Double-click the list tab to scroll to the top 2024-09-02 02:38:46 +08:00
wanghongenpin
dc455263a6 Fix the issue of partial p12 certificate import failure (#269) 2024-09-01 07:23:26 +08:00
wanghongenpin
debec047c9 Optimize certificate initialization & repair window mode to open package capture 2024-08-26 00:07:53 +08:00
wanghongenpin
95c01c3ed2 fix script binary body convert (#274) 2024-08-08 23:31:23 +08:00
wanghongenpin
04215af421 Import Root Certificate(.p12) (#185) 2024-07-29 00:59:07 +08:00
wanghongenpin
f4e3489ac1 History supports replaying all requests (#246) 2024-07-28 21:17:42 +08:00