From e8640954f3b22c9e96e63f9ea9cae5df032f40d3 Mon Sep 17 00:00:00 2001 From: fscarmen <62703343+fscarmen@users.noreply.github.com> Date: Sun, 18 Feb 2024 10:11:06 +0000 Subject: [PATCH] v1.1 Support WARP ipv4 , ipv6 and dualstack. --- .github/workflows/test.yml | 33 ++++++++++++++-------- README.md | 20 ++++++------- action.yml | 57 ++++++++++++-------------------------- 3 files changed, 49 insertions(+), 61 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35cbc5c..4e1729d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,28 +7,39 @@ on: tags: - 'v*' - jobs: - client-by-default: + client-dual-by-default: runs-on: ubuntu-latest name: client warp+doh mode by default steps: - - uses: fscarmen/warp-on-actions@v1.0 + - uses: fscarmen/warp-on-actions@v1.1 + + client-ipv4: + runs-on: ubuntu-latest + name: client warp+doh mode with ipv4 + steps: + - name: Set up WARP with client with ipv4 + uses: fscarmen/warp-on-actions@v1.1 + with: + mode: client + stack: ipv4 - client: + client-ipv6: runs-on: ubuntu-latest - name: client warp+doh mode + name: client warp+doh mode with ipv6 steps: - name: Set up WARP with client - uses: fscarmen/warp-on-actions@v1.0 + uses: fscarmen/warp-on-actions@v1.1 with: mode: client + stack: ipv6 - wireguard: + client-dual: runs-on: ubuntu-latest - name: wireguard mode + name: client warp+doh mode with dual steps: - - name: Set up WARP with wireguard - uses: fscarmen/warp-on-actions@v1.0 + - name: Set up WARP with client + uses: fscarmen/warp-on-actions@v1.1 with: - mode: wireguard \ No newline at end of file + mode: client + stack: dual \ No newline at end of file diff --git a/README.md b/README.md index cf56ae8..0a7d338 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,17 @@ * * * -Usage: -* client warp+doh mode +### Usage example: +client warp+doh mode ``` - name: Set up WARP - uses: fscarmen/warp-on-actions@v1.0 + uses: fscarmen/warp-on-actions@v1.1 with: - mode: client # Optional, default + stack: dual # Optional. Support [ ipv4, ipv6, dual ]. Default is dual. ``` -* wireguard -``` - - name: Set up WARP - uses: fscarmen/warp-on-actions@v1.0 - with: - mode: wireguard -``` \ No newline at end of file +### Input Parameters + +| Parameter | **Mandatory**/**Optional** | Description | +| --------- | -------- | ----------- | +| stack | **Optional** | WARP stack: one of `ipv4`, `ipv6`,`dual`. Default is `dual`. | \ No newline at end of file diff --git a/action.yml b/action.yml index 1b52c89..f1c552b 100644 --- a/action.yml +++ b/action.yml @@ -4,54 +4,33 @@ author: 'fscarmen ' description: 'Install Cloudflare Warp on Github actions' inputs: - mode: - description: 'Choose WARP mode: wireguard or client.' + stack: + description: 'Choose WARP stacks: IPv4/IPv6 only or dualstacks.' required: false - default: 'client' + default: 'dual' runs: using: composite steps: - name: Install WARP run: | - if [ "${{ inputs.mode }}" == 'client' ]; then - echo "WARP mode: client warp+doh." - sudo apt-get -y update - curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list - sudo apt-get update - sudo apt-get install -y cloudflare-warp - sudo warp-cli --accept-tos register - sudo warp-cli --accept-tos set-mode warp+doh - sudo warp-cli --accept-tos connect - - elif [ "${{ inputs.mode }}" == 'wireguard' ]; then - echo "WARP mode: wireguard." - sudo apt-get -y update - sudo apt-get -y install --no-install-recommends net-tools iproute2 openresolv dnsutils iptables wireguard-tools - LAN=$(ip route get 192.168.193.10 | grep -oP 'src \K\S+') - echo "[Interface] - PrivateKey = cKE7LmCF61IhqqABGhvJ44jWXp8fKymcMAEVAzbDF2k= - Address = 172.16.0.2/32 - Address = fd01:5ca1:ab1e:823e:e094:eb1c:ff87:1fab/128 - PostUp = ip -4 rule add from $LAN lookup main - PostDown = ip -4 rule delete from $LAN lookup main - DNS = 8.8.8.8,8.8.4.4 - MTU = 1280 - - [Peer] - PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo= - AllowedIPs = 0.0.0.0/0 - AllowedIPs = ::/0 - Endpoint = 162.159.193.10:2408" | sed "s/^[ ]\+//g" | sudo tee /etc/wireguard/warp.conf - sudo wg-quick up warp - - else - echo -e "WARP mode: ${{ inputs.mode }}.\nYou can choose client or wireguard." - exit 1 + echo "WARP mode: client warp+doh." + sudo apt-get -y update + curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list + sudo apt-get update + sudo apt-get install -y cloudflare-warp + sudo warp-cli --accept-tos registration new + sudo warp-cli --accept-tos mode warp+doh + if [ "${{ inputs.stack }}" == 'ipv4' ]; then + sudo warp-cli --accept-tos add-excluded-route ::/0 + elif [ "${{ inputs.stack }}" == 'ipv6' ]; then + sudo warp-cli --accept-tos add-excluded-route 0.0.0.0/0 fi + sudo warp-cli --accept-tos connect sleep 1 - sudo curl -s4m8 --retry 3 -A Mozilla https://api.ip.sb/geoip + echo "IPv4: $(sudo curl -s4m8 --retry 3 -A Mozilla https://api.ip.sb/geoip)" + echo "IPv6: $(sudo curl -s6m8 --retry 3 -A Mozilla https://api.ip.sb/geoip)" shell: bash \ No newline at end of file