Per-Arne Andersen
4 years ago
committed by
GitHub
37 changed files with 17003 additions and 14994 deletions
@ -0,0 +1,25 @@ |
|||
name: build wg-dashboard |
|||
|
|||
on: |
|||
push: |
|||
branches: |
|||
- master |
|||
|
|||
jobs: |
|||
build: |
|||
runs-on: ubuntu-latest |
|||
steps: |
|||
- name: checkout code |
|||
uses: actions/checkout@v2 |
|||
- name: install buildx |
|||
id: buildx |
|||
uses: crazy-max/ghaction-docker-buildx@v1 |
|||
with: |
|||
version: latest |
|||
- name: login to docker hub |
|||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin |
|||
- name: build the image |
|||
run: | |
|||
docker buildx build --push \ |
|||
--tag perara/wg-manager:latest \ |
|||
--platform linux/amd64 . |
@ -0,0 +1,16 @@ |
|||
dist: focal |
|||
os: linux |
|||
language: python |
|||
env: |
|||
global: |
|||
- DOCKER_REPO=perara/wg-manager |
|||
before_install: |
|||
- curl -fsSL https://get.docker.com | sh |
|||
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json |
|||
- mkdir -p $HOME/.docker |
|||
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json |
|||
- sudo service docker start |
|||
install: |
|||
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
|||
- docker buildx create --name xbuilder --use |
|||
script: bash scripts/ci.sh |
@ -0,0 +1,16 @@ |
|||
import requests |
|||
|
|||
if __name__ == "__main__": |
|||
sess = requests.Session() |
|||
|
|||
resp = sess.post("http://localhost:8888/api/v1/login", data={ |
|||
"username": "admin", |
|||
"password": "admin" |
|||
}) |
|||
print(resp.json()) |
|||
sess.headers.update({ |
|||
"Authorization": f"Bearer {resp.json()['access_token']}" |
|||
}) |
|||
|
|||
for _ in range(20): |
|||
print(sess.get("http://localhost:8888/api/v1/wg/generate_psk").json()) |
@ -1,5 +1,6 @@ |
|||
#!/usr/bin/env bash |
|||
cd .. |
|||
docker login |
|||
|
|||
docker build -t perara/wg-manager . |
|||
docker push perara/wg-manager |
|||
docker build -t perara/wg-manager:dev . |
|||
docker push perara/wg-manager:dev |
|||
|
@ -0,0 +1,59 @@ |
|||
# Build Docker Image from Github Repo |
|||
The steps below will walk you through installing the application in a docker container from the latest github version. |
|||
|
|||
--- |
|||
|
|||
First thing we need to do is clone the github repository |
|||
```bash |
|||
git clone https://github.com/perara/wg-manager.git |
|||
``` |
|||
|
|||
Next we need to build the image. This will take some time. |
|||
```bash |
|||
docker build -t wg-manager . |
|||
``` |
|||
|
|||
Now that our image is built, we can either launch the container via _docker-compose_ or through the _docker CLI_. |
|||
|
|||
## Docker Compose |
|||
```yaml |
|||
version: "2.1" |
|||
services: |
|||
wireguard: |
|||
container_name: wg-manager |
|||
image: wg-manager |
|||
restart: always |
|||
sysctls: |
|||
net.ipv6.conf.all.disable_ipv6: 0 # Required for IPV6 |
|||
cap_add: |
|||
- NET_ADMIN |
|||
network_mode: host |
|||
ports: |
|||
- 51802:51802/udp |
|||
- 8888:8888 |
|||
volumes: |
|||
- ./wg-manager:/config |
|||
environment: |
|||
HOST: 0.0.0.0 |
|||
PORT: 8888 |
|||
ADMIN_USERNAME: admin |
|||
ADMIN_PASSWORD: admin |
|||
WEB_CONCURRENCY: 1 |
|||
``` |
|||
|
|||
## Docker CLI |
|||
```bash |
|||
docker run -d \ |
|||
--sysctl net.ipv6.conf.all.disable_ipv6=0 \ |
|||
--cap-add NET_ADMIN \ |
|||
--name wg-manager \ |
|||
--net host \ |
|||
-p "51802:51802/udp" \ |
|||
-p "8888:8888" \ |
|||
-v wg-manager:/config \ |
|||
-e HOST="0.0.0.0" \ |
|||
-e PORT="8888" \ |
|||
-e ADMIN_USERNAME="admin" \ |
|||
-e ADMIN_PASSWORD="admin" \ |
|||
wg-manager |
|||
``` |
@ -0,0 +1,17 @@ |
|||
#!/bin/bash |
|||
|
|||
if [ "$TRAVIS_PULL_REQUEST" = "true" ] || [ "$TRAVIS_BRANCH" != "master" ]; then |
|||
docker buildx build \ |
|||
--progress plain \ |
|||
--platform=linux/amd64,linux/arm64/v8,linux/arm64,linux/arm/v7,linux/arm/v6 \ |
|||
. |
|||
exit $? |
|||
fi |
|||
echo $DOCKER_PASSWORD | docker login -u qmcgaw --password-stdin &> /dev/null |
|||
TAG="${TRAVIS_TAG:-latest}" |
|||
docker buildx build \ |
|||
--progress plain \ |
|||
--platform=linux/amd64,linux/arm64/v8,linux/arm64,linux/arm/v7,linux/arm/v6 \ |
|||
-t $DOCKER_REPO:$TAG \ |
|||
--push \ |
|||
. |
@ -0,0 +1,21 @@ |
|||
from sqlalchemy import * |
|||
from migrate import * |
|||
|
|||
|
|||
def upgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
server = Table('server', meta, autoload=True) |
|||
allowed_ips = Column('allowed_ips', Text) |
|||
allowed_ips.create(server) |
|||
except: |
|||
pass |
|||
|
|||
|
|||
def downgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
server = Table('server', meta, autoload=True) |
|||
server.c.allowed_ips.drop() |
|||
except: |
|||
pass |
@ -0,0 +1,21 @@ |
|||
from sqlalchemy import * |
|||
from migrate import * |
|||
|
|||
|
|||
def upgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
server = Table('server', meta, autoload=True) |
|||
keep_alive = Column('keep_alive', Integer) |
|||
keep_alive.create(server) |
|||
except: |
|||
pass |
|||
|
|||
|
|||
def downgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
server = Table('server', meta, autoload=True) |
|||
server.c.keep_alive.drop() |
|||
except: |
|||
pass |
@ -0,0 +1,21 @@ |
|||
from sqlalchemy import * |
|||
from migrate import * |
|||
|
|||
|
|||
def upgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
peer = Table('peer', meta, autoload=True) |
|||
keep_alive = Column('keep_alive', Integer) |
|||
keep_alive.create(peer) |
|||
except: |
|||
pass |
|||
|
|||
|
|||
def downgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
peer = Table('peer', meta, autoload=True) |
|||
peer.c.keep_alive.drop() |
|||
except: |
|||
pass |
@ -0,0 +1,20 @@ |
|||
from sqlalchemy import * |
|||
from migrate import * |
|||
|
|||
|
|||
def upgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
server = Table('server', meta, autoload=True) |
|||
server.c.v6_subnet.alter(nullable=True) |
|||
except: |
|||
pass |
|||
|
|||
|
|||
def downgrade(migrate_engine): |
|||
try: |
|||
meta = MetaData(bind=migrate_engine) |
|||
server = Table('server', meta, autoload=True) |
|||
server.c.v6_subnet.alter(nullable=False) |
|||
except: |
|||
pass |
@ -1,12 +1,13 @@ |
|||
[Interface] |
|||
Address = {{ data.peer.address }}/{{ data.server.subnet }}{%- if is_ipv6 -%},{{ data.peer.v6_address }}/{{ data.server.v6_subnet }}{%- endif %} |
|||
PrivateKey = {{ data.peer.private_key }} |
|||
{% if data.peer.dns %} |
|||
DNS = {{ data.peer.dns }} |
|||
{% endif %} |
|||
|
|||
[Peer] |
|||
PublicKey = {{ data.server.public_key }} |
|||
AllowedIPs = {{ data.peer.allowed_ips }} |
|||
Endpoint = {{ data.server.endpoint }}:{{ data.server.listen_port }} |
|||
{% if data.peer.shared_key %} |
|||
PresharedKey = {{ data.peer.shared_key }} |
|||
{% endif %} |
|||
{% if data.peer.shared_key %}PresharedKey = {{ data.peer.shared_key }}{% endif %} |
|||
{% if data.peer.keep_alive %}PersistentKeepalive = {{data.peer.keep_alive}}{% endif %} |
|||
|
File diff suppressed because it is too large
@ -1,12 +1,22 @@ |
|||
import { AbstractControl, ValidationErrors } from '@angular/forms'; |
|||
import * as IPCIDR from 'ip-cidr'; |
|||
import {Address4, Address6} from 'ip-address' |
|||
|
|||
export class IPValidator { |
|||
|
|||
static isIPAddress(control: AbstractControl): ValidationErrors | null { |
|||
if (!control.value || !(new IPCIDR(control.value).isValid())) { |
|||
return { validIP: true }; |
|||
} |
|||
return null; |
|||
|
|||
try { |
|||
new Address4(control.value) |
|||
return null |
|||
} catch (e) {} |
|||
try{ |
|||
new Address6(control.value) |
|||
return null |
|||
} catch (e) {} |
|||
return { validIP: true }; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
|
Loading…
Reference in new issue