luci: fix hysteria2 bandwidth when nil (#2855)

This commit is contained in:
Gzxhwq 2023-10-16 20:35:03 +08:00 committed by sbwml
parent e195f359a4
commit faed417e44
3 changed files with 8 additions and 12 deletions

View File

@ -45,11 +45,9 @@ o = s:option(Flag, option_name("tls_allowInsecure"), translate("allowInsecure"),
o.default = "0"
o = s:option(Value, option_name("up_mbps"), translate("Max upload Mbps"))
o.default = "100"
o.rewrite_option = o.option
o = s:option(Value, option_name("down_mbps"), translate("Max download Mbps"))
o.default = "100"
o.rewrite_option = o.option
o = s:option(Value, option_name("hop_interval"), translate("Hop Interval"))

View File

@ -33,11 +33,9 @@ o.default = "1"
o.rewrite_option = o.option
o = s:option(Value, option_name("up_mbps"), translate("Max upload Mbps"))
o.default = "100"
o.rewrite_option = o.option
o = s:option(Value, option_name("down_mbps"), translate("Max download Mbps"))
o.default = "100"
o.rewrite_option = o.option
o = s:option(Flag, option_name("ignoreClientBandwidth"), translate("ignoreClientBandwidth"))

View File

@ -20,10 +20,10 @@ function gen_config_server(node)
type = "password",
password = node.hysteria2_auth_password
},
bandwidth = {
up = node.hysteria2_up_mbps and node.hysteria2_up_mbps .. " mbps" or "1 gbps",
down = node.hysteria2_down_mbps and node.hysteria2_down_mbps .. " mbps" or "1 gbps",
},
bandwidth = (node.hysteria2_up_mbps or node.hysteria2_down_mbps) and {
up = node.hysteria2_up_mbps and node.hysteria2_up_mbps .. " mbps" or nil,
down = node.hysteria2_down_mbps and node.hysteria2_down_mbps .. " mbps" or nil
} or nil,
ignoreClientBandwidth = (node.hysteria2_ignoreClientBandwidth == "1") and true or false,
disableUDP = (node.hysteria2_udp == "0") and true or false,
}
@ -85,10 +85,10 @@ function gen_config(var)
maxIdleTimeout = (node.hysteria2_idle_timeout) and tonumber(node.hysteria2_idle_timeout) or nil,
disablePathMTUDiscovery = (node.hysteria2_disable_mtu_discovery) and true or false,
},
bandwidth = {
up = node.hysteria2_up_mbps and node.hysteria2_up_mbps .. " mbps" or "100 mbps",
down = node.hysteria2_down_mbps and node.hysteria2_down_mbps .. " mbps" or "100 mbps"
},
bandwidth = (node.hysteria2_up_mbps or node.hysteria2_down_mbps) and {
up = node.hysteria2_up_mbps and node.hysteria2_up_mbps .. " mbps" or nil,
down = node.hysteria2_down_mbps and node.hysteria2_down_mbps .. " mbps" or nil
} or nil,
fast_open = (node.fast_open == "1") and true or false,
lazy = (node.hysteria2_lazy_start == "1") and true or false,
socks5 = (local_socks_address and local_socks_port) and {