@@ -19,6 +19,7 @@ protocol_list=(
19
19
VMess-TCP-dynamic-port
20
20
VMess-mKCP-dynamic-port
21
21
VMess-QUIC-dynamic-port
22
+ Socks
22
23
)
23
24
ss_method_list=(
24
25
aes-128-gcm
@@ -69,6 +70,7 @@ info_list=(
69
70
" SNI (serverName)"
70
71
" 指纹 (Fingerprint)"
71
72
" 公钥 (Public key)"
73
+ " 用户名 (Username)"
72
74
)
73
75
change_list=(
74
76
" 更改协议"
@@ -86,6 +88,7 @@ change_list=(
86
88
" 更改动态端口"
87
89
" 更改伪装网站"
88
90
" 更改 mKCP seed"
91
+ " 更改用户名 (Username)"
89
92
)
90
93
servername_list=(
91
94
www.amazon.com
@@ -216,7 +219,7 @@ ask() {
216
219
set_header_type)
217
220
is_tmp_list=(${header_type_list[@]} )
218
221
is_default_arg=$is_random_header_type
219
- [[ $( grep tcp <<< " $is_new_protocol-$net" ) ]] && {
222
+ [[ $( grep -i tcp <<< " $is_new_protocol-$net" ) ]] && {
220
223
is_tmp_list=(none http)
221
224
is_default_arg=none
222
225
}
@@ -531,14 +534,15 @@ change() {
531
534
4)
532
535
# new password
533
536
is_new_pass=$3
534
- if [[ $net == ' ss' || $is_trojan ]]; then
537
+ if [[ $net == ' ss' || $is_trojan || $is_socks_pass ]]; then
535
538
[[ $is_auto ]] && get_uuid && is_new_pass=$tmp_uuid
536
539
else
537
540
err " ($is_config_file ) 不支持更改密码."
538
541
fi
539
542
[[ ! $is_new_pass ]] && ask string is_new_pass " 请输入新密码:"
540
543
trojan_password=$is_new_pass
541
544
ss_password=$is_new_pass
545
+ is_socks_pass=$is_new_pass
542
546
add $net
543
547
;;
544
548
5)
@@ -689,6 +693,12 @@ change() {
689
693
kcp_seed=$is_new_kcp_seed
690
694
add $net
691
695
;;
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
+ ;;
692
702
esac
693
703
}
694
704
@@ -861,7 +871,10 @@ add() {
861
871
door)
862
872
is_new_protocol=Dokodemo-Door
863
873
;;
864
- http | socks)
874
+ socks)
875
+ is_new_protocol=Socks
876
+ ;;
877
+ http)
865
878
is_new_protocol=local-$is_lower
866
879
;;
867
880
* )
@@ -908,7 +921,13 @@ add() {
908
921
is_use_door_addr=$3
909
922
is_use_door_port=$4
910
923
;;
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)
912
931
is_use_port=$2
913
932
;;
914
933
esac
@@ -1016,6 +1035,8 @@ add() {
1016
1035
[[ $is_use_host ]] && host=$is_use_host
1017
1036
[[ $is_use_door_addr ]] && door_addr=$is_use_door_addr
1018
1037
[[ $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
1019
1040
fi
1020
1041
1021
1042
if [[ $is_use_tls ]]; then
@@ -1039,11 +1060,17 @@ add() {
1039
1060
# set port
1040
1061
[[ ! $port ]] && ask string port " 请输入端口:"
1041
1062
1042
- case ${is_new_protocol} in
1063
+ case ${is_new_protocol,, } in
1043
1064
* tcp* | * kcp* | * quic* )
1044
1065
[[ ! $header_type ]] && ask set_header_type
1045
1066
;;
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)
1047
1074
# set method
1048
1075
[[ ! $ss_method ]] && ask set_ss_method
1049
1076
# set password
@@ -1130,12 +1157,12 @@ get() {
1130
1157
get file $2
1131
1158
if [[ $is_config_file ]]; then
1132
1159
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 )
1134
1161
[[ $? != 0 ]] && err " 无法读取此文件: $is_config_file "
1135
1162
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 )
1136
1163
is_json_data_host=$( jq ' .inbounds[0]|.streamSettings|.grpc_host,.wsSettings.headers.Host,.httpSettings.host[0]' <<< $is_json_str )
1137
1164
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)
1139
1166
[[ $is_debug ]] && msg " \n------------- debug: $is_config_file -------------"
1140
1167
i=0
1141
1168
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() {
1220
1247
* socks* )
1221
1248
is_protocol=socks
1222
1249
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}'
1224
1253
;;
1225
1254
* )
1226
1255
err " 无法识别协议: $is_config_file "
@@ -1453,7 +1482,12 @@ info() {
1453
1482
is_info_show=(0 1 2 13 14)
1454
1483
is_info_str=($is_protocol $is_addr $port $door_addr $door_port )
1455
1484
;;
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)
1457
1491
is_can_change=(0 1)
1458
1492
is_info_show=(0 1 2)
1459
1493
is_info_str=($is_protocol 127.0.0.1 $port )
0 commit comments