The shadowsocks userinfo, the vmess body and the SSR link trimmed a single "="
from their base64, so a value that needed two padding characters was exported
with one left over. A strict decoder rejects that, and a lenient one decodes
the stray character as data: editing such a shadowsocks node in the GUI turned
its password into "test\r..." because the escaped "=" reached the decoder.
Defaulting the port made an absent port legal, and with it a link that carries
no host at all: `socks5://` was accepted and stored as a node with an empty
server, where the previous port conversion had rejected it.
A Reality VLESS proxy carries reality-opts.spider-x and a TLS VMess proxy
carries client-fingerprint; both were dropped by the mapping, so the imported
node handshook with an empty spider path and the default fingerprint and the
provider's server could refuse it.
The GUI shows backend error text as is, so errors were never localized.
common.Coded wraps an error with a stable code and scalar parameters;
ResponseError adds "errorCode" and "params" next to the unchanged English
"message" when the chain carries one. Thirty-two user-facing errors are
coded (no server selected, core start failure, port occupied, malformed
link with protocol and detail, subscription fetch failure with host,
server/subscription not found with ids, bad request with the field,
credentials, session, admin, request in progress, GFW list missing,
invalid config, asset download, transparent setup, mux range, custom
inbound fields). logError now keeps the error chain instead of
flattening it. Messages, status codes and control flow are unchanged; the
two strings the GUI matches on stay as they are.
tools_test.go becomes an external test package so the common tests
compile again; its FillEmpty equality assertion, which never ran before,
is skipped with the reason.
Errors that reach the GUI were written for the log: "ResolveURL failed:
invalid parameters", "httpGetUsingSpecificClient: response is nil",
"LocateServerRaw: invalid TYPE", "bad request", "illegal base64 data at
input byte 18". Reword the messages that can reach a user so each names
the input that was rejected (link scheme, missing password, port, server
id, request field), states the expected form for malformed input, drops
Go function names, keeps the %w chain so errors.Is/As still work, and
never echoes passwords, tokens or full share links (hosts only).
Messages the GUI string-matches ("invalid config", "the last request is
being processed") are unchanged.
ParseSSURL read the userinfo re-percent-escaped through u.User.String()
and decoded only the URL-safe alphabet, so SIP002 links with a standard
alphabet failed and keys containing "/" were stored encoded; accept both
alphabets, padded or not, and the raw method:password form. ParseSocksURL
ran Atoi on the port before its 1080 default, rejecting socks5://host.
ParseVlessURL stored the id re-escaped, so non-UUID ids with spaces or
non-ASCII were hashed encoded and double-encoded on export. The VLESS
exporter dropped idleTimeout, healthCheckTimeout, permitWithoutStream and
initialWindowsSize for gRPC although the parser reads them. Tests cover
each case.
ParseTuicURL read the certificate pin and name verification only as
pinnedPeerCertSha256/verifyPeerCertByName while the GUI form and other
clients emit pinned_peer_cert_sha256/verify_peer_cert_by_name, so a pin
typed into the form was dropped. ParseTrojanURL read host only for the
trojan-go scheme although ConfigurationMC uses it as the WebSocket Host
header for plain trojan as well.
ImportSubscription redeclared err with := inside the block, so a failure
of AppendSubscriptions was assigned to the shadow and the function
returned nil.
ParseHttpURL ran strconv.Atoi on the port before the per-scheme default,
so a link without a port failed with "invalid parameters" and the
Port == 0 branches were unreachable. Parse the port only when present.
A proxy link never carries a path or query; one that does is a
subscription URL pasted into the server box. Reject it with a message
that says so instead of the bare parameter error.
A subscription that serves a Clash config went through the line parser,
which picked up a stray URL from the rules and produced a "successful"
subscription holding one bogus http node. Detect a YAML body with a
proxies list and map each proxy onto the share link v2rayA already parses
for its type: anytls, trojan, vless, vmess, ss (obfs and v2ray-plugin),
ssr, hysteria2, tuic, socks5 and http. Unsupported types are counted in
the log; a config with no usable proxy fails the import instead of
storing an empty subscription.
u.User.String() returns URL-encoded userinfo, causing the password to be
incorrectly stored when it contains special characters like '/'. For
example, a password of '/' would be stored as '%2F'.
Switch to u.User.Password() which returns the decoded password directly,
consistent with how juicity, hysteria2, http, and socks5 handle it.