Skip to content

fix(fmt): default the AnyTLS and Naive port to 443 when the link omits it - #10504

Merged
2dust merged 1 commit into
2dust:masterfrom
b84330808:fix-anytls-naive-default-port
Nov 3, 2026
Merged

2dust merged 1 commit into
2dust:masterfrom
b84330808:fix-anytls-naive-default-port

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

The AnyTLS URI scheme (https://github.com/anytls/anytls-go/blob/main/docs/uri_scheme.md) makes the port optional — "如果省略端口,则默认为 443" — and two of its three examples have no port:

anytls://[email protected]/?sni=real.example.com
anytls://[email protected]/?sni=127.0.0.1&insecure=1

The naive+https:// / naive+quic:// link format (https://gist.github.com/DuckSoft/ca03913b0a26fc77a1da4d01cc6ab2f1) works the same way ("port can be omitted if it's 443"), and none of its examples has a port.

AnytlsFmt.Resolve and NaiveFmt.Resolve copy Uri.Port as-is. For these schemes System.Uri returns -1 when the port is missing, so the links above import as a node with port -1, ProfileItem.IsValid() rejects it, and the core config is never generated.

This applies the same default Hysteria2Fmt got in #10026: -1 becomes 443, while an explicit :0 stays 0.

Tests: new AnytlsFmtTests and NaiveFmtTests (spec examples, no-port forms, explicit port, :0). Without the change 8 of the 12 fail with Expected to be 443 but found -1; with it all 12 pass, and the full ServiceLib.Tests suite passes (188/188) on Windows, .NET SDK 10.0.403.

I used Claude Code to write this change.

…s it

The AnyTLS URI scheme makes the port optional and defaults it to 443,
and two of its three examples leave it out. The naive+https:// and
naive+quic:// link format does the same: the port is omitted when it is
443, and none of its examples carries one.

System.Uri answers -1 for an unregistered scheme with no port, so these
links were imported with Port = -1 and the profile failed IsValid().
Apply the same default Hysteria2Fmt already uses (2dust#10026). An explicit
":0" is still kept as 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@2dust
2dust merged commit ff9fd7b into 2dust:master Nov 3, 2026
4 checks passed
amir-samiee pushed a commit to amir-samiee/v2rayN that referenced this pull request Nov 5, 2026
…s it (2dust#10504)

The AnyTLS URI scheme makes the port optional and defaults it to 443,
and two of its three examples leave it out. The naive+https:// and
naive+quic:// link format does the same: the port is omitted when it is
443, and none of its examples carries one.

System.Uri answers -1 for an unregistered scheme with no port, so these
links were imported with Port = -1 and the profile failed IsValid().
Apply the same default Hysteria2Fmt already uses (2dust#10026). An explicit
":0" is still kept as 0.

Co-authored-by: Claude Opus 5.5 <[email protected]>
patterniha added a commit to patterniha/PattN that referenced this pull request Nov 11, 2026
Brings in 2dust/v2rayN up to e3457fa (still 7.25.6):
- Native AOT (2dust#10295, 2dust#10513): JSON through a source-generated
  context, trimming roots, and AOT zips of the Windows desktop, Linux
  and macOS builds; ReactiveUI 26 (2dust#10249) and ProDataGrid (2dust#10347);
- a pre-resolver per subscription (2dust#10220), MASQUE WARP (2dust#10498), the
  XDRIVE transport (2dust#10546), sing-box TUN dns_mode (2dust#10336) and an AUTO
  bind interface (2dust#10519);
- the download refactor with Downloader 6 (2dust#10534), subscription
  profiles kept on a failed import (2dust#10429), repeated test results
  kept (2dust#10466), share-link fixes (2dust#10504, 2dust#10505, 2dust#10520, 2dust#10526),
  udphop (2dust#10550), REALITY fragments (2dust#10428), and the WebAPI's
  restart deadline (2dust#10516) and macOS instance lock (2dust#10454);
- Linux packages cross-built for x64, arm64, riscv64, ppc64le and
  loong64 in one job, plus x86 packages (2dust#10487, 2dust#10537), and a daily
  certificate update workflow (2dust#10497).

Where upstream changed code PattN had changed:
- no IPv6 FakeIP setting (2dust#10464): PattN writes no fakedns block, so
  Xray-core uses its default IPv4 and IPv6 pools, and sing-box gets an
  IPv6 range on its own; FakeIPUtils and its tests go;
- 2dust#10485's DNS change is not taken: PattN asks each direct group's
  servers in turn and ends the query on the last;
- the TUN inbound copies the inbound's sniffing (2dust#10460) without
  forcing routeOnly;
- MASQUE: upstream's editor and import, which no longer clear or lock
  the TLS options: the fork core speaks HTTP/2 over TLS when the ALPN
  has h2 but not h3, so they apply there;
- the WebAPI restart: upstream's polling fix (2dust#10516) replaces PattN's
  own wait.

Adapted to the AOT JSON and the download refactor: Aether's DNS, the
share-link JSON options, the outbound tag check and the Psiphon test
fixtures go through the source-generated context; the Aether test only
says whether to measure speed, and its IP lookup uses a download
service on the tunnel's proxy; the rule-set 404 skip moves into the new
download helper.

Release workflows and Linux packaging scripts take upstream's layout
with PattN's names and bundles: every Linux architecture builds on each
release (exotic_arch is gone; patterniha/Aether has builds for x64 and
arm64 only), the deb packages keep the cores' execute bits (2dust#10335),
which 2dust#10537's rewrite dropped, and the certificate workflow runs only
upstream.

Conflicts:
- resx: both sets of strings.
- SubEditWindow: upstream's pre-resolver row among PattN's rows.
- AddServerViewModelTests: upstream's; PattN's preset tests move to
  AddServerViewModelPresetTests.
- CoreConfigV2rayIPNetworkTests: without upstream's fakedns pool test.
- README: PattN's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants