4 Commits
Author SHA1 Message Date
yuanyuanxianganddeepseek-flash 5bff9df3fc Improve: Harden the self-implemented SOCKS5 proxy listener
Follow-up to the HP-Socket replacement: the four items the first pass
deliberately left out, plus two defects that the new tests turned up.

The listener now binds 127.0.0.1 instead of INADDR_ANY. The dialog only
ever points the user (and the Chrome shortcut) at 127.0.0.1, and an
unauthenticated SOCKS5 port open on every interface is an open proxy.

The SOCKS5 handshake is parsed as a byte stream. The previous code
assumed one callback carried exactly one message, which happens to hold
for curl and Chrome but not in general: a greeting split across segments
was answered twice, and a CONNECT request followed by tunnel data in the
same read dropped the trailing bytes. Each connection now keeps a pending
buffer and a four-state machine (greeting, request, connecting, tunnel),
and bytes that arrive before CONNECT_RESULT are replayed to the client
once the tunnel opens, after the SOCKS5 reply.

Flow control: the listener takes a PROXYCANRECVPROC callback that is
consulted before each recv. The dialog answers it from the main
connection's send queue, so a download that outruns the client link
pauses the local read instead of growing the server's buffer. A 300MB
transfer through the tunnel peaks 150KB above the idle working set.

Handshake watchdog: sessions that stall in greeting/request/connecting
are dropped after 30 seconds; established tunnels are left alone.

Two defects in the log path, both surfaced by the watchdog test. Logging
every 32KB chunk produced roughly 9000 posted messages for a 300MB
transfer, which starved the UI thread's timers (the first watchdog run
never fired) and could overflow the message queue; and every line re-set
the whole 256KB text into the read-only edit. Transfers now log
cumulative progress once per second and a per-connection total at
teardown, panes are refreshed at most every 100ms from a dirty flag, and
a failed PostMessage no longer leaks its CString.

Localization: the new session-log strings were also added to en_US.ini,
zh_TW.ini and de_DE.ini (16 keys each, GBK, kept in the existing
FormatL section). Two of the lines were reworded instead of translated
as-is: the close notice now says what happened (the client asked to
close, or the downlink send failed) rather than printing the protocol
token name, and the throughput arrows are now << and >> because
CIniParser splits an entry at the first '=', so the old <== and ==>
could never have served as keys.

Testing: curl IPv4 and hostname tunnels, 4MB and 300MB transfers
byte-identical, byte-at-a-time and pipelined handshakes, refused target
(REP=5), SOCKS client killed mid-transfer, client process killed
mid-transfer (dialog closes, port released), 20 parallel connections,
five open/close cycles with no handle or thread growth, and the 30s
handshake timeout. The dialog log was checked at runtime with
Language=en_US and renders in English only.

Co-Authored-By: deepseek-flash
2026-10-29 16:12:14 +01:00
yuanyuanxianganddeepseek-flash 45e1dd9f6c Feature: Implement the proxy mapping listener without HP-Socket
The proxy mapping dialog ("代理映射") depended on HP-Socket: three vendored
SDK headers (4787 lines) plus #pragma comment(lib) lines pulling in four
prebuilt lib/DLL variants, all guarded by ENABLE_HPSOCKET, which has been 0
since the initial commit -- so the feature was dead code that only answered
"This feature is unavailable due to HPSocket disabled" and no build of this
repository ever ran it.

Replace that dependency with a small listener built on blocking sockets and
select, which is the same approach the client's CProxyManager and the
server's own SimpleWebSocket already take. The accept loop polls every
200 ms so Shutdown can return without closing a socket another thread is
selecting on, and each accepted connection gets a relay thread that only
has to recv and hand bytes to the dialog. Connection sockets are closed by
their relay thread alone; Disconnect only raises a stop flag and calls
shutdown() under the same lock the relay thread takes before closesocket,
so a recycled handle is never shut down by mistake. Finished threads are
parked in a graveyard and joined by the accept thread, which keeps the
thread handle count flat across open/close cycles.

ProxyMapDlg keeps the SOCKS5 state machine it had, but now stores its
per-connection state in a map keyed by the connection id instead of
relying on HP-Socket's GetConnectionExtra, and it logs through a posted
window message rather than touching CEdit from worker threads. The two log
panes in IDD_PROXY are ES_READONLY, so EM_REPLACESEL was silently ignored
(the original code had the same latent bug); the dialog now keeps the pane
text itself and writes it with SetWindowText, bounded to 256 KB per pane.

The vcxproj and filters lose the three SDK headers, and the dialog gate in
OnOpenProxyDialog loses its ENABLE_HPSOCKET check.

Tested against a Debug server with a Debug Windows client on the same
host: curl through the listener succeeds over both the IPv4 and the
hostname ATYP paths, a 4 MB transfer arrives byte-identical, a refused
target maps to SOCKS5 reply 5, killing the client mid-transfer closes the
dialog and releases the port, and five open/close cycles leave the server's
handle and thread counts unchanged.

Co-Authored-By: deepseek-flash
2026-10-29 15:37:16 +01:00
yuanyuanxianganddeepseek-v4-pro 221617fe02 Fix: Translate remaining server UI strings missing _TR/_L
Wrap the last untranslated Chinese UI strings so English mode stops showing
raw Chinese. Format strings passed to sprintf/wsprintf and the status-bar
SendMessageTimeout calls now go through _TRF, and the CString/PostMessage
literals plus a few member-initializer and Compare values go through
_TR/_L. Covers the wallet validation message, the SOCKS proxy connection
log lines, the file-manager status bar, and the machine-info progress
messages.

Add the 24 corresponding entries to lang/en_US.ini and lang/zh_TW.ini
(GBK), keeping the escaped-format-string key style. The Yes/No/Desktop/
Recent keys already existed, so the BuildDlg and CFileManagerDlg compare
fixes reuse them.

Co-Authored-By: deepseek-v4-pro
2026-09-06 09:39:59 +02:00
yuanyuanxiang 5a325a202b Init: Migrate SimpleRemoter (Since v1.3.1) to Gitea 2026-04-19 22:55:21 +02:00