diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85156b9..b6f41a8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,31 +12,72 @@ jobs: runs-on: ubuntu-latest name: client warp+doh mode by default steps: - - uses: fscarmen/warp-on-actions@v1.2 + - uses: fscarmen/warp-on-actions@v1.3 + with: + mode: client 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.2 + uses: fscarmen/warp-on-actions@v1.3 with: stack: ipv4 + mode: client client-ipv6: runs-on: ubuntu-latest name: client warp+doh mode with ipv6 steps: - name: Set up WARP with client - uses: fscarmen/warp-on-actions@v1.2 + uses: fscarmen/warp-on-actions@v1.3 with: stack: ipv6 + mode: client client-dual: runs-on: ubuntu-latest name: client warp+doh mode with dual steps: - name: Set up WARP with client - uses: fscarmen/warp-on-actions@v1.2 + uses: fscarmen/warp-on-actions@v1.3 + with: + stack: dual + mode: client + + wireguard-dual-by-default: + runs-on: ubuntu-latest + name: wireguard mode by default + steps: + - uses: fscarmen/warp-on-actions@v1.3 + + wireguard-ipv4: + runs-on: ubuntu-latest + name: wireguard mode with ipv4 + steps: + - name: Set up WARP with client with ipv4 + uses: fscarmen/warp-on-actions@v1.3 + with: + stack: ipv4 + mode: wireguard + + wireguard-ipv6: + runs-on: ubuntu-latest + name: wireguard mode with ipv6 + steps: + - name: Set up WARP with client + uses: fscarmen/warp-on-actions@v1.3 + with: + stack: ipv6 + mode: wireguard + + wireguard-dual: + runs-on: ubuntu-latest + name: wireguard mode with dual + steps: + - name: Set up WARP with client + uses: fscarmen/warp-on-actions@v1.3 with: - stack: dual \ No newline at end of file + stack: dual + mode: wireguard \ No newline at end of file diff --git a/README.md b/README.md index 62ccf1f..c75025a 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,18 @@ * * * ### Usage example: -client warp+doh mode + ``` - name: Set up WARP - uses: fscarmen/warp-on-actions@v1.2 + uses: fscarmen/warp-on-actions@v1.3 with: - stack: dual # Optional. Support [ ipv4, ipv6, dual ]. Default is dual. + stack: dual # Optional. Support [ ipv4, ipv6, dual ]. Default is dual. + mode: wireguard # Optional. Support [ wireguard, client ]. Default is wireguard. ``` ### Input Parameters | Parameter | **Mandatory**/**Optional** | Description | | --------- | -------- | ----------- | -| stack | **Optional** | WARP stack: one of `ipv4`, `ipv6`,`dual`. Default is `dual`. | \ No newline at end of file +| stack | **Optional** | WARP stack: one of `ipv4`, `ipv6`,`dual`. Default is `dual`. | +| mode | **Optional** | WARP mode: one of `wireguard`, `client`. Default is `wireguard`. | diff --git a/action.yml b/action.yml index f6abdb7..2506d24 100644 --- a/action.yml +++ b/action.yml @@ -9,27 +9,72 @@ inputs: required: false default: 'dual' + mode: + description: 'Choose WARP mode: wireguard or client.' + required: false + default: 'wireguard' + runs: using: composite steps: - name: Install WARP run: | - 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 tunnel ip add-range ::0/0 - elif [ "${{ inputs.stack }}" == 'ipv6' ]; then - sudo warp-cli --accept-tos tunnel ip add-range 0.0.0.0/0 - fi - sudo warp-cli --accept-tos connect + 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 registration new + sudo warp-cli --accept-tos mode warp+doh + if [ "${{ inputs.stack }}" == 'ipv4' ]; then + sudo warp-cli --accept-tos tunnel ip add-range ::0/0 + elif [ "${{ inputs.stack }}" == 'ipv6' ]; then + sudo warp-cli --accept-tos tunnel ip add-range 0.0.0.0/0 + fi + 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+') + CONFIG="[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= + " + + if [ "${{ inputs.stack }}" == 'ipv4' ]; then + CONFIG+="AllowedIPs = 0.0.0.0/0 + " + elif [ "${{ inputs.stack }}" == 'ipv6' ]; then + CONFIG+="AllowedIPs = ::/0 + " + else + CONFIG+="AllowedIPs = 0.0.0.0/0 + AllowedIPs = ::/0 + " + fi + CONFIG+="Endpoint = 162.159.193.10:2408" + echo "$CONFIG" | 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 + fi sleep 1 + echo -e "===============================\nIP:" 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)"