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