mirror of
https://github.com/DanielLavrushin/b4.git
synced 2026-07-09 16:00:05 +00:00
fix: remove WSFallbackTCP configuration and related references (#224)
Some checks failed
Deploy documentation / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy documentation / build-and-deploy (push) Has been cancelled
This commit is contained in:
parent
9287d5a90f
commit
f6ba3ee35f
10 changed files with 44 additions and 99 deletions
|
|
@ -242,7 +242,6 @@ var DefaultConfig = Config{
|
|||
BindAddress: "0.0.0.0",
|
||||
FakeSNI: "storage.googleapis.com",
|
||||
UpstreamMode: "auto",
|
||||
WSFallbackTCP: true,
|
||||
WSEndpointHost: "149.154.167.220",
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ func migrateV38to39(c *Config, _ map[string]interface{}) error {
|
|||
func migrateV37to38(c *Config, _ map[string]interface{}) error {
|
||||
log.Tracef("Migration v37->v38: Adding MTProto upstream transport (WS) fields")
|
||||
c.System.MTProto.UpstreamMode = "auto"
|
||||
c.System.MTProto.WSFallbackTCP = true
|
||||
c.System.MTProto.WSCustomDomain = ""
|
||||
c.System.MTProto.WSEndpointHost = "149.154.167.220"
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -224,7 +224,6 @@ type MTProtoConfig struct {
|
|||
DCRelay string `json:"dc_relay"`
|
||||
UpstreamMode string `json:"upstream_mode"`
|
||||
WSCustomDomain string `json:"ws_custom_domain"`
|
||||
WSFallbackTCP bool `json:"ws_fallback_tcp"`
|
||||
WSEndpointHost string `json:"ws_endpoint_host"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ func (api *API) handleMTProtoTestWS(w http.ResponseWriter, r *http.Request) {
|
|||
var req struct {
|
||||
UpstreamMode string `json:"upstream_mode"`
|
||||
WSCustomDomain *string `json:"ws_custom_domain"`
|
||||
WSFallbackTCP *bool `json:"ws_fallback_tcp"`
|
||||
WSEndpointHost *string `json:"ws_endpoint_host"`
|
||||
DC int `json:"dc"`
|
||||
}
|
||||
|
|
@ -58,9 +57,6 @@ func (api *API) handleMTProtoTestWS(w http.ResponseWriter, r *http.Request) {
|
|||
if req.WSCustomDomain != nil {
|
||||
probeCfg.WSCustomDomain = *req.WSCustomDomain
|
||||
}
|
||||
if req.WSFallbackTCP != nil {
|
||||
probeCfg.WSFallbackTCP = *req.WSFallbackTCP
|
||||
}
|
||||
if req.WSEndpointHost != nil {
|
||||
probeCfg.WSEndpointHost = *req.WSEndpointHost
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ export const MTProtoSettings = ({ config, onChange }: MTProtoSettingsProps) => {
|
|||
body: JSON.stringify({
|
||||
upstream_mode: config.system.mtproto?.upstream_mode || "auto",
|
||||
ws_custom_domain: config.system.mtproto?.ws_custom_domain || "",
|
||||
ws_fallback_tcp: config.system.mtproto?.ws_fallback_tcp ?? true,
|
||||
ws_endpoint_host: config.system.mtproto?.ws_endpoint_host || "",
|
||||
dc: 2,
|
||||
}),
|
||||
|
|
@ -303,9 +302,8 @@ export const MTProtoSettings = ({ config, onChange }: MTProtoSettingsProps) => {
|
|||
{(() => {
|
||||
const mode = config.system.mtproto?.upstream_mode || "auto";
|
||||
const enabled = !!config.system.mtproto?.enabled;
|
||||
const fallback = config.system.mtproto?.ws_fallback_tcp ?? true;
|
||||
const showDcRelay =
|
||||
!!dcRelay || mode === "tcp" || (mode === "auto" && fallback);
|
||||
!!dcRelay || mode === "tcp" || mode === "auto";
|
||||
return (
|
||||
<B4FormGroup
|
||||
label={t("settings.MTProto.upstreamTitle")}
|
||||
|
|
@ -328,15 +326,38 @@ export const MTProtoSettings = ({ config, onChange }: MTProtoSettingsProps) => {
|
|||
`settings.MTProto.upstream${upstreamDescSuffix(mode)}Desc`,
|
||||
)}
|
||||
/>
|
||||
{mode === "auto" && (
|
||||
<B4Switch
|
||||
label={t("settings.MTProto.wsFallbackTcp")}
|
||||
checked={config.system.mtproto?.ws_fallback_tcp ?? true}
|
||||
onChange={(checked: boolean) =>
|
||||
onChange("system.mtproto.ws_fallback_tcp", checked)
|
||||
{showDcRelay && (
|
||||
<B4TextField
|
||||
label={t("settings.MTProto.dcRelay")}
|
||||
value={config.system.mtproto?.dc_relay || ""}
|
||||
onChange={(e) =>
|
||||
onChange("system.mtproto.dc_relay", e.target.value)
|
||||
}
|
||||
description={t("settings.MTProto.wsFallbackTcpDesc")}
|
||||
placeholder="vps-ip:7007"
|
||||
disabled={!enabled}
|
||||
helperText={t("settings.MTProto.dcRelayHelp")}
|
||||
slotProps={{
|
||||
input: {
|
||||
endAdornment: (
|
||||
<InputAdornment position="end" sx={{ mr: -0.5 }}>
|
||||
<Tooltip
|
||||
title={t("settings.MTProto.dcRelayHelpButton")}
|
||||
>
|
||||
<span style={{ display: "inline-flex" }}>
|
||||
<IconButton
|
||||
size="small"
|
||||
onClick={openRelayHelp}
|
||||
disabled={!enabled}
|
||||
sx={{ px: 0 }}
|
||||
>
|
||||
<HelpOutlineIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</InputAdornment>
|
||||
),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{mode !== "tcp" && (
|
||||
|
|
@ -416,40 +437,6 @@ export const MTProtoSettings = ({ config, onChange }: MTProtoSettingsProps) => {
|
|||
</Stack>
|
||||
)}
|
||||
</Box>
|
||||
{showDcRelay && (
|
||||
<B4TextField
|
||||
label={t("settings.MTProto.dcRelay")}
|
||||
value={config.system.mtproto?.dc_relay || ""}
|
||||
onChange={(e) =>
|
||||
onChange("system.mtproto.dc_relay", e.target.value)
|
||||
}
|
||||
placeholder="vps-ip:7007"
|
||||
disabled={!enabled}
|
||||
helperText={t("settings.MTProto.dcRelayHelp")}
|
||||
slotProps={{
|
||||
input: {
|
||||
endAdornment: (
|
||||
<InputAdornment position="end" sx={{ mr: -0.5 }}>
|
||||
<Tooltip
|
||||
title={t("settings.MTProto.dcRelayHelpButton")}
|
||||
>
|
||||
<span style={{ display: "inline-flex" }}>
|
||||
<IconButton
|
||||
size="small"
|
||||
onClick={openRelayHelp}
|
||||
disabled={!enabled}
|
||||
sx={{ px: 0 }}
|
||||
>
|
||||
<HelpOutlineIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>
|
||||
</InputAdornment>
|
||||
),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</B4FormGroup>
|
||||
);
|
||||
})()}
|
||||
|
|
|
|||
|
|
@ -285,15 +285,13 @@
|
|||
"upstreamAutoDesc": "Try WebSocket first via kws*.web.telegram.org, fall back to direct TCP. Recommended for censored networks.",
|
||||
"upstreamWs": "WebSocket only",
|
||||
"upstreamWsDesc": "Strict WebSocket transport via kws*.web.telegram.org. No TCP fallback.",
|
||||
"wsFallbackTcp": "Allow TCP fallback",
|
||||
"wsFallbackTcpDesc": "In Auto mode, fall back to direct TCP if all WebSocket attempts fail.",
|
||||
"wsCustomDomain": "Custom WebSocket domain",
|
||||
"wsCustomDomainHelp": "Optional. Enter the base domain (e.g. your-domain.com) that proxies WebSocket traffic to Telegram. b4 prepends kws1., kws2., ... per DC automatically. Leave empty to use Telegram's native kws*.web.telegram.org.",
|
||||
"wsEndpointHost": "Telegram WS edge IP (advanced)",
|
||||
"wsEndpointHostHelp": "Override the IP used when WS uses native kws*.web.telegram.org SNI. Default: 149.154.167.220. Leave empty for default. Does not affect the custom WebSocket domain path.",
|
||||
"testWs": "Test transports",
|
||||
"testWs": "Test connection",
|
||||
"testWsRunning": "Testing…",
|
||||
"testWsHelp": "Probes DC 2 over each configured transport and reports latency."
|
||||
"testWsHelp": "Probes DC 2 over the configured transport(s) and reports latency."
|
||||
},
|
||||
"MSSClamping": {
|
||||
"title": "Global MSS Clamping",
|
||||
|
|
|
|||
|
|
@ -281,15 +281,13 @@
|
|||
"upstreamAutoDesc": "Сначала WebSocket через kws*.web.telegram.org, при неудаче — прямой TCP. Рекомендуется для сетей с цензурой.",
|
||||
"upstreamWs": "Только WebSocket",
|
||||
"upstreamWsDesc": "Жёсткий WebSocket-транспорт через kws*.web.telegram.org. Без TCP-резерва.",
|
||||
"wsFallbackTcp": "Разрешить TCP-резерв",
|
||||
"wsFallbackTcpDesc": "В режиме Авто переключаться на прямой TCP, если все попытки WebSocket провалились.",
|
||||
"wsCustomDomain": "Свой WebSocket-домен",
|
||||
"wsCustomDomainHelp": "Опционально. Укажите базовый домен (например, your-domain.com), который проксирует WebSocket-трафик к Telegram. b4 сам подставит kws1., kws2., ... перед каждым DC. Пусто — использовать встроенный kws*.web.telegram.org.",
|
||||
"wsEndpointHost": "IP edge-сервера Telegram (расширенное)",
|
||||
"wsEndpointHostHelp": "IP, к которому подключаемся для встроенного kws*.web.telegram.org SNI. По умолчанию 149.154.167.220. Оставьте пустым для значения по умолчанию. Не влияет на путь через свой WebSocket-домен.",
|
||||
"testWs": "Проверить транспорты",
|
||||
"testWs": "Проверить соединение",
|
||||
"testWsRunning": "Проверка…",
|
||||
"testWsHelp": "Пробует достучаться до DC 2 каждым настроенным транспортом и измеряет задержку."
|
||||
"testWsHelp": "Пробует достучаться до DC 2 настроенным транспортом (или транспортами) и измеряет задержку."
|
||||
},
|
||||
"MSSClamping": {
|
||||
"title": "Глобальный MSS Clamping",
|
||||
|
|
|
|||
|
|
@ -291,7 +291,6 @@ export interface MTProtoConfig {
|
|||
dc_relay: string;
|
||||
upstream_mode: "tcp" | "ws" | "auto";
|
||||
ws_custom_domain: string;
|
||||
ws_fallback_tcp: boolean;
|
||||
ws_endpoint_host: string;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ func planTransports(cfg *config.MTProtoConfig, queueCfg config.QueueConfig, dc i
|
|||
}
|
||||
}
|
||||
|
||||
allowTCP := mode == "tcp" || (mode == "auto" && cfg.WSFallbackTCP) || len(plans) == 0
|
||||
allowTCP := mode == "tcp" || mode == "auto" || len(plans) == 0
|
||||
if allowTCP {
|
||||
addr, err := ResolveDC(dc, queueCfg.IPv6Enabled, cfg.DCRelay)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ func TestPlanTransports_UnknownDC_NoKwsPlans(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPlanTransports_AutoMode_IncludesTCPWhenFallbackEnabled(t *testing.T) {
|
||||
cfg := &config.MTProtoConfig{UpstreamMode: "auto", WSFallbackTCP: true}
|
||||
func TestPlanTransports_AutoMode_AlwaysIncludesTCPFallback(t *testing.T) {
|
||||
cfg := &config.MTProtoConfig{UpstreamMode: "auto"}
|
||||
plans, err := planTransports(cfg, config.QueueConfig{IPv4Enabled: true}, 2)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
|
|
@ -86,18 +86,7 @@ func TestPlanTransports_AutoMode_IncludesTCPWhenFallbackEnabled(t *testing.T) {
|
|||
t.Fatalf("auto mode for DC 2 should include both kws plans")
|
||||
}
|
||||
if !hasTCP(plans) {
|
||||
t.Fatalf("auto + fallback should include TCP")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlanTransports_AutoMode_NoTCPWhenFallbackDisabled(t *testing.T) {
|
||||
cfg := &config.MTProtoConfig{UpstreamMode: "auto", WSFallbackTCP: false}
|
||||
plans, err := planTransports(cfg, config.QueueConfig{IPv4Enabled: true}, 2)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if hasTCP(plans) {
|
||||
t.Fatalf("auto without fallback should not include TCP for DC 2")
|
||||
t.Fatalf("auto mode must always include TCP fallback")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,21 +161,20 @@ func TestPlanTransports_DCRelay_TCPMode_TargetsRelay(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPlanTransports_DCRelay_AutoFallbackOn_WSPlansPlusRelayTCP(t *testing.T) {
|
||||
func TestPlanTransports_DCRelay_AutoMode_WSPlansPlusRelayTCP(t *testing.T) {
|
||||
cfg := &config.MTProtoConfig{
|
||||
UpstreamMode: "auto",
|
||||
WSFallbackTCP: true,
|
||||
DCRelay: "127.0.0.1:4443",
|
||||
UpstreamMode: "auto",
|
||||
DCRelay: "127.0.0.1:4443",
|
||||
}
|
||||
plans, err := planTransports(cfg, config.QueueConfig{IPv4Enabled: true}, 2)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if len(wsSNIs(plans)) == 0 {
|
||||
t.Fatalf("auto + fallback: expected WS plans first, got none")
|
||||
t.Fatalf("auto: expected WS plans first, got none")
|
||||
}
|
||||
if !hasTCP(plans) {
|
||||
t.Fatalf("auto + fallback: expected TCP plan as fallback")
|
||||
t.Fatalf("auto: expected TCP plan as fallback")
|
||||
}
|
||||
for _, p := range plans {
|
||||
if p.kind == transportTCP && !strings.HasPrefix(p.addr, "127.0.0.1:") {
|
||||
|
|
@ -195,24 +183,6 @@ func TestPlanTransports_DCRelay_AutoFallbackOn_WSPlansPlusRelayTCP(t *testing.T)
|
|||
}
|
||||
}
|
||||
|
||||
func TestPlanTransports_DCRelay_AutoFallbackOff_IgnoredForKnownDC(t *testing.T) {
|
||||
cfg := &config.MTProtoConfig{
|
||||
UpstreamMode: "auto",
|
||||
WSFallbackTCP: false,
|
||||
DCRelay: "127.0.0.1:4443",
|
||||
}
|
||||
plans, err := planTransports(cfg, config.QueueConfig{IPv4Enabled: true}, 2)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if hasTCP(plans) {
|
||||
t.Fatalf("auto + fallback off: DCRelay must NOT introduce a TCP plan; got %+v", plans)
|
||||
}
|
||||
if len(wsSNIs(plans)) == 0 {
|
||||
t.Fatalf("expected WS plans, got none")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlanTransports_DCRelay_IgnoredInWSMode(t *testing.T) {
|
||||
cfg := &config.MTProtoConfig{
|
||||
UpstreamMode: "ws",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue