Skip to content

[feat] add an API to get the final url after following redirect responses#1698

Open
k3-cat wants to merge 27 commits intoSagerNet:dev-nextfrom
k3-cat:dev-next
Open

[feat] add an API to get the final url after following redirect responses#1698
k3-cat wants to merge 27 commits intoSagerNet:dev-nextfrom
k3-cat:dev-next

Conversation

@k3-cat
Copy link

@k3-cat k3-cat commented Apr 21, 2024

Description

This change adds a new Method getFinalURL() -> string to experimental/libbox.HTTPResponse, which allows the caller obtain the final URL after been redirected.

Motivation

This change should bring the following benefits:

  • performance improvement
  • enhance robustness
  • server can have more flexible update strategies
  • reduce reconfiguration work for user

Expected influences

None
According to Ref1, net/http.Client will follows a redirect response (if less than 10 times) by default. From my test, all existing sing-box apps follow this default behaviour, and this change will not break this behaviour. In addition, the connection can be protected by TLS, so this change should not introduce extra security issue.

nekohasekai and others added 27 commits April 12, 2024 09:04
The `process_path` rule of sing-box is inherited from Clash,
the original code uses the local system's path format (e.g. `\Device\HarddiskVolume1\folder\program.exe`),
but when the device has multiple disks, the HarddiskVolume serial number is not stable.

This change make QueryFullProcessImageNameW output a Win32 path (such as `C:\folder\program.exe`),
which will disrupt the existing `process_path` use cases in Windows.
For historical reasons, sing-box's `domain_suffix` rule matches literal prefixes instead of the same as other projects.

This change modifies the behavior of `domain_suffix`: If the rule value is prefixed with `.`,
the behavior is unchanged, otherwise it matches `(domain|.+\.domain)` instead.
@nekohasekai nekohasekai force-pushed the dev-next branch 6 times, most recently from dfdd296 to 0a8b7a3 Compare January 2, 2026 11:23
@nekohasekai nekohasekai force-pushed the dev-next branch 8 times, most recently from 1bd617e to 0028b06 Compare January 12, 2026 12:44
@nekohasekai nekohasekai force-pushed the dev-next branch 6 times, most recently from 237887d to 5d67c13 Compare January 17, 2026 11:21
@nekohasekai nekohasekai force-pushed the dev-next branch 9 times, most recently from 4d60ac3 to c1dc6cb Compare February 1, 2026 04:30
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.

4 participants

Comments