Files
2dust_v2rayN/v2rayN/ServiceLib
Miheichev Aleksandr Sergeevich f332caf507 fix(hysteria2): default the port to 443 when the share URI omits it (#10026)
The Hysteria2 URI scheme makes the port optional: "The hostname and
optional port of the server. If the port is omitted, it defaults to 443."
`Hysteria2Fmt.Resolve` assigned `url.Port` straight through, and
`System.Uri` answers -1 for an unregistered scheme that carries no port,
so `hysteria2://password@hy2.example/` imported as a profile with
`Port = -1`. `ProfileItem.IsValid` rejects any port outside 1..65535, so
such a link produced a profile that could never be used, and nothing said
why.

-1 is the only value that means "the port was omitted"; a ':' with no
digits after it maps to -1 as well. An explicit ":0" parses as 0 and
keeps the fate it has today - rejected by `IsValid` - rather than being
redirected to a server the link never named.

`ResolveRealm` takes its port from `HyRealm.RendezvousPort` instead of
the URI, so it is unaffected.

The added tests cover both spellings of the scheme, with and without a
trailing slash, a bare ':', and the resulting profile's validity. Two of
them are controls: an explicit port is still preserved, and an explicit
":0" still does not turn into 443.
2026-08-28 14:33:05 +08:00
..
2026-08-01 10:08:43 +08:00
2026-08-22 17:32:26 +08:00
2026-08-05 14:25:16 +08:00
2026-08-22 17:32:26 +08:00
2026-08-21 14:15:54 +08:00
2026-08-27 15:31:39 +08:00
2026-08-26 19:41:52 +08:00
2026-08-22 17:32:26 +08:00
2026-07-26 21:07:36 +08:00
2026-08-01 10:08:43 +08:00
2026-08-01 10:08:43 +08:00