mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-12 22:31:00 +00:00
fix(mtproto): drop the remark fragment from tg proxy deep links
genMtprotoLink appended the panel remark as a URL fragment (tg://proxy?...&secret=...#remark). Because secret/server is the last query value, lenient Telegram parsers fold the "#remark" into it and the imported proxy breaks with "incorrect client random". Telegram proxy deep links have no name field, so emit a clean link on both the backend (internal/sub) and frontend (inbound-link.ts). The remark still shows as a separate tag in the inbound info modal, which reads it from genAllLinks, not the URL. Guards: Go TestGenMtprotoLinkFields asserts no fragment; the frontend mtproto link test asserts no '#'.
This commit is contained in:
@@ -663,8 +663,11 @@ func (s *SubService) genWireguardLink(inbound *model.Inbound, email string) stri
|
||||
}
|
||||
|
||||
// genMtprotoLink builds a per-client Telegram proxy deep link for an mtproto
|
||||
// inbound: the server/port pair plus the client's own FakeTLS secret. Returns ""
|
||||
// when the client has no secret.
|
||||
// inbound: the server/port pair plus the client's own FakeTLS secret. The link
|
||||
// carries no remark fragment — Telegram proxy deep links have no name field, and
|
||||
// a trailing "#remark" is appended to the last query value by lenient parsers,
|
||||
// corrupting the server address. The remark is shown separately in the panel UI.
|
||||
// Returns "" when the client has no secret.
|
||||
func (s *SubService) genMtprotoLink(inbound *model.Inbound, email string) string {
|
||||
if inbound.Protocol != model.MTProto {
|
||||
return ""
|
||||
@@ -678,7 +681,7 @@ func (s *SubService) genMtprotoLink(inbound *model.Inbound, email string) string
|
||||
"port": fmt.Sprintf("%d", inbound.Port),
|
||||
"secret": resolved.Secret,
|
||||
}
|
||||
return buildLinkWithParams("tg://proxy", params, s.genRemark(inbound, email, "", ""))
|
||||
return buildLinkWithParams("tg://proxy", params, "")
|
||||
}
|
||||
|
||||
// Protocol link generators are intentionally ordered as:
|
||||
|
||||
@@ -40,6 +40,9 @@ func TestGenMtprotoLinkFields(t *testing.T) {
|
||||
if q.Get("secret") != mtprotoTestSecret {
|
||||
t.Fatalf("secret = %q, want the client's FakeTLS secret", q.Get("secret"))
|
||||
}
|
||||
if u.Fragment != "" {
|
||||
t.Fatalf("link carries a #%s fragment; tg://proxy links must have no remark fragment", u.Fragment)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenMtprotoLinkWrongProtocol(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user