@@ -517,10 +517,23 @@ change() {
517
517
1)
518
518
# new port
519
519
is_new_port=$3
520
- [[ $host ]] && err " ($is_config_file ) 不支持更改端口, 因为没啥意义."
520
+ [[ $host && ! $is_caddy ]] && err " ($is_config_file ) 不支持更改端口, 因为没啥意义."
521
+ if [[ $is_new_port && ! $is_auto ]]; then
522
+ [[ ! $( is_test port $is_new_port ) ]] && err " 请输入正确的端口, 可选(1-65535)"
523
+ [[ $is_new_port != 443 && $( is_test port_used $is_new_port ) ]] && err " 无法使用 ($is_new_port ) 端口"
524
+ fi
521
525
[[ $is_auto ]] && get_port && is_new_port=$tmp_port
522
526
[[ ! $is_new_port ]] && ask string is_new_port " 请输入新端口:"
523
- add $net $is_new_port
527
+ if [[ $is_caddy && $host ]]; then
528
+ net=$is_old_net
529
+ tlsport=$is_new_port
530
+ load caddy.sh
531
+ caddy_config $net
532
+ manage restart caddy &
533
+ info
534
+ else
535
+ add $net $is_new_port
536
+ fi
524
537
;;
525
538
2)
526
539
# new host
@@ -1192,7 +1205,11 @@ get() {
1192
1205
is_dynamic_port_range=$( jq -r ' .inbounds[0].port' $is_dynamic_port_file )
1193
1206
[[ $? != 0 ]] && err " 无法读取动态端口文件: $is_dynamic_port "
1194
1207
fi
1195
- [[ $is_client && $host ]] && port=443
1208
+ if [[ $is_caddy && $host ]]; then
1209
+ tlsport=$( egrep -o " $host :[1-9][0-9]?+" $is_caddy_conf /$host .conf | sed s/.* ://)
1210
+ fi
1211
+ [[ ! $tlsport ]] && tlsport=443
1212
+ [[ $is_client && $host ]] && port=$tlsport
1196
1213
get protocol $is_protocol -$net
1197
1214
fi
1198
1215
;;
@@ -1446,39 +1463,39 @@ info() {
1446
1463
ss)
1447
1464
is_can_change=(0 1 4 6)
1448
1465
is_info_show=(0 1 2 10 11)
1449
- is_url=" ss://$( echo -n ${ss_method} :${ss_password} | base64 -w 0) @${is_addr} :${port} #233boy-ss -${is_addr} "
1466
+ is_url=" ss://$( echo -n ${ss_method} :${ss_password} | base64 -w 0) @${is_addr} :${port} #233boy-$net -${is_addr} "
1450
1467
is_info_str=($is_protocol $is_addr $port $ss_password $ss_method )
1451
1468
;;
1452
1469
ws | h2 | grpc)
1453
1470
is_color=45
1454
- is_can_change=(0 2 3 5)
1471
+ is_can_change=(0 1 2 3 5)
1455
1472
is_info_show=(0 1 2 3 4 6 7 8)
1456
1473
is_url_path=path
1457
1474
[[ $net == ' grpc' ]] && {
1458
1475
path=$( sed ' s#/##g' <<< $path )
1459
1476
is_url_path=serviceName
1460
1477
}
1461
1478
[[ $is_protocol == ' vmess' ]] && {
1462
- is_vmess_url=$( jq -c ' {v:2,ps:' \" 233boy-$host \" ' ,add:' \" $is_addr \" ' ,port:' \" 443 \" ' ,id:' \" $uuid \" ' ,aid:"0",net:' \" $net \" ' ,host:' \" $host \" ' ,path:' \" $path \" ' ,tls:' \" tls\" ' }' <<< {} )
1479
+ is_vmess_url=$( jq -c ' {v:2,ps:' \" 233boy-$net - $ host\" ' ,add:' \" $is_addr \" ' ,port:' \" $tlsport \" ' ,id:' \" $uuid \" ' ,aid:"0",net:' \" $net \" ' ,host:' \" $host \" ' ,path:' \" $path \" ' ,tls:' \" tls\" ' }' <<< {} )
1463
1480
is_url=vmess://$( echo -n $is_vmess_url | base64 -w 0)
1464
1481
} || {
1465
1482
[[ $is_trojan ]] && {
1466
1483
uuid=$trojan_password
1467
- is_info_str=($is_protocol $is_addr 443 $trojan_password $net $host $path ' tls' )
1468
- is_can_change=(0 2 3 4)
1484
+ is_info_str=($is_protocol $is_addr $tlsport $trojan_password $net $host $path ' tls' )
1485
+ is_can_change=(0 1 2 3 4)
1469
1486
is_info_show=(0 1 2 10 4 6 7 8)
1470
1487
}
1471
- is_url=" $is_protocol ://$uuid @$host :443 ?encryption=none&security=tls&type=$net &host=$host &${is_url_path} =$( sed ' s#/#%2F#g' <<< $path ) #233boy-$host "
1488
+ is_url=" $is_protocol ://$uuid @$host :$tlsport ?encryption=none&security=tls&type=$net &host=$host &${is_url_path} =$( sed ' s#/#%2F#g' <<< $path ) #233boy- $net -$host "
1472
1489
}
1473
1490
[[ $is_caddy ]] && is_can_change+=(13)
1474
- is_info_str=($is_protocol $is_addr 443 $uuid $net $host $path ' tls' )
1491
+ is_info_str=($is_protocol $is_addr $tlsport $uuid $net $host $path ' tls' )
1475
1492
;;
1476
1493
reality)
1477
1494
is_color=41
1478
1495
is_can_change=(0 1 5 10 11)
1479
1496
is_info_show=(0 1 2 3 15 8 16 17 18)
1480
1497
is_info_str=($is_protocol $is_addr $port $uuid xtls-rprx-vision reality $is_servername " ios" $is_public_key )
1481
- is_url=" $is_protocol ://$uuid @$ip :$port ?encryption=none&security=reality&flow=xtls-rprx-vision&type=tcp&sni=$is_servername &pbk=$is_public_key &fp=ios#233boy-$is_addr "
1498
+ is_url=" $is_protocol ://$uuid @$ip :$port ?encryption=none&security=reality&flow=xtls-rprx-vision&type=tcp&sni=$is_servername &pbk=$is_public_key &fp=ios#233boy-$net - $ is_addr"
1482
1499
;;
1483
1500
door)
1484
1501
is_can_change=(0 1 8 9)
@@ -1489,7 +1506,7 @@ info() {
1489
1506
is_can_change=(0 1 15 4)
1490
1507
is_info_show=(0 1 2 19 10)
1491
1508
is_info_str=($is_protocol $is_addr $port $is_socks_user $is_socks_pass )
1492
- is_url=" socks://$( echo -n ${is_socks_user} :${is_socks_pass} | base64 -w 0) @${is_addr} :${port} #233boy-socks -${is_addr} "
1509
+ is_url=" socks://$( echo -n ${is_socks_user} :${is_socks_pass} | base64 -w 0) @${is_addr} :${port} #233boy-$net -${is_addr} "
1493
1510
;;
1494
1511
http)
1495
1512
is_can_change=(0 1)
0 commit comments