Skip to content

Commit 1d96492

Browse files
committed
1 parent 8259e2d commit 1d96492

File tree

5 files changed

+235
-3
lines changed

5 files changed

+235
-3
lines changed

luci-app-openclash/luasrc/model/cbi/openclash/servers-config.lua

+95
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ o:value("snell", translate("Snell"))
146146
o:value("mieru", translate("Mieru"))
147147
o:value("socks5", translate("Socks5"))
148148
o:value("http", translate("HTTP(S)"))
149+
o:value("direct", translate("DIRECT"))
150+
o:value("dns", translate("DNS"))
151+
o:value("ssh", translate("SSH"))
149152

150153
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
151154

@@ -156,11 +159,39 @@ o.default = "Server - "..sid
156159
o = s:option(Value, "server", translate("Server Address"))
157160
o.datatype = "host"
158161
o.rmempty = true
162+
o:depends("type", "ss")
163+
o:depends("type", "ssr")
164+
o:depends("type", "vmess")
165+
o:depends("type", "trojan")
166+
o:depends("type", "vless")
167+
o:depends("type", "hysteria")
168+
o:depends("type", "hysteria2")
169+
o:depends("type", "wireguard")
170+
o:depends("type", "tuic")
171+
o:depends("type", "mieru")
172+
o:depends("type", "snell")
173+
o:depends("type", "socks5")
174+
o:depends("type", "http")
175+
o:depends("type", "ssh")
159176

160177
o = s:option(Value, "port", translate("Server Port"))
161178
o.datatype = "port"
162179
o.rmempty = false
163180
o.default = "443"
181+
o:depends("type", "ss")
182+
o:depends("type", "ssr")
183+
o:depends("type", "vmess")
184+
o:depends("type", "trojan")
185+
o:depends("type", "vless")
186+
o:depends("type", "hysteria")
187+
o:depends("type", "hysteria2")
188+
o:depends("type", "wireguard")
189+
o:depends("type", "tuic")
190+
o:depends("type", "mieru")
191+
o:depends("type", "snell")
192+
o:depends("type", "socks5")
193+
o:depends("type", "http")
194+
o:depends("type", "ssh")
164195

165196
o = s:option(Flag, "flag_port_hopping", translate("Enable Port Hopping"))
166197
o:depends("type", "hysteria")
@@ -415,6 +446,7 @@ o:depends("type", "socks5")
415446
o:depends("type", "trojan")
416447
o:depends({type = "snell", snell_version = "3"})
417448
o:depends("type", "wireguard")
449+
o:depends("type", "direct")
418450

419451
o = s:option(ListValue, "udp_over_tcp", translate("udp-over-tcp"))
420452
o.rmempty = true
@@ -659,12 +691,30 @@ o:depends("type", "http")
659691
o = s:option(Value, "auth_name", translate("Auth Username"))
660692
o:depends("type", "socks5")
661693
o:depends("type", "http")
694+
o:depends("type", "ssh")
662695
o.rmempty = true
663696

664697
-- 验证密码
665698
o = s:option(Value, "auth_pass", translate("Auth Password"))
666699
o:depends("type", "socks5")
667700
o:depends("type", "http")
701+
o:depends("type", "ssh")
702+
o.rmempty = true
703+
704+
o = s:option(Value, "private_key", translate("private-key"))
705+
o:depends("type", "ssh")
706+
o.rmempty = true
707+
708+
o = s:option(Value, "private_key_passphrase", translate("private-key-passphrase"))
709+
o:depends("type", "ssh")
710+
o.rmempty = true
711+
712+
o = s:option(DynamicList, "host_key", translate("host-key"))
713+
o:depends("type", "ssh")
714+
o.rmempty = true
715+
716+
o = s:option(DynamicList, "host_key_algorithms", translate("host-key-algorithms"))
717+
o:depends("type", "ssh")
668718
o.rmempty = true
669719

670720
-- [[ alpn ]]--
@@ -889,6 +939,21 @@ o:value("ipv4-prefer")
889939
o:value("ipv6")
890940
o:value("ipv6-prefer")
891941
o.default = "ipv4-prefer"
942+
o:depends("type", "ss")
943+
o:depends("type", "ssr")
944+
o:depends("type", "vmess")
945+
o:depends("type", "trojan")
946+
o:depends("type", "vless")
947+
o:depends("type", "hysteria")
948+
o:depends("type", "hysteria2")
949+
o:depends("type", "wireguard")
950+
o:depends("type", "tuic")
951+
o:depends("type", "mieru")
952+
o:depends("type", "snell")
953+
o:depends("type", "socks5")
954+
o:depends("type", "http")
955+
o:depends("type", "ssh")
956+
o:depends("type", "direct")
892957

893958
-- [[ smux ]]--
894959
o = s:option(ListValue, "multiplex", translate("Multiplex")..translate("(Only Meta Core)"))
@@ -952,11 +1017,41 @@ o:depends("multiplex", "true")
9521017
o = s:option(Value, "interface_name", translate("interface-name"))
9531018
o.rmempty = true
9541019
o.placeholder = translate("eth0")
1020+
o:depends("type", "ss")
1021+
o:depends("type", "ssr")
1022+
o:depends("type", "vmess")
1023+
o:depends("type", "trojan")
1024+
o:depends("type", "vless")
1025+
o:depends("type", "hysteria")
1026+
o:depends("type", "hysteria2")
1027+
o:depends("type", "wireguard")
1028+
o:depends("type", "tuic")
1029+
o:depends("type", "mieru")
1030+
o:depends("type", "snell")
1031+
o:depends("type", "socks5")
1032+
o:depends("type", "http")
1033+
o:depends("type", "ssh")
1034+
o:depends("type", "direct")
9551035

9561036
-- [[ routing-mark ]]--
9571037
o = s:option(Value, "routing_mark", translate("routing-mark"))
9581038
o.rmempty = true
9591039
o.placeholder = translate("2333")
1040+
o:depends("type", "ss")
1041+
o:depends("type", "ssr")
1042+
o:depends("type", "vmess")
1043+
o:depends("type", "trojan")
1044+
o:depends("type", "vless")
1045+
o:depends("type", "hysteria")
1046+
o:depends("type", "hysteria2")
1047+
o:depends("type", "wireguard")
1048+
o:depends("type", "tuic")
1049+
o:depends("type", "mieru")
1050+
o:depends("type", "snell")
1051+
o:depends("type", "socks5")
1052+
o:depends("type", "http")
1053+
o:depends("type", "ssh")
1054+
o:depends("type", "direct")
9601055

9611056
-- [[ other-setting ]]--
9621057
o = s:option(Value, "other_parameters", translate("Other Parameters"))

luci-app-openclash/root/usr/share/openclash/yml_groups_get.sh

+14
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,20 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "
222222
uci_commands << uci_set + 'policy_filter=\"' + x['filter'].to_s + '\"'
223223
end
224224
};
225+
226+
threads_g << Thread.new {
227+
#interface-name
228+
if x.key?('interface-name') then
229+
uci_commands << uci_set + 'interface_name=\"' + x['interface-name'].to_s + '\"'
230+
end
231+
};
232+
233+
threads_g << Thread.new {
234+
#routing-mark
235+
if x.key?('routing-mark') then
236+
uci_commands << uci_set + 'routing_mark=\"' + x['routing-mark'].to_s + '\"'
237+
end
238+
};
225239
226240
threads_g << Thread.new {
227241
#other_group

luci-app-openclash/root/usr/share/openclash/yml_groups_set.sh

+6
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ yml_groups_set()
350350
[ -n "$policy_filter" ] && {
351351
echo " filter: \"$policy_filter\"" >>$GROUP_FILE
352352
}
353+
[ -n "$interface_name" ] && {
354+
echo " interface-name: \"$interface_name\"" >>$GROUP_FILE
355+
}
356+
[ -n "$routing_mark" ] && {
357+
echo " routing-mark: \"$routing_mark\"" >>$GROUP_FILE
358+
}
353359
}
354360

355361
create_config=$(uci -q get openclash.config.create_config)

luci-app-openclash/root/usr/share/openclash/yml_proxys_get.sh

+50
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,56 @@ ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "
12661266
};
12671267
end;
12681268
1269+
if x['type'] == 'ssh' then
1270+
threads << Thread.new{
1271+
if x.key?('username') then
1272+
uci_commands << uci_set + 'auth_name=\"' + x['username'].to_s + '\"'
1273+
end
1274+
};
1275+
1276+
threads << Thread.new{
1277+
if x.key?('password') then
1278+
uci_commands << uci_set + 'auth_pass=\"' + x['password'].to_s + '\"'
1279+
end
1280+
};
1281+
1282+
threads << Thread.new{
1283+
if x.key?('private-key') then
1284+
uci_commands << uci_set + 'private_key=\"' + x['private-key'].to_s + '\"'
1285+
end
1286+
};
1287+
1288+
threads << Thread.new{
1289+
if x.key?('private-key-passphrase') then
1290+
uci_commands << uci_set + 'private_key_passphrase=\"' + x['private-key-passphrase'].to_s + '\"'
1291+
end
1292+
};
1293+
1294+
threads << Thread.new{
1295+
#host-key-algorithms
1296+
if x.key?('host-key-algorithms') then
1297+
host_key_algorithms = uci_del + 'host_key_algorithms >/dev/null 2>&1'
1298+
system(host_key_algorithms)
1299+
x['host-key-algorithms'].each{
1300+
|x|
1301+
uci_commands << uci_add + 'host_key_algorithms=\"' + x.to_s + '\"'
1302+
}
1303+
end
1304+
};
1305+
1306+
threads << Thread.new{
1307+
#host-key
1308+
if x.key?('host-key') then
1309+
host_key = uci_del + 'host_key >/dev/null 2>&1'
1310+
system(host_key)
1311+
x['host-key'].each{
1312+
|x|
1313+
uci_commands << uci_add + 'host_key=\"' + x.to_s + '\"'
1314+
}
1315+
end
1316+
};
1317+
end;
1318+
12691319
if x['type'] == 'socks5' or x['type'] == 'http' then
12701320
threads << Thread.new{
12711321
if x.key?('username') then

luci-app-openclash/root/usr/share/openclash/yml_proxys_set.sh

+70-3
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ yml_servers_set()
319319
config_get "username" "$section" "username" ""
320320
config_get "transport" "$section" "transport" "TCP"
321321
config_get "multiplexing" "$section" "multiplexing" "MULTIPLEXING_LOW"
322+
config_get "private_key" "$section" "private_key" ""
323+
config_get "private_key_passphrase" "$section" "private_key_passphrase" ""
324+
config_get "host_key" "$section" "host_key" ""
325+
config_get "host_key_algorithms" "$section" "host_key_algorithms" ""
322326

323327
if [ "$enabled" = "0" ]; then
324328
return
@@ -332,11 +336,11 @@ yml_servers_set()
332336
return
333337
fi
334338

335-
if [ -z "$server" ]; then
339+
if [ -z "$server" ] && [ "$type" != "direct" ] && [ "$type" != "dns" ]; then
336340
return
337341
fi
338342

339-
if [ -z "$port" ]; then
343+
if [ -z "$port" ] && [ "$type" != "direct" ] && [ "$type" != "dns" ]; then
340344
return
341345
fi
342346

@@ -1189,7 +1193,70 @@ EOF
11891193
fi
11901194
fi
11911195
fi
1192-
1196+
1197+
#dns
1198+
if [ "$type" = "dns" ]; then
1199+
cat >> "$SERVER_FILE" <<-EOF
1200+
- name: "$name"
1201+
type: $type
1202+
EOF
1203+
fi
1204+
1205+
#direct
1206+
if [ "$type" = "direct" ]; then
1207+
cat >> "$SERVER_FILE" <<-EOF
1208+
- name: "$name"
1209+
type: $type
1210+
EOF
1211+
if [ ! -z "$udp" ]; then
1212+
cat >> "$SERVER_FILE" <<-EOF
1213+
udp: $udp
1214+
EOF
1215+
fi
1216+
fi
1217+
1218+
#ssh
1219+
if [ "$type" = "ssh" ]; then
1220+
cat >> "$SERVER_FILE" <<-EOF
1221+
- name: "$name"
1222+
type: $type
1223+
server: "$server"
1224+
port: $port
1225+
EOF
1226+
if [ ! -z "$auth_name" ]; then
1227+
cat >> "$SERVER_FILE" <<-EOF
1228+
username: "$auth_name"
1229+
EOF
1230+
fi
1231+
if [ ! -z "$auth_pass" ]; then
1232+
cat >> "$SERVER_FILE" <<-EOF
1233+
password: "$auth_pass"
1234+
EOF
1235+
fi
1236+
if [ ! -z "$private_key" ]; then
1237+
cat >> "$SERVER_FILE" <<-EOF
1238+
private-key: "$private_key"
1239+
EOF
1240+
fi
1241+
if [ ! -z "$private_key_passphrase" ]; then
1242+
cat >> "$SERVER_FILE" <<-EOF
1243+
private-key-passphrase: "$private_key_passphrase"
1244+
EOF
1245+
fi
1246+
if [ ! -z "$host_key" ]; then
1247+
cat >> "$SERVER_FILE" <<-EOF
1248+
host-key:
1249+
EOF
1250+
config_list_foreach "$section" "host_key" set_alpn
1251+
fi
1252+
if [ ! -z "$host_key_algorithms" ]; then
1253+
cat >> "$SERVER_FILE" <<-EOF
1254+
host-key-algorithms:
1255+
EOF
1256+
config_list_foreach "$section" "host_key_algorithms" set_alpn
1257+
fi
1258+
fi
1259+
11931260
#socks5
11941261
if [ "$type" = "socks5" ]; then
11951262
cat >> "$SERVER_FILE" <<-EOF

0 commit comments

Comments
 (0)