Skip to content

Commit

Permalink
v1.3 Add wireguard mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarmen committed Oct 28, 2024
1 parent 231be33 commit 0e0fbd8
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 23 deletions.
51 changes: 46 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,72 @@ jobs:
runs-on: ubuntu-latest
name: client warp+doh mode by default
steps:
- uses: fscarmen/[email protected]
- uses: fscarmen/[email protected]
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/[email protected]
uses: fscarmen/[email protected]
with:
stack: dual
mode: client

wireguard-dual-by-default:
runs-on: ubuntu-latest
name: wireguard mode by default
steps:
- uses: fscarmen/[email protected]

wireguard-ipv4:
runs-on: ubuntu-latest
name: wireguard mode with ipv4
steps:
- name: Set up WARP with client with ipv4
uses: fscarmen/[email protected]
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/[email protected]
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/[email protected]
with:
stack: dual
stack: dual
mode: wireguard
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. |
| stack | **Optional** | WARP stack: one of `ipv4`, `ipv6`,`dual`. Default is `dual`. |
| mode | **Optional** | WARP mode: one of `wireguard`, `client`. Default is `wireguard`. |
73 changes: 59 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit 0e0fbd8

Please sign in to comment.