Skip to content

Commit

Permalink
luci: fix hysteria2 bandwidth when nil (xiaorouji#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gzxhwq authored Oct 16, 2023
1 parent e834b8e commit 97e11cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
16 changes: 8 additions & 8 deletions luci-app-passwall/luasrc/passwall/util_hysteria2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 97e11cf

Please sign in to comment.