Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
perf: README.md & deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Lugones committed Oct 24, 2021
1 parent f7b831e commit de3f20c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ FROM linuxserver/wireguard as wireguard_api
RUN apt-get -y update
RUN apt-get install -y python3.6 python3-pip python-dev build-essential python3-venv

RUN mkdir -p /codebase
ADD . /codebase
WORKDIR /codebase
ADD . /
WORKDIR /

RUN pip3 install -r requirements.txt

Expand Down
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# wireguard-api
VPN node based in Wireguard with an API to get commands from master node

VPN node based in Wireguard with an API exposed to receive commands.

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ragnarok22/wireguard-api/Release?label=Release)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ragnarok22/wireguard-api/Publish%20Docker%20image?label=Docker%20image)
Expand All @@ -9,13 +10,60 @@ VPN node based in Wireguard with an API to get commands from master node
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

## Installation

Pull the image from GitHub Container Registery:

```bash
docker pull ghcr.io/lugodev/wireguard-api:main
```

## Run the container

Run the container, providing the environment vars and the volume to store the VPN configurations:

```
docker run wireguard-api -d \
-e API_TOKEN=YOUR_TOKEN \
-e VPN_HOSTNAME=YOUR_HOSTNAME \
-v /wireguard-api:/wireguard-api
```

The env vars:
* `YOUR_TOKEN`: the token you pass to the API when sending commands via HTTP requests.
* `YOUR_HOSTNAME`: your VPN hostname.

The volume `/wireguard-api` holds the VPN configurations, map the folder you'd like in your folders structure.

## Ports exposed

The container exposes two ports, which must be allowed in your firewall in order to receive traffic.

* `51820`: WireGuard protocol.
* `8008`: WireGuard API.

Allow the ports:

```bash
ufw allow 51820
ufw allow 8008
ufw reload
```

## Usage
An easy way to communicate your wireguard server with your ui. Just make a post request to root route with de token key and the command. Example:

An easy way to communicate your WireGuard server with your UI. Just make a post request to root route with the token key and the command. Example:

```bash
curl --request POST http://wireguard_api -d 'token=my_token&command=my_command'
```

Examples:

```BASH
curl --request POST http://myvpn.com:8008/ -d 'token=my_token&command=wg set wg0 peer 6DVHXzbM0TfPr6Q4yDBtA/A0jzdUXu8XqR+yV2vF1F9= remove'
```

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
1 change: 0 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async def run_command(command: Command):
shell=True,
stderr=subprocess.STDOUT
)

except Exception as e:
status = str(e)
return {"status": status}
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ services:
- INTERNAL_SUBNET=10.13.13.0 # only change if it clashes
- ALLOWEDIPS=0.0.0.0/0 # change this or ALL traffic will be routed through the VPN
volumes:
- /apps/wireguard-api:/codebase
- /apps/wireguard-api:/config
- /lib/modules:/lib/modules
networks:
wireguard_api_subnet:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "Wireguard-Api"
name = "wireguard-api"
version = "0.1.0"
description = "VPN node based in Wireguard with an API to get commands from master node"
description = "VPN node based in Wireguard with an API exposed to receive commands"
authors = ["Carlos Lugones <[email protected]>", "Reinier Hernández <[email protected]>"]

[tool.poetry.dependencies]
Expand Down

0 comments on commit de3f20c

Please sign in to comment.