Files
Denozordec 4905c06b9b
Publish mtproxy_checker Docker image / test (push) Successful in 19s
Publish mtproxy_checker Docker image / build-and-push (push) Successful in 48s
init
2026-04-11 00:38:22 +07:00

32 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package faketls
// SNIDomain returns hostname bytes for TLS SNI from the raw ee-secret domain suffix.
//
// В ссылке tg:// после 16-байтного ключа часто идёт «хвост» домена: один служебный байт (часто 0xd0)
// и дальше ASCII hostname в hex (например …d0632e61… → "c.api.stepa.one").
// В extension server_name нужно передавать только hostname в ASCII, иначе прокси обрывает сессию.
func SNIDomain(raw []byte) []byte {
if len(raw) >= 2 {
// Типичный префикс Telegram для ASCII-имени после ключа
if raw[0] == 0xd0 && raw[1] >= 0x20 && raw[1] < 0x7f {
return raw[1:]
}
}
// Fallback: пропускаем ведущие не-hostname байты до первой буквы/цифры/точки
i := 0
for i < len(raw) {
b := raw[i]
if (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') {
break
}
if b == '.' || b == '-' {
break
}
i++
}
if i >= len(raw) {
return raw
}
return raw[i:]
}