diff --git a/.env b/.env index 860c24eb7742dec59e0a8bf8cf35e9383c70a450..c23d50bf1f19cfd6ba9813651b2e55ff79841544 100644 --- a/.env +++ b/.env @@ -1,9 +1,14 @@ HOP_PT="0" KCP="0" +QUIC="0" OPENVPN_HOST="openvpn-server" OPENVPN_PORT="5540" LIVE_TEST="0" OBFS4_HOST="obfsvpn-1" OBFS4_HOST2= OBFS4_PORT="4430" -TUN_MTU="48000" \ No newline at end of file +TUN_MTU="48000" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.1ive.bridge b/.env.1ive.bridge index 765730d9263843e13a78a5cf134a1b9de8474eef..a427b658ac2fcedcee26a2b02d9ea88e0aa14cf9 100644 --- a/.env.1ive.bridge +++ b/.env.1ive.bridge @@ -12,3 +12,7 @@ OBFS4_HOST="135.181.103.26" OBFS4_HOST2= OBFS4_PORT="4445" TUN_MTU="1500" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.hopping b/.env.hopping index 3c18d8a4dddc1eddbd50cfb2f8495ad242cd5cd4..3f6014d09fc479e881f2fd0b99dd5b54bcb0fad5 100644 --- a/.env.hopping +++ b/.env.hopping @@ -7,4 +7,8 @@ LIVE_TEST="0" OBFS4_HOST="obfsvpn-1" OBFS4_HOST2="obfsvpn-2" OBFS4_PORT="4430" -TUN_MTU="48000" \ No newline at end of file +TUN_MTU="48000" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.hopping.kcp b/.env.hopping.kcp index 7ca042c2fe1f8bd4415844a7161fec24c4e425c6..193c95edc1d7098d633e0ae05ffe6fa884beb549 100644 --- a/.env.hopping.kcp +++ b/.env.hopping.kcp @@ -7,4 +7,8 @@ LIVE_TEST="0" OBFS4_HOST="obfsvpn-1" OBFS4_HOST2="obfsvpn-2" OBFS4_PORT="4430" -TUN_MTU="48000" \ No newline at end of file +TUN_MTU="48000" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.hopping.quic b/.env.hopping.quic index 0ccaad1050e611c9add3045de687511d2c063f0b..5fd60bb179422fc6ccb5abb51d0c8905ecd85646 100644 --- a/.env.hopping.quic +++ b/.env.hopping.quic @@ -8,3 +8,7 @@ OBFS4_HOST="obfsvpn-1" OBFS4_HOST2="obfsvpn-2" OBFS4_PORT="4430" TUN_MTU="48000" +OBFSVPN_PORT_SEED="1" +OBFSVPN_MIN_HOP_PORT="45000" +OBFSVPN_MAX_HOP_PORT="50000" +OBFSVPN_PORT_COUNT="50" diff --git a/.env.hoppingkcp.live.bridge b/.env.hoppingkcp.live.bridge index 4702e925686f4d375ce5bd7e61b9ecdf7ac93eec..c1525d8049f255cd8b1c53aa5b9d73a80b52eec0 100644 --- a/.env.hoppingkcp.live.bridge +++ b/.env.hoppingkcp.live.bridge @@ -12,3 +12,7 @@ OBFS4_HOST="135.181.103.26" OBFS4_HOST2="95.217.28.167" OBFS4_PORT="4446" TUN_MTU="1500" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.kcp b/.env.kcp index f03a92404cfd765daf8c6ad950c24969b7bbb377..e5fcceefab40cc5a508a1e6209b71e0f4435cb91 100644 --- a/.env.kcp +++ b/.env.kcp @@ -7,4 +7,8 @@ LIVE_TEST="0" OBFS4_HOST="obfsvpn-1" OBFS4_HOST2= OBFS4_PORT="4430" -TUN_MTU="48000" \ No newline at end of file +TUN_MTU="48000" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.kcp.live.bridge b/.env.kcp.live.bridge index 4f545beb19a4a37f6759c83251688b8b7358948c..54048f857cbb219dcea05cfa5cb880748103909a 100644 --- a/.env.kcp.live.bridge +++ b/.env.kcp.live.bridge @@ -12,3 +12,7 @@ OBFS4_HOST="135.181.103.26" OBFS4_HOST2= OBFS4_PORT="4444" TUN_MTU="1500" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.kcp.live.gw b/.env.kcp.live.gw index a1854888d2add096a1bad5141de313d87233fd15..3ca54fa30e2256ed7837f162fa4d46bc169a4fd1 100644 --- a/.env.kcp.live.gw +++ b/.env.kcp.live.gw @@ -11,4 +11,8 @@ OPENVPN_PORT="53" OBFS4_HOST="obfsvpn-1" OBFS4_HOST2= OBFS4_PORT="4430" -TUN_MTU="1500" \ No newline at end of file +TUN_MTU="1500" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/.env.quic b/.env.quic index eaacba6f9e822283dd9785ddc7c4c2b055e7a76d..e6c5c3f573f149b4dd3189da7004e7b520d857e1 100644 --- a/.env.quic +++ b/.env.quic @@ -8,3 +8,7 @@ OBFS4_HOST="obfsvpn-1" OBFS4_HOST2= OBFS4_PORT="4430" TUN_MTU="48000" +OBFSVPN_PORT_SEED="" +OBFSVPN_MIN_HOP_PORT="" +OBFSVPN_MAX_HOP_PORT="" +OBFSVPN_PORT_COUNT="" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c78cecbb4b12deaa33891a3e5d1ab3e48cb8968d..be0ad3d63283780d7fd67f3964d88b63999e7150 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,10 @@ services: HOP_PT: "$HOP_PT" KCP: "$KCP" QUIC: "$QUIC" + OBFSVPN_PORT_SEED: "$OBFSVPN_PORT_SEED" + OBFSVPN_MIN_HOP_PORT: "$OBFSVPN_MIN_HOP_PORT" + OBFSVPN_MAX_HOP_PORT: "$OBFSVPN_MAX_HOP_PORT" + OBFSVPN_PORT_COUNT: "$OBFSVPN_PORT_COUNT" QUIC_TLS_CERT: "/opt/openvpn/data/pki/ca.crt" QUIC_TLS_KEY: "/opt/openvpn/data/pki/private/ca.key" OBFS4_KEY_FILE: "/opt/obfsvpn/data/obfs4.json" @@ -62,6 +66,10 @@ services: QUIC_TLS_CERT: "/opt/openvpn/data/MyReq.crt" QUIC_TLS_KEY: "/opt/openvpn/data/MyReq.key" OBFS4_KEY_FILE: "/opt/obfsvpn/data/obfs4.json" + OBFSVPN_PORT_SEED: "$OBFSVPN_PORT_SEED" + OBFSVPN_MIN_HOP_PORT: "$OBFSVPN_MIN_HOP_PORT" + OBFSVPN_MAX_HOP_PORT: "$OBFSVPN_MAX_HOP_PORT" + OBFSVPN_PORT_COUNT: "$OBFSVPN_PORT_COUNT" # only necessary for traditional/non-hopping mode OBFS4_PORT: "$OBFS4_PORT" command: "/opt/obfsvpn/start_obfsvpn.sh" @@ -84,6 +92,10 @@ services: HOP_PT: "$HOP_PT" KCP: "$KCP" QUIC: "$QUIC" + OBFSVPN_PORT_SEED: "$OBFSVPN_PORT_SEED" + OBFSVPN_MIN_HOP_PORT: "$OBFSVPN_MIN_HOP_PORT" + OBFSVPN_MAX_HOP_PORT: "$OBFSVPN_MAX_HOP_PORT" + OBFSVPN_PORT_COUNT: "$OBFSVPN_PORT_COUNT" # the minimum number of seconds to wait before hopping MIN_HOP_SECONDS: 5 # a random range to wait in addition to the minimum hop time diff --git a/images/obfsvpn-client/start.sh b/images/obfsvpn-client/start.sh index 65d3d75d1f590ecd617b2289ca46874cb8d65c4f..6fb97ad26aaddf4debcb800243c240a70a8760f1 100755 --- a/images/obfsvpn-client/start.sh +++ b/images/obfsvpn-client/start.sh @@ -30,8 +30,32 @@ fi if [[ "$HOP_PT" == "1" ]]; then echo "Starting obfsvpn-client in hopping mode" + # set a couple of optional hopping flags + FLAG_MIN_HOP_PORT="" + if [[ -n $OBFSVPN_MIN_HOP_PORT ]]; then + FLAG_MIN_HOP_PORT="-min-port $OBFSVPN_MIN_HOP_PORT" + echo "Setting Min hopping port to $OBFSVPN_MIN_HOP_PORT" + fi + + FLAG_MAX_HOP_PORT="" + if [[ -n $OBFSVPN_MAX_HOP_PORT ]]; then + FLAG_MAX_HOP_PORT="-max-port $OBFSVPN_MAX_HOP_PORT" + echo "Setting max hopping port to $OBFSVPN_MAX_HOP_PORT" + fi + + FLAG_SEED="" + if [[ -n $OBFSVPN_SEED ]]; then + FLAG_SEED="-ps $OBFSVPN_SEED" + echo "Setting hopping port seed to $OBFSVPN_SEED" + fi + + FLAG_PORT_COUNT="" + if [[ -n $OBFSVPN_PORT_COUNT ]]; then + FLAG_PORT_COUNT="-pc $OBFSVPN_PORT_COUNT" + echo "Setting hopping port count to $OBFSVPN_PORT_COUNT" + fi /usr/bin/obfsvpn-client $FLAG_KCP $FLAG_QUIC -h -c "$OBFS4_CERT1,$OBFS4_CERT1" -r "$OBFS4_SERVER_HOST1,$OBFS4_SERVER_HOST2" \ - -m "$MIN_HOP_SECONDS" -j "$HOP_JITTER" -v & + -m "$MIN_HOP_SECONDS" -j "$HOP_JITTER" $FLAG_MAX_HOP_PORT $FLAG_MIN_HOP_PORT $FLAG_SEED $FLAG_PORT_COUNT & # start openvpn in udp # set connect-retry low to help facilitate integration test