新增IPv6的转发支持
This commit is contained in:
@@ -87,9 +87,12 @@ create_service() {
|
||||
read -rp "目标端口: " TARGET_PORT
|
||||
|
||||
echo "协议类型:"
|
||||
echo "1) TCP"
|
||||
echo "2) UDP"
|
||||
read -rp "选择 (1/2): " PROTO_CHOICE
|
||||
echo "1) TCP (IPv4)"
|
||||
echo "2) TCP (IPv6)"
|
||||
echo "3) UDP (IPv4)"
|
||||
echo "4) UDP (IPv6)"
|
||||
|
||||
read -rp "选择 (1/2/3/4): " PROTO_CHOICE
|
||||
|
||||
case "$PROTO_CHOICE" in
|
||||
1)
|
||||
@@ -97,8 +100,16 @@ create_service() {
|
||||
SOCAT_CMD="TCP-LISTEN:${LOCAL_PORT},reuseaddr,fork TCP:${TARGET_IP}:${TARGET_PORT}"
|
||||
;;
|
||||
2)
|
||||
PROTO="tcp6"
|
||||
SOCAT_CMD="TCP6-LISTEN:${LOCAL_PORT},reuseaddr,fork TCP6:${TARGET_IP}:${TARGET_PORT}"
|
||||
;;
|
||||
3)
|
||||
PROTO="udp"
|
||||
SOCAT_CMD="UDP-LISTEN:${LOCAL_PORT},reuseaddr UDP:${TARGET_IP}:${TARGET_PORT}"
|
||||
SOCAT_CMD="UDP-LISTEN:${LOCAL_PORT},reuseaddr,fork UDP:${TARGET_IP}:${TARGET_PORT}"
|
||||
;;
|
||||
4)
|
||||
PROTO="udp6"
|
||||
SOCAT_CMD="UDP6-LISTEN:${LOCAL_PORT},reuseaddr,fork UDP6:${TARGET_IP}:${TARGET_PORT}"
|
||||
;;
|
||||
*)
|
||||
echo "❌ 无效选择"
|
||||
@@ -114,6 +125,7 @@ create_service() {
|
||||
Description=Socat ${PROTO^^} Port Forward ${LOCAL_PORT} -> ${TARGET_IP}:${TARGET_PORT}
|
||||
After=network.target
|
||||
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/socat ${SOCAT_CMD}
|
||||
|
||||
Reference in New Issue
Block a user