Skip to content

Commit 07af4a2

Browse files
committed
add socks
1 parent 61e55ae commit 07af4a2

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

Diff for: src/core.sh

+44-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ protocol_list=(
1919
VMess-TCP-dynamic-port
2020
VMess-mKCP-dynamic-port
2121
VMess-QUIC-dynamic-port
22+
Socks
2223
)
2324
ss_method_list=(
2425
aes-128-gcm
@@ -69,6 +70,7 @@ info_list=(
6970
"SNI (serverName)"
7071
"指纹 (Fingerprint)"
7172
"公钥 (Public key)"
73+
"用户名 (Username)"
7274
)
7375
change_list=(
7476
"更改协议"
@@ -86,6 +88,7 @@ change_list=(
8688
"更改动态端口"
8789
"更改伪装网站"
8890
"更改 mKCP seed"
91+
"更改用户名 (Username)"
8992
)
9093
servername_list=(
9194
www.amazon.com
@@ -216,7 +219,7 @@ ask() {
216219
set_header_type)
217220
is_tmp_list=(${header_type_list[@]})
218221
is_default_arg=$is_random_header_type
219-
[[ $(grep tcp <<<"$is_new_protocol-$net") ]] && {
222+
[[ $(grep -i tcp <<<"$is_new_protocol-$net") ]] && {
220223
is_tmp_list=(none http)
221224
is_default_arg=none
222225
}
@@ -531,14 +534,15 @@ change() {
531534
4)
532535
# new password
533536
is_new_pass=$3
534-
if [[ $net == 'ss' || $is_trojan ]]; then
537+
if [[ $net == 'ss' || $is_trojan || $is_socks_pass ]]; then
535538
[[ $is_auto ]] && get_uuid && is_new_pass=$tmp_uuid
536539
else
537540
err "($is_config_file) 不支持更改密码."
538541
fi
539542
[[ ! $is_new_pass ]] && ask string is_new_pass "请输入新密码:"
540543
trojan_password=$is_new_pass
541544
ss_password=$is_new_pass
545+
is_socks_pass=$is_new_pass
542546
add $net
543547
;;
544548
5)
@@ -689,6 +693,12 @@ change() {
689693
kcp_seed=$is_new_kcp_seed
690694
add $net
691695
;;
696+
15)
697+
# new socks user
698+
[[ ! $is_socks_user ]] && err "($is_config_file) 不支持更改用户名 (Username)."
699+
ask string is_socks_user "请输入新用户名 (Username):"
700+
add $net
701+
;;
692702
esac
693703
}
694704

@@ -861,7 +871,10 @@ add() {
861871
door)
862872
is_new_protocol=Dokodemo-Door
863873
;;
864-
http | socks)
874+
socks)
875+
is_new_protocol=Socks
876+
;;
877+
http)
865878
is_new_protocol=local-$is_lower
866879
;;
867880
*)
@@ -908,7 +921,13 @@ add() {
908921
is_use_door_addr=$3
909922
is_use_door_port=$4
910923
;;
911-
*http | *socks)
924+
socks)
925+
is_socks=1
926+
is_use_port=$2
927+
is_use_socks_user=$3
928+
is_use_socks_pass=$4
929+
;;
930+
*http)
912931
is_use_port=$2
913932
;;
914933
esac
@@ -1016,6 +1035,8 @@ add() {
10161035
[[ $is_use_host ]] && host=$is_use_host
10171036
[[ $is_use_door_addr ]] && door_addr=$is_use_door_addr
10181037
[[ $is_use_servername ]] && is_servername=$is_use_servername
1038+
[[ $is_use_socks_user ]] && is_socks_user=$is_use_socks_user
1039+
[[ $is_use_socks_pass ]] && is_socks_pass=$is_use_socks_pass
10191040
fi
10201041

10211042
if [[ $is_use_tls ]]; then
@@ -1039,11 +1060,17 @@ add() {
10391060
# set port
10401061
[[ ! $port ]] && ask string port "请输入端口:"
10411062

1042-
case ${is_new_protocol} in
1063+
case ${is_new_protocol,,} in
10431064
*tcp* | *kcp* | *quic*)
10441065
[[ ! $header_type ]] && ask set_header_type
10451066
;;
1046-
Shadowsocks)
1067+
socks)
1068+
# set user
1069+
[[ ! $is_socks_user ]] && ask string is_socks_user "请设置用户名:"
1070+
# set password
1071+
[[ ! $is_socks_pass ]] && ask string is_socks_pass "请设置密码:"
1072+
;;
1073+
shadowsocks)
10471074
# set method
10481075
[[ ! $ss_method ]] && ask set_ss_method
10491076
# set password
@@ -1130,12 +1157,12 @@ get() {
11301157
get file $2
11311158
if [[ $is_config_file ]]; then
11321159
is_json_str=$(cat $is_conf_dir/"$is_config_file")
1133-
is_json_data_base=$(jq '.inbounds[0]|.protocol,.port,.settings.clients[0].id,.settings.clients[0].password,.settings.method,.settings.password,.settings.address,.settings.port,.settings.detour.to' <<<$is_json_str)
1160+
is_json_data_base=$(jq '.inbounds[0]|.protocol,.port,.settings.clients[0].id,.settings.clients[0].password,.settings.method,.settings.password,.settings.address,.settings.port,.settings.detour.to,.settings.accounts[0].user,.settings.accounts[0].pass' <<<$is_json_str)
11341161
[[ $? != 0 ]] && err "无法读取此文件: $is_config_file"
11351162
is_json_data_more=$(jq '.inbounds[0]|.streamSettings|.network,.security,.tcpSettings.header.type,.kcpSettings.seed,.kcpSettings.header.type,.quicSettings.header.type,.wsSettings.path,.httpSettings.path,.grpcSettings.serviceName' <<<$is_json_str)
11361163
is_json_data_host=$(jq '.inbounds[0]|.streamSettings|.grpc_host,.wsSettings.headers.Host,.httpSettings.host[0]' <<<$is_json_str)
11371164
is_json_data_reality=$(jq '.inbounds[0]|.streamSettings|.realitySettings.serverNames[0],.realitySettings.publicKey,.realitySettings.privateKey' <<<$is_json_str)
1138-
is_up_var_set=(null is_protocol port uuid trojan_password ss_method ss_password door_addr door_port is_dynamic_port net is_reality tcp_type kcp_seed kcp_type quic_type ws_path h2_path grpc_path grpc_host ws_host h2_host is_servername is_public_key is_private_key)
1165+
is_up_var_set=(null is_protocol port uuid trojan_password ss_method ss_password door_addr door_port is_dynamic_port is_socks_user is_socks_pass net is_reality tcp_type kcp_seed kcp_type quic_type ws_path h2_path grpc_path grpc_host ws_host h2_host is_servername is_public_key is_private_key)
11391166
[[ $is_debug ]] && msg "\n------------- debug: $is_config_file -------------"
11401167
i=0
11411168
for v in $(sed 's/""/null/g;s/"//g' <<<"$is_json_data_base $is_json_data_more $is_json_data_host $is_json_data_reality"); do
@@ -1220,7 +1247,9 @@ get() {
12201247
*socks*)
12211248
is_protocol=socks
12221249
net=socks
1223-
json_str=''"$is_listen_127"',settings:{udp:true}'
1250+
[[ ! $is_socks_user ]] && is_socks_user=233boy
1251+
[[ ! $is_socks_pass ]] && is_socks_pass=$uuid
1252+
json_str='settings:{auth:"password",accounts:[{user:'\"$is_socks_user\"',pass:'\"$is_socks_pass\"'}],udp:true}'
12241253
;;
12251254
*)
12261255
err "无法识别协议: $is_config_file"
@@ -1453,7 +1482,12 @@ info() {
14531482
is_info_show=(0 1 2 13 14)
14541483
is_info_str=($is_protocol $is_addr $port $door_addr $door_port)
14551484
;;
1456-
socks | http)
1485+
socks)
1486+
is_can_change=(0 1 15 4)
1487+
is_info_show=(0 1 2 19 10)
1488+
is_info_str=($is_protocol $is_addr $port $is_socks_user $is_socks_pass)
1489+
;;
1490+
http)
14571491
is_can_change=(0 1)
14581492
is_info_show=(0 1 2)
14591493
is_info_str=($is_protocol 127.0.0.1 $port)

Diff for: src/download.sh

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ download() {
4343
link="https://github.com/${is_sh_repo}/releases/download/${latest_ver}/code.zip"
4444
download_file
4545
unzip -qo $tmpfile -d $is_sh_dir
46+
chmod +x $is_sh_bin
4647
;;
4748
caddy)
4849
name="Caddy"

Diff for: src/old.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ if [[ $is_old_use ]]; then
107107
fi
108108
fi
109109
if [[ $socks ]]; then
110-
add socks $socks_port
110+
add socks $socks_port $socks_username $socks_userpass
111111
fi
112112
port=$v2ray_port
113113
uuid=$v2ray_id

Diff for: v2ray.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

33
args=$@
4-
is_sh_ver=v4.0
4+
is_sh_ver=v4.01
55

66
. /etc/v2ray/sh/src/init.sh

0 commit comments

Comments
 (0)