├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── deploy-nightly.yml │ ├── deploy.yml │ ├── lint.yml │ └── stale.yml ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── assets ├── screenshot.png └── wg-easy.sketch ├── docker-compose.dev.yml ├── docker-compose.yml ├── docs └── changelog.json ├── package-lock.json ├── package.json └── src ├── .eslintrc.json ├── .gitignore ├── config.js ├── lib ├── Server.js ├── ServerError.js ├── Util.js └── WireGuard.js ├── package-lock.json ├── package.json ├── server.js ├── services ├── Server.js └── WireGuard.js └── www ├── css └── vendor │ └── tailwind.min.css ├── img ├── apple-touch-icon.png ├── favicon.png └── logo.png ├── index.html ├── js ├── api.js ├── app.js └── vendor │ ├── md5.min.js │ ├── timeago.min.js │ └── vue.min.js └── manifest.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: weejewel 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/workflows/deploy-nightly.yml: -------------------------------------------------------------------------------- 1 | name: Build & Publish Nightly Docker Image to GitHub Container Registry 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 12 * * *" 7 | 8 | jobs: 9 | deploy: 10 | name: Build & Deploy 11 | runs-on: ubuntu-latest 12 | permissions: 13 | packages: write 14 | contents: read 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | ref: production 19 | 20 | - name: Set up QEMU 21 | uses: docker/setup-qemu-action@v1 22 | 23 | - name: Set up Docker Buildx 24 | uses: docker/setup-buildx-action@v1 25 | 26 | - name: Login to GitHub Container Registry 27 | uses: docker/login-action@v3 28 | with: 29 | registry: ghcr.io 30 | username: ${{ github.actor }} 31 | password: ${{ secrets.GITHUB_TOKEN }} 32 | 33 | - name: Set environment variables 34 | run: echo RELEASE=$(cat ./src/package.json | jq -r .release) >> $GITHUB_ENV 35 | 36 | - name: Build & Publish Docker Image 37 | uses: docker/build-push-action@v5 38 | with: 39 | push: true 40 | platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 41 | tags: ghcr.io/wg-easy/wg-easy:nightly, ghcr.io/wg-easy/wg-easy:${{ env.RELEASE }}-nightly 42 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Build & Publish Docker Image to GitHub Container Registry 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - production 8 | 9 | jobs: 10 | deploy: 11 | name: Build & Deploy 12 | runs-on: ubuntu-latest 13 | permissions: 14 | packages: write 15 | contents: read 16 | steps: 17 | - uses: actions/checkout@v4 18 | with: 19 | ref: production 20 | 21 | - name: Set up QEMU 22 | uses: docker/setup-qemu-action@v1 23 | 24 | - name: Set up Docker Buildx 25 | uses: docker/setup-buildx-action@v1 26 | 27 | - name: Login to GitHub Container Registry 28 | uses: docker/login-action@v3 29 | with: 30 | registry: ghcr.io 31 | username: ${{ github.actor }} 32 | password: ${{ secrets.GITHUB_TOKEN }} 33 | 34 | - name: Set environment variables 35 | run: echo RELEASE=$(cat ./src/package.json | jq -r .release) >> $GITHUB_ENV 36 | 37 | - name: Build & Publish Docker Image 38 | uses: docker/build-push-action@v5 39 | with: 40 | push: true 41 | platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 42 | tags: ghcr.io/wg-easy/wg-easy:latest, ghcr.io/wg-easy/wg-easy:${{ env.RELEASE }} 43 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - production 8 | pull_request: 9 | 10 | jobs: 11 | lint: 12 | name: Lint 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: actions/setup-node@v1 17 | with: 18 | node-version: '18' 19 | 20 | - run: | 21 | cd src 22 | npm ci 23 | npm run lint 24 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. 2 | # 3 | # You can adjust the behavior by modifying this file. 4 | # For more information, see: 5 | # https://github.com/actions/stale 6 | name: Mark stale issues and pull requests 7 | 8 | on: 9 | workflow_dispatch: 10 | schedule: 11 | - cron: '*/5 * * * *' 12 | 13 | jobs: 14 | stale: 15 | 16 | runs-on: ubuntu-latest 17 | permissions: 18 | issues: write 19 | pull-requests: write 20 | 21 | steps: 22 | - uses: actions/stale@v5 23 | with: 24 | days-before-issue-stale: 14 25 | days-before-issue-close: 7 26 | stale-issue-label: "stale" 27 | stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." 28 | close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." 29 | days-before-pr-stale: 30 30 | days-before-pr-close: 14 31 | stale-pr-message: "This PR is stale because it has been open for 30 days with no activity." 32 | close-pr-message: "This PR was closed because it has been inactive for 14 days since being marked as stale." 33 | repo-token: ${{ secrets.GITHUB_TOKEN }} 34 | operations-per-run: 100 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /config 2 | /wg0.conf 3 | /wg0.json -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/node:18-alpine AS build_node_modules 2 | 3 | # Copy Web UI 4 | COPY src/ /app/ 5 | WORKDIR /app 6 | RUN npm ci --production 7 | 8 | # Copy build result to a new image. 9 | # This saves a lot of disk space. 10 | FROM docker.io/library/node:18-alpine 11 | COPY --from=build_node_modules /app /app 12 | 13 | # Move node_modules one directory up, so during development 14 | # we don't have to mount it in a volume. 15 | # This results in much faster reloading! 16 | # 17 | # Also, some node_modules might be native, and 18 | # the architecture & OS of your development machine might differ 19 | # than what runs inside of docker. 20 | RUN mv /app/node_modules /node_modules 21 | 22 | # Install Linux packages 23 | RUN apk add -U --no-cache \ 24 | iptables \ 25 | wireguard-tools \ 26 | dumb-init 27 | 28 | # Expose Ports 29 | EXPOSE 51820/udp 30 | EXPOSE 51821/tcp 31 | 32 | # Set Environment 33 | ENV DEBUG=Server,WireGuard 34 | 35 | # Run Web UI 36 | WORKDIR /app 37 | CMD ["/usr/bin/dumb-init", "node", "server.js"] 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | **You may:** 2 | 3 | * Use this software for yourself; 4 | * Use this software for a company; 5 | * Modify this software, as long as you: 6 | * Publish the changes on GitHub as an open-source & linked fork; 7 | * Don't remove any links to the original project or donation pages; 8 | 9 | **You may not:** 10 | 11 | * Use this software in a commercial product without a license from the original author; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WireGuard Easy 2 | 3 | [![Build & Publish Docker Image to Docker Hub](https://github.com/wg-easy/wg-easy/actions/workflows/deploy.yml/badge.svg?branch=production)](https://github.com/wg-easy/wg-easy/actions/workflows/deploy.yml) 4 | [![Lint](https://github.com/wg-easy/wg-easy/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/wg-easy/wg-easy/actions/workflows/lint.yml) 5 | ![Docker](https://img.shields.io/docker/pulls/weejewel/wg-easy.svg) 6 | [![Sponsor](https://img.shields.io/github/sponsors/weejewel)](https://github.com/sponsors/WeeJeWel) 7 | ![GitHub Stars](https://img.shields.io/github/stars/wg-easy/wg-easy) 8 | 9 | You have found the easiest way to install & manage WireGuard on any Linux host! 10 | 11 |

12 | 13 |

14 | 15 | ## Features 16 | 17 | * All-in-one: WireGuard + Web UI. 18 | * Easy installation, simple to use. 19 | * List, create, edit, delete, enable & disable clients. 20 | * Show a client's QR code. 21 | * Download a client's configuration file. 22 | * Statistics for which clients are connected. 23 | * Tx/Rx charts for each connected client. 24 | * Gravatar support. 25 | 26 | ## Requirements 27 | 28 | * A host with a kernel that supports WireGuard (all modern kernels). 29 | * A host with Docker installed. 30 | 31 | ## Installation 32 | 33 | ### 1. Install Docker 34 | 35 | If you haven't installed Docker yet, install it by running: 36 | 37 | ```bash 38 | $ curl -sSL https://get.docker.com | sh 39 | $ sudo usermod -aG docker $(whoami) 40 | $ exit 41 | ``` 42 | 43 | And log in again. 44 | 45 | ### 2. Run WireGuard Easy 46 | 47 | To automatically install & run wg-easy, simply run: 48 | 49 |
 50 | $ docker run -d \
 51 |   --name=wg-easy \
 52 |   -e WG_HOST=🚨YOUR_SERVER_IP \
 53 |   -e PASSWORD=🚨YOUR_ADMIN_PASSWORD \
 54 |   -v ~/.wg-easy:/etc/wireguard \
 55 |   -p 51820:51820/udp \
 56 |   -p 51821:51821/tcp \
 57 |   --cap-add=NET_ADMIN \
 58 |   --cap-add=SYS_MODULE \
 59 |   --sysctl="net.ipv4.conf.all.src_valid_mark=1" \
 60 |   --sysctl="net.ipv4.ip_forward=1" \
 61 |   --restart unless-stopped \
 62 |   ghcr.io/wg-easy/wg-easy
 63 | 
64 | 65 | > 💡 Replace `YOUR_SERVER_IP` with your WAN IP, or a Dynamic DNS hostname. 66 | > 67 | > 💡 Replace `YOUR_ADMIN_PASSWORD` with a password to log in on the Web UI. 68 | 69 | The Web UI will now be available on `http://0.0.0.0:51821`. 70 | 71 | > 💡 Your configuration files will be saved in `~/.wg-easy` 72 | 73 | ### 3. Sponsor 74 | 75 | Are you enjoying this project? [Buy me a beer!](https://github.com/sponsors/WeeJeWel) 🍻 76 | 77 | ## Options 78 | 79 | These options can be configured by setting environment variables using `-e KEY="VALUE"` in the `docker run` command. 80 | 81 | | Env | Default | Example | Description | 82 | | - | - | - | - | 83 | | `PASSWORD` | - | `foobar123` | When set, requires a password when logging in to the Web UI. | 84 | | `WG_HOST` | - | `vpn.myserver.com` | The public hostname of your VPN server. | 85 | | `WG_DEVICE` | `eth0` | `ens6f0` | Ethernet device the wireguard traffic should be forwarded through. | 86 | | `WG_PORT` | `51820` | `12345` | The public UDP port of your VPN server. WireGuard will always listen on `51820` inside the Docker container. | 87 | | `WG_MTU` | `null` | `1420` | The MTU the clients will use. Server uses default WG MTU. | 88 | | `WG_PERSISTENT_KEEPALIVE` | `0` | `25` | Value in seconds to keep the "connection" open. If this value is 0, then connections won't be kept alive. | 89 | | `WG_DEFAULT_ADDRESS` | `10.8.0.x` | `10.6.0.x` | Clients IP address range. | 90 | | `WG_DEFAULT_DNS` | `1.1.1.1` | `8.8.8.8, 8.8.4.4` | DNS server clients will use. | 91 | | `WG_ALLOWED_IPS` | `0.0.0.0/0, ::/0` | `192.168.15.0/24, 10.0.1.0/24` | Allowed IPs clients will use. | 92 | | `WG_PRE_UP` | `...` | - | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L19) for the default value. | 93 | | `WG_POST_UP` | `...` | `iptables ...` | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L20) for the default value. | 94 | | `WG_PRE_DOWN` | `...` | - | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L27) for the default value. | 95 | | `WG_POST_DOWN` | `...` | `iptables ...` | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L28) for the default value. | 96 | 97 | > If you change `WG_PORT`, make sure to also change the exposed port. 98 | 99 | ## Updating 100 | 101 | To update to the latest version, simply run: 102 | 103 | ```bash 104 | docker stop wg-easy 105 | docker rm wg-easy 106 | docker pull ghcr.io/wg-easy/wg-easy 107 | ``` 108 | 109 | And then run the `docker run -d \ ...` command above again. 110 | 111 | ## Common Use Cases 112 | 113 | * [Using WireGuard-Easy with Pi-Hole](https://github.com/wg-easy/wg-easy/wiki/Using-WireGuard-Easy-with-Pi-Hole) 114 | * [Using WireGuard-Easy with nginx/SSL](https://github.com/wg-easy/wg-easy/wiki/Using-WireGuard-Easy-with-nginx-SSL) 115 | -------------------------------------------------------------------------------- /assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeeJeWel/wg-easy/83ac4ff4cf96b23ec4e1d8019413311834083d7a/assets/screenshot.png -------------------------------------------------------------------------------- /assets/wg-easy.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeeJeWel/wg-easy/83ac4ff4cf96b23ec4e1d8019413311834083d7a/assets/wg-easy.sketch -------------------------------------------------------------------------------- /docker-compose.dev.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | wg-easy: 4 | image: wg-easy 5 | command: npm run serve 6 | volumes: 7 | - ./src/:/app/ 8 | environment: 9 | # - PASSWORD=p 10 | - WG_HOST=192.168.1.233 11 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | wg-easy: 4 | environment: 5 | # ⚠️ Required: 6 | # Change this to your host's public address 7 | - WG_HOST=raspberrypi.local 8 | 9 | # Optional: 10 | # - PASSWORD=foobar123 11 | # - WG_PORT=51820 12 | # - WG_DEFAULT_ADDRESS=10.8.0.x 13 | # - WG_DEFAULT_DNS=1.1.1.1 14 | # - WG_MTU=1420 15 | # - WG_ALLOWED_IPS=192.168.15.0/24, 10.0.1.0/24 16 | # - WG_PRE_UP=echo "Pre Up" > /etc/wireguard/pre-up.txt 17 | # - WG_POST_UP=echo "Post Up" > /etc/wireguard/post-up.txt 18 | # - WG_PRE_DOWN=echo "Pre Down" > /etc/wireguard/pre-down.txt 19 | # - WG_POST_DOWN=echo "Post Down" > /etc/wireguard/post-down.txt 20 | 21 | image: ghcr.io/wg-easy/wg-easy 22 | container_name: wg-easy 23 | volumes: 24 | - .:/etc/wireguard 25 | ports: 26 | - "51820:51820/udp" 27 | - "51821:51821/tcp" 28 | restart: unless-stopped 29 | cap_add: 30 | - NET_ADMIN 31 | - SYS_MODULE 32 | sysctls: 33 | - net.ipv4.ip_forward=1 34 | - net.ipv4.conf.all.src_valid_mark=1 35 | -------------------------------------------------------------------------------- /docs/changelog.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": "Initial version. Enjoy!", 3 | "2": "You can now rename a client, and update the address. Enjoy!", 4 | "3": "Many improvements and small changes. Enjoy!", 5 | "4": "Now with pretty charts for client's network speed. Enjoy!", 6 | "5": "Many small improvements & feature requests. Enjoy!", 7 | "6": "Many small performance improvements & bug fixes. Enjoy!", 8 | "7": "Improved the look & performance of the upload/download chart.", 9 | "8": "Updated to Node.js v18." 10 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "lockfileVersion": 1 4 | } 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "scripts": { 4 | "build": "DOCKER_BUILDKIT=1 docker build --tag wg-easy .", 5 | "serve": "docker-compose -f docker-compose.yml -f docker-compose.dev.yml up", 6 | "start": "docker run --env WG_HOST=0.0.0.0 --name wg-easy --cap-add=NET_ADMIN --cap-add=SYS_MODULE --sysctl=\"net.ipv4.conf.all.src_valid_mark=1\" --mount type=bind,source=\"$(pwd)\"/config,target=/etc/wireguard -p 51820:51820/udp -p 51821:51821/tcp wg-easy" 7 | } 8 | } -------------------------------------------------------------------------------- /src/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "athom", 3 | "ignorePatterns": [ 4 | "**/vendor/*.js" 5 | ], 6 | "rules": { 7 | "consistent-return": "off", 8 | "no-shadow": "off", 9 | "max-len": "off" 10 | } 11 | } -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules -------------------------------------------------------------------------------- /src/config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { release } = require('./package.json'); 4 | 5 | module.exports.RELEASE = release; 6 | module.exports.PORT = process.env.PORT || 51821; 7 | module.exports.PASSWORD = process.env.PASSWORD; 8 | module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/'; 9 | module.exports.WG_DEVICE = process.env.WG_DEVICE || 'eth0'; 10 | module.exports.WG_HOST = process.env.WG_HOST; 11 | module.exports.WG_PORT = process.env.WG_PORT || 51820; 12 | module.exports.WG_MTU = process.env.WG_MTU || null; 13 | module.exports.WG_PERSISTENT_KEEPALIVE = process.env.WG_PERSISTENT_KEEPALIVE || 0; 14 | module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x'; 15 | module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string' 16 | ? process.env.WG_DEFAULT_DNS 17 | : '1.1.1.1'; 18 | module.exports.WG_ALLOWED_IPS = process.env.WG_ALLOWED_IPS || '0.0.0.0/0, ::/0'; 19 | 20 | module.exports.WG_PRE_UP = process.env.WG_PRE_UP || ''; 21 | module.exports.WG_POST_UP = process.env.WG_POST_UP || ` 22 | iptables -t nat -A POSTROUTING -s ${module.exports.WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o ${module.exports.WG_DEVICE} -j MASQUERADE; 23 | iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT; 24 | iptables -A FORWARD -i wg0 -j ACCEPT; 25 | iptables -A FORWARD -o wg0 -j ACCEPT; 26 | `.split('\n').join(' '); 27 | 28 | module.exports.WG_PRE_DOWN = process.env.WG_PRE_DOWN || ''; 29 | module.exports.WG_POST_DOWN = process.env.WG_POST_DOWN || ''; 30 | -------------------------------------------------------------------------------- /src/lib/Server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | const express = require('express'); 6 | const expressSession = require('express-session'); 7 | const debug = require('debug')('Server'); 8 | 9 | const Util = require('./Util'); 10 | const ServerError = require('./ServerError'); 11 | const WireGuard = require('../services/WireGuard'); 12 | 13 | const { 14 | PORT, 15 | RELEASE, 16 | PASSWORD, 17 | } = require('../config'); 18 | 19 | module.exports = class Server { 20 | 21 | constructor() { 22 | // Express 23 | this.app = express() 24 | .disable('etag') 25 | .use('/', express.static(path.join(__dirname, '..', 'www'))) 26 | .use(express.json()) 27 | .use(expressSession({ 28 | secret: String(Math.random()), 29 | resave: true, 30 | saveUninitialized: true, 31 | })) 32 | 33 | .get('/api/release', (Util.promisify(async () => { 34 | return RELEASE; 35 | }))) 36 | 37 | // Authentication 38 | .get('/api/session', Util.promisify(async req => { 39 | const requiresPassword = !!process.env.PASSWORD; 40 | const authenticated = requiresPassword 41 | ? !!(req.session && req.session.authenticated) 42 | : true; 43 | 44 | return { 45 | requiresPassword, 46 | authenticated, 47 | }; 48 | })) 49 | .post('/api/session', Util.promisify(async req => { 50 | const { 51 | password, 52 | } = req.body; 53 | 54 | if (typeof password !== 'string') { 55 | throw new ServerError('Missing: Password', 401); 56 | } 57 | 58 | if (password !== PASSWORD) { 59 | throw new ServerError('Incorrect Password', 401); 60 | } 61 | 62 | req.session.authenticated = true; 63 | req.session.save(); 64 | 65 | debug(`New Session: ${req.session.id}`); 66 | })) 67 | 68 | // WireGuard 69 | .use((req, res, next) => { 70 | if (!PASSWORD) { 71 | return next(); 72 | } 73 | 74 | if (req.session && req.session.authenticated) { 75 | return next(); 76 | } 77 | 78 | return res.status(401).json({ 79 | error: 'Not Logged In', 80 | }); 81 | }) 82 | .delete('/api/session', Util.promisify(async req => { 83 | const sessionId = req.session.id; 84 | 85 | req.session.destroy(); 86 | 87 | debug(`Deleted Session: ${sessionId}`); 88 | })) 89 | .get('/api/wireguard/client', Util.promisify(async req => { 90 | return WireGuard.getClients(); 91 | })) 92 | .get('/api/wireguard/client/:clientId/qrcode.svg', Util.promisify(async (req, res) => { 93 | const { clientId } = req.params; 94 | const svg = await WireGuard.getClientQRCodeSVG({ clientId }); 95 | res.header('Content-Type', 'image/svg+xml'); 96 | res.send(svg); 97 | })) 98 | .get('/api/wireguard/client/:clientId/configuration', Util.promisify(async (req, res) => { 99 | const { clientId } = req.params; 100 | const client = await WireGuard.getClient({ clientId }); 101 | const config = await WireGuard.getClientConfiguration({ clientId }); 102 | const configName = client.name 103 | .replace(/[^a-zA-Z0-9_=+.-]/g, '-') 104 | .replace(/(-{2,}|-$)/g, '-') 105 | .replace(/-$/, '') 106 | .substring(0, 32); 107 | res.header('Content-Disposition', `attachment; filename="${configName || clientId}.conf"`); 108 | res.header('Content-Type', 'text/plain'); 109 | res.send(config); 110 | })) 111 | .post('/api/wireguard/client', Util.promisify(async req => { 112 | const { name } = req.body; 113 | return WireGuard.createClient({ name }); 114 | })) 115 | .delete('/api/wireguard/client/:clientId', Util.promisify(async req => { 116 | const { clientId } = req.params; 117 | return WireGuard.deleteClient({ clientId }); 118 | })) 119 | .post('/api/wireguard/client/:clientId/enable', Util.promisify(async req => { 120 | const { clientId } = req.params; 121 | return WireGuard.enableClient({ clientId }); 122 | })) 123 | .post('/api/wireguard/client/:clientId/disable', Util.promisify(async req => { 124 | const { clientId } = req.params; 125 | return WireGuard.disableClient({ clientId }); 126 | })) 127 | .put('/api/wireguard/client/:clientId/name', Util.promisify(async req => { 128 | const { clientId } = req.params; 129 | const { name } = req.body; 130 | return WireGuard.updateClientName({ clientId, name }); 131 | })) 132 | .put('/api/wireguard/client/:clientId/address', Util.promisify(async req => { 133 | const { clientId } = req.params; 134 | const { address } = req.body; 135 | return WireGuard.updateClientAddress({ clientId, address }); 136 | })) 137 | 138 | .listen(PORT, () => { 139 | debug(`Listening on http://0.0.0.0:${PORT}`); 140 | }); 141 | } 142 | 143 | }; 144 | -------------------------------------------------------------------------------- /src/lib/ServerError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = class ServerError extends Error { 4 | 5 | constructor(message, statusCode = 500) { 6 | super(message); 7 | this.statusCode = statusCode; 8 | } 9 | 10 | }; 11 | -------------------------------------------------------------------------------- /src/lib/Util.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const childProcess = require('child_process'); 4 | 5 | module.exports = class Util { 6 | 7 | static isValidIPv4(str) { 8 | const blocks = str.split('.'); 9 | if (blocks.length !== 4) return false; 10 | 11 | for (let value of blocks) { 12 | value = parseInt(value, 10); 13 | if (Number.isNaN(value)) return false; 14 | if (value < 0 || value > 255) return false; 15 | } 16 | 17 | return true; 18 | } 19 | 20 | static promisify(fn) { 21 | // eslint-disable-next-line func-names 22 | return function(req, res) { 23 | Promise.resolve().then(async () => fn(req, res)) 24 | .then(result => { 25 | if (res.headersSent) return; 26 | 27 | if (typeof result === 'undefined') { 28 | return res 29 | .status(204) 30 | .end(); 31 | } 32 | 33 | return res 34 | .status(200) 35 | .json(result); 36 | }) 37 | .catch(error => { 38 | if (typeof error === 'string') { 39 | error = new Error(error); 40 | } 41 | 42 | // eslint-disable-next-line no-console 43 | console.error(error); 44 | 45 | return res 46 | .status(error.statusCode || 500) 47 | .json({ 48 | error: error.message || error.toString(), 49 | stack: error.stack, 50 | }); 51 | }); 52 | }; 53 | } 54 | 55 | static async exec(cmd, { 56 | log = true, 57 | } = {}) { 58 | if (typeof log === 'string') { 59 | // eslint-disable-next-line no-console 60 | console.log(`$ ${log}`); 61 | } else if (log === true) { 62 | // eslint-disable-next-line no-console 63 | console.log(`$ ${cmd}`); 64 | } 65 | 66 | if (process.platform !== 'linux') { 67 | return ''; 68 | } 69 | 70 | return new Promise((resolve, reject) => { 71 | childProcess.exec(cmd, { 72 | shell: 'bash', 73 | }, (err, stdout) => { 74 | if (err) return reject(err); 75 | return resolve(String(stdout).trim()); 76 | }); 77 | }); 78 | } 79 | 80 | }; 81 | -------------------------------------------------------------------------------- /src/lib/WireGuard.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs').promises; 4 | const path = require('path'); 5 | 6 | const debug = require('debug')('WireGuard'); 7 | const uuid = require('uuid'); 8 | const QRCode = require('qrcode'); 9 | 10 | const Util = require('./Util'); 11 | const ServerError = require('./ServerError'); 12 | 13 | const { 14 | WG_PATH, 15 | WG_HOST, 16 | WG_PORT, 17 | WG_MTU, 18 | WG_DEFAULT_DNS, 19 | WG_DEFAULT_ADDRESS, 20 | WG_PERSISTENT_KEEPALIVE, 21 | WG_ALLOWED_IPS, 22 | WG_PRE_UP, 23 | WG_POST_UP, 24 | WG_PRE_DOWN, 25 | WG_POST_DOWN, 26 | } = require('../config'); 27 | 28 | module.exports = class WireGuard { 29 | 30 | async getConfig() { 31 | if (!this.__configPromise) { 32 | this.__configPromise = Promise.resolve().then(async () => { 33 | if (!WG_HOST) { 34 | throw new Error('WG_HOST Environment Variable Not Set!'); 35 | } 36 | 37 | debug('Loading configuration...'); 38 | let config; 39 | try { 40 | config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8'); 41 | config = JSON.parse(config); 42 | debug('Configuration loaded.'); 43 | } catch (err) { 44 | const privateKey = await Util.exec('wg genkey'); 45 | const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`, { 46 | log: 'echo ***hidden*** | wg pubkey', 47 | }); 48 | const address = WG_DEFAULT_ADDRESS.replace('x', '1'); 49 | 50 | config = { 51 | server: { 52 | privateKey, 53 | publicKey, 54 | address, 55 | }, 56 | clients: {}, 57 | }; 58 | debug('Configuration generated.'); 59 | } 60 | 61 | await this.__saveConfig(config); 62 | await Util.exec('wg-quick down wg0').catch(() => { }); 63 | await Util.exec('wg-quick up wg0').catch(err => { 64 | if (err && err.message && err.message.includes('Cannot find device "wg0"')) { 65 | throw new Error('WireGuard exited with the error: Cannot find device "wg0"\nThis usually means that your host\'s kernel does not support WireGuard!'); 66 | } 67 | 68 | throw err; 69 | }); 70 | // await Util.exec(`iptables -t nat -A POSTROUTING -s ${WG_DEFAULT_ADDRESS.replace('x', '0')}/24 -o eth0 -j MASQUERADE`); 71 | // await Util.exec('iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT'); 72 | // await Util.exec('iptables -A FORWARD -i wg0 -j ACCEPT'); 73 | // await Util.exec('iptables -A FORWARD -o wg0 -j ACCEPT'); 74 | await this.__syncConfig(); 75 | 76 | return config; 77 | }); 78 | } 79 | 80 | return this.__configPromise; 81 | } 82 | 83 | async saveConfig() { 84 | const config = await this.getConfig(); 85 | await this.__saveConfig(config); 86 | await this.__syncConfig(); 87 | } 88 | 89 | async __saveConfig(config) { 90 | let result = ` 91 | # Note: Do not edit this file directly. 92 | # Your changes will be overwritten! 93 | 94 | # Server 95 | [Interface] 96 | PrivateKey = ${config.server.privateKey} 97 | Address = ${config.server.address}/24 98 | ListenPort = 51820 99 | PreUp = ${WG_PRE_UP} 100 | PostUp = ${WG_POST_UP} 101 | PreDown = ${WG_PRE_DOWN} 102 | PostDown = ${WG_POST_DOWN} 103 | `; 104 | 105 | for (const [clientId, client] of Object.entries(config.clients)) { 106 | if (!client.enabled) continue; 107 | 108 | result += ` 109 | 110 | # Client: ${client.name} (${clientId}) 111 | [Peer] 112 | PublicKey = ${client.publicKey} 113 | PresharedKey = ${client.preSharedKey} 114 | AllowedIPs = ${client.address}/32`; 115 | } 116 | 117 | debug('Config saving...'); 118 | await fs.writeFile(path.join(WG_PATH, 'wg0.json'), JSON.stringify(config, false, 2), { 119 | mode: 0o660, 120 | }); 121 | await fs.writeFile(path.join(WG_PATH, 'wg0.conf'), result, { 122 | mode: 0o600, 123 | }); 124 | debug('Config saved.'); 125 | } 126 | 127 | async __syncConfig() { 128 | debug('Config syncing...'); 129 | await Util.exec('wg syncconf wg0 <(wg-quick strip wg0)'); 130 | debug('Config synced.'); 131 | } 132 | 133 | async getClients() { 134 | const config = await this.getConfig(); 135 | const clients = Object.entries(config.clients).map(([clientId, client]) => ({ 136 | id: clientId, 137 | name: client.name, 138 | enabled: client.enabled, 139 | address: client.address, 140 | publicKey: client.publicKey, 141 | createdAt: new Date(client.createdAt), 142 | updatedAt: new Date(client.updatedAt), 143 | allowedIPs: client.allowedIPs, 144 | 145 | persistentKeepalive: null, 146 | latestHandshakeAt: null, 147 | transferRx: null, 148 | transferTx: null, 149 | })); 150 | 151 | // Loop WireGuard status 152 | const dump = await Util.exec('wg show wg0 dump', { 153 | log: false, 154 | }); 155 | dump 156 | .trim() 157 | .split('\n') 158 | .slice(1) 159 | .forEach(line => { 160 | const [ 161 | publicKey, 162 | preSharedKey, // eslint-disable-line no-unused-vars 163 | endpoint, // eslint-disable-line no-unused-vars 164 | allowedIps, // eslint-disable-line no-unused-vars 165 | latestHandshakeAt, 166 | transferRx, 167 | transferTx, 168 | persistentKeepalive, 169 | ] = line.split('\t'); 170 | 171 | const client = clients.find(client => client.publicKey === publicKey); 172 | if (!client) return; 173 | 174 | client.latestHandshakeAt = latestHandshakeAt === '0' 175 | ? null 176 | : new Date(Number(`${latestHandshakeAt}000`)); 177 | client.transferRx = Number(transferRx); 178 | client.transferTx = Number(transferTx); 179 | client.persistentKeepalive = persistentKeepalive; 180 | }); 181 | 182 | return clients; 183 | } 184 | 185 | async getClient({ clientId }) { 186 | const config = await this.getConfig(); 187 | const client = config.clients[clientId]; 188 | if (!client) { 189 | throw new ServerError(`Client Not Found: ${clientId}`, 404); 190 | } 191 | 192 | return client; 193 | } 194 | 195 | async getClientConfiguration({ clientId }) { 196 | const config = await this.getConfig(); 197 | const client = await this.getClient({ clientId }); 198 | 199 | return ` 200 | [Interface] 201 | PrivateKey = ${client.privateKey} 202 | Address = ${client.address}/24 203 | ${WG_DEFAULT_DNS ? `DNS = ${WG_DEFAULT_DNS}` : ''} 204 | ${WG_MTU ? `MTU = ${WG_MTU}` : ''} 205 | 206 | [Peer] 207 | PublicKey = ${config.server.publicKey} 208 | PresharedKey = ${client.preSharedKey} 209 | AllowedIPs = ${WG_ALLOWED_IPS} 210 | PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE} 211 | Endpoint = ${WG_HOST}:${WG_PORT}`; 212 | } 213 | 214 | async getClientQRCodeSVG({ clientId }) { 215 | const config = await this.getClientConfiguration({ clientId }); 216 | return QRCode.toString(config, { 217 | type: 'svg', 218 | width: 512, 219 | }); 220 | } 221 | 222 | async createClient({ name }) { 223 | if (!name) { 224 | throw new Error('Missing: Name'); 225 | } 226 | 227 | const config = await this.getConfig(); 228 | 229 | const privateKey = await Util.exec('wg genkey'); 230 | const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`); 231 | const preSharedKey = await Util.exec('wg genpsk'); 232 | 233 | // Calculate next IP 234 | let address; 235 | for (let i = 2; i < 255; i++) { 236 | const client = Object.values(config.clients).find(client => { 237 | return client.address === WG_DEFAULT_ADDRESS.replace('x', i); 238 | }); 239 | 240 | if (!client) { 241 | address = WG_DEFAULT_ADDRESS.replace('x', i); 242 | break; 243 | } 244 | } 245 | 246 | if (!address) { 247 | throw new Error('Maximum number of clients reached.'); 248 | } 249 | 250 | // Create Client 251 | const clientId = uuid.v4(); 252 | const client = { 253 | name, 254 | address, 255 | privateKey, 256 | publicKey, 257 | preSharedKey, 258 | 259 | createdAt: new Date(), 260 | updatedAt: new Date(), 261 | 262 | enabled: true, 263 | }; 264 | 265 | config.clients[clientId] = client; 266 | 267 | await this.saveConfig(); 268 | 269 | return client; 270 | } 271 | 272 | async deleteClient({ clientId }) { 273 | const config = await this.getConfig(); 274 | 275 | if (config.clients[clientId]) { 276 | delete config.clients[clientId]; 277 | await this.saveConfig(); 278 | } 279 | } 280 | 281 | async enableClient({ clientId }) { 282 | const client = await this.getClient({ clientId }); 283 | 284 | client.enabled = true; 285 | client.updatedAt = new Date(); 286 | 287 | await this.saveConfig(); 288 | } 289 | 290 | async disableClient({ clientId }) { 291 | const client = await this.getClient({ clientId }); 292 | 293 | client.enabled = false; 294 | client.updatedAt = new Date(); 295 | 296 | await this.saveConfig(); 297 | } 298 | 299 | async updateClientName({ clientId, name }) { 300 | const client = await this.getClient({ clientId }); 301 | 302 | client.name = name; 303 | client.updatedAt = new Date(); 304 | 305 | await this.saveConfig(); 306 | } 307 | 308 | async updateClientAddress({ clientId, address }) { 309 | const client = await this.getClient({ clientId }); 310 | 311 | if (!Util.isValidIPv4(address)) { 312 | throw new ServerError(`Invalid Address: ${address}`, 400); 313 | } 314 | 315 | client.address = address; 316 | client.updatedAt = new Date(); 317 | 318 | await this.saveConfig(); 319 | } 320 | 321 | }; 322 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "release": 8, 3 | "name": "wg-easy", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "server.js", 7 | "scripts": { 8 | "serve": "DEBUG=Server,WireGuard node --watch server.js", 9 | "serve-with-password": "PASSWORD=wg npm run serve", 10 | "lint": "eslint ." 11 | }, 12 | "author": "Emile Nijssen", 13 | "license": "GPL", 14 | "dependencies": { 15 | "debug": "^4.3.1", 16 | "express": "^4.17.1", 17 | "express-session": "^1.17.1", 18 | "qrcode": "^1.4.4", 19 | "uuid": "^8.3.2" 20 | }, 21 | "devDependencies": { 22 | "eslint": "^7.27.0", 23 | "eslint-config-athom": "^2.1.0" 24 | }, 25 | "engines": { 26 | "node": "18" 27 | } 28 | } -------------------------------------------------------------------------------- /src/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('./services/Server'); 4 | 5 | const WireGuard = require('./services/WireGuard'); 6 | 7 | WireGuard.getConfig() 8 | .catch(err => { 9 | // eslint-disable-next-line no-console 10 | console.error(err); 11 | 12 | // eslint-disable-next-line no-process-exit 13 | process.exit(1); 14 | }); 15 | -------------------------------------------------------------------------------- /src/services/Server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Server = require('../lib/Server'); 4 | 5 | module.exports = new Server(); 6 | -------------------------------------------------------------------------------- /src/services/WireGuard.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const WireGuard = require('../lib/WireGuard'); 4 | 5 | module.exports = new WireGuard(); 6 | -------------------------------------------------------------------------------- /src/www/img/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeeJeWel/wg-easy/83ac4ff4cf96b23ec4e1d8019413311834083d7a/src/www/img/apple-touch-icon.png -------------------------------------------------------------------------------- /src/www/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeeJeWel/wg-easy/83ac4ff4cf96b23ec4e1d8019413311834083d7a/src/www/img/favicon.png -------------------------------------------------------------------------------- /src/www/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WeeJeWel/wg-easy/83ac4ff4cf96b23ec4e1d8019413311834083d7a/src/www/img/logo.png -------------------------------------------------------------------------------- /src/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WireGuard 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 |
27 | 29 | Logout 30 | 32 | 34 | 35 | 36 |

37 | 38 | WireGuard 39 |

40 |

41 | 42 |
44 |
45 |
46 |

There is an update available!

47 |

{{latestRelease.changelog}}

48 |
49 | 50 | 52 | Update → 53 | 54 |
55 |
56 | 57 |
58 |
59 |
60 |

Clients

61 |
62 |
63 | 72 |
73 |
74 | 75 |
76 | 77 |
79 | 80 | 81 |
82 | 83 |
92 | 93 | 94 |
107 | 108 | 109 |
121 |
122 |
123 | 124 |
125 |
126 | 128 | 130 | 131 | 132 | 133 |
135 |
136 |
137 |
138 |
139 | 140 |
141 | 142 | 143 |
144 | 145 | 146 | 151 | {{client.name}} 153 | 154 | 155 | 158 | 161 | 163 | 164 | 165 |
166 | 167 | 168 |
169 | 170 | 171 | 172 | 173 | 174 | 179 | {{client.address}} 181 | 182 | 183 | 186 | 189 | 191 | 192 | 193 | 194 | 195 | 196 | 200 | · 201 | 203 | 206 | 207 | {{client.transferTxCurrent | bytes}}/s 208 | 209 | 210 | 211 | 215 | · 216 | 218 | 221 | 222 | {{client.transferRxCurrent | bytes}}/s 223 | 224 | 225 | 226 | 228 | · {{new Date(client.latestHandshakeAt) | timeago}} 229 | 230 |
231 |
232 | 233 |
234 |
235 | 236 | 237 |
239 |
240 |
241 |
243 |
244 |
245 | 246 | 247 | 255 | 256 | 257 | 260 | 262 | 264 | 265 | 266 | 267 | 268 | 276 |
277 |
278 | 279 |
280 | 281 |
282 |
283 |

There are no clients yet.

284 | 293 |

294 |
295 |
296 | 298 | 299 | 301 | 302 | 303 |
304 |
305 |
306 | 307 | 308 |
309 |
310 |
311 | 317 | 318 |
319 |
320 |
321 | 322 | 323 |
324 |
325 | 335 | 338 | 339 | 340 | 341 | 351 | 392 |
393 |
394 | 395 | 396 |
397 |
398 | 408 | 411 | 412 | 413 | 414 | 424 | 462 |
463 |
464 |
465 | 466 |
467 |

WireGuard

468 | 469 |
470 | 471 |
472 | 474 | 475 | 476 |
477 | 478 | 480 | 481 | 491 | 494 | 496 |
497 |
498 | 499 |
500 | 501 | 503 | 504 | 506 | 507 | 508 | 509 |
510 | 511 |
512 | 513 |

Made by Emile Nijssen · Donate · GitHub

517 | 518 | 519 |
520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | -------------------------------------------------------------------------------- /src/www/js/api.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-unused-vars */ 2 | /* eslint-disable no-undef */ 3 | 4 | 'use strict'; 5 | 6 | class API { 7 | 8 | async call({ method, path, body }) { 9 | const res = await fetch(`./api${path}`, { 10 | method, 11 | headers: { 12 | 'Content-Type': 'application/json', 13 | }, 14 | body: body 15 | ? JSON.stringify(body) 16 | : undefined, 17 | }); 18 | 19 | if (res.status === 204) { 20 | return undefined; 21 | } 22 | 23 | const json = await res.json(); 24 | 25 | if (!res.ok) { 26 | throw new Error(json.error || res.statusText); 27 | } 28 | 29 | return json; 30 | } 31 | 32 | async getRelease() { 33 | return this.call({ 34 | method: 'get', 35 | path: '/release', 36 | }); 37 | } 38 | 39 | async getSession() { 40 | return this.call({ 41 | method: 'get', 42 | path: '/session', 43 | }); 44 | } 45 | 46 | async createSession({ password }) { 47 | return this.call({ 48 | method: 'post', 49 | path: '/session', 50 | body: { password }, 51 | }); 52 | } 53 | 54 | async deleteSession() { 55 | return this.call({ 56 | method: 'delete', 57 | path: '/session', 58 | }); 59 | } 60 | 61 | async getClients() { 62 | return this.call({ 63 | method: 'get', 64 | path: '/wireguard/client', 65 | }).then(clients => clients.map(client => ({ 66 | ...client, 67 | createdAt: new Date(client.createdAt), 68 | updatedAt: new Date(client.updatedAt), 69 | latestHandshakeAt: client.latestHandshakeAt !== null 70 | ? new Date(client.latestHandshakeAt) 71 | : null, 72 | }))); 73 | } 74 | 75 | async createClient({ name }) { 76 | return this.call({ 77 | method: 'post', 78 | path: '/wireguard/client', 79 | body: { name }, 80 | }); 81 | } 82 | 83 | async deleteClient({ clientId }) { 84 | return this.call({ 85 | method: 'delete', 86 | path: `/wireguard/client/${clientId}`, 87 | }); 88 | } 89 | 90 | async enableClient({ clientId }) { 91 | return this.call({ 92 | method: 'post', 93 | path: `/wireguard/client/${clientId}/enable`, 94 | }); 95 | } 96 | 97 | async disableClient({ clientId }) { 98 | return this.call({ 99 | method: 'post', 100 | path: `/wireguard/client/${clientId}/disable`, 101 | }); 102 | } 103 | 104 | async updateClientName({ clientId, name }) { 105 | return this.call({ 106 | method: 'put', 107 | path: `/wireguard/client/${clientId}/name/`, 108 | body: { name }, 109 | }); 110 | } 111 | 112 | async updateClientAddress({ clientId, address }) { 113 | return this.call({ 114 | method: 'put', 115 | path: `/wireguard/client/${clientId}/address/`, 116 | body: { address }, 117 | }); 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/www/js/app.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | /* eslint-disable no-alert */ 3 | /* eslint-disable no-undef */ 4 | /* eslint-disable no-new */ 5 | 6 | 'use strict'; 7 | 8 | function bytes(bytes, decimals, kib, maxunit) { 9 | kib = kib || false; 10 | if (bytes === 0) return '0 B'; 11 | if (Number.isNaN(parseFloat(bytes)) && !Number.isFinite(bytes)) return 'NaN'; 12 | const k = kib ? 1024 : 1000; 13 | const dm = decimals != null && !Number.isNaN(decimals) && decimals >= 0 ? decimals : 2; 14 | const sizes = kib 15 | ? ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB', 'BiB'] 16 | : ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB']; 17 | let i = Math.floor(Math.log(bytes) / Math.log(k)); 18 | if (maxunit !== undefined) { 19 | const index = sizes.indexOf(maxunit); 20 | if (index !== -1) i = index; 21 | } 22 | // eslint-disable-next-line no-restricted-properties 23 | return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; 24 | } 25 | 26 | new Vue({ 27 | el: '#app', 28 | data: { 29 | authenticated: null, 30 | authenticating: false, 31 | password: null, 32 | requiresPassword: null, 33 | 34 | clients: null, 35 | clientsPersist: {}, 36 | clientDelete: null, 37 | clientCreate: null, 38 | clientCreateName: '', 39 | clientEditName: null, 40 | clientEditNameId: null, 41 | clientEditAddress: null, 42 | clientEditAddressId: null, 43 | qrcode: null, 44 | 45 | currentRelease: null, 46 | latestRelease: null, 47 | 48 | chartOptions: { 49 | chart: { 50 | background: 'transparent', 51 | type: 'bar', 52 | stacked: false, 53 | toolbar: { 54 | show: false, 55 | }, 56 | animations: { 57 | enabled: false, 58 | }, 59 | }, 60 | colors: [ 61 | '#DDDDDD', // rx 62 | '#EEEEEE', // tx 63 | ], 64 | dataLabels: { 65 | enabled: false, 66 | }, 67 | plotOptions: { 68 | bar: { 69 | horizontal: false, 70 | }, 71 | }, 72 | xaxis: { 73 | labels: { 74 | show: false, 75 | }, 76 | axisTicks: { 77 | show: true, 78 | }, 79 | axisBorder: { 80 | show: true, 81 | }, 82 | }, 83 | yaxis: { 84 | labels: { 85 | show: false, 86 | }, 87 | min: 0, 88 | }, 89 | tooltip: { 90 | enabled: false, 91 | }, 92 | legend: { 93 | show: false, 94 | }, 95 | grid: { 96 | show: false, 97 | padding: { 98 | left: -10, 99 | right: 0, 100 | bottom: -15, 101 | top: -15, 102 | }, 103 | column: { 104 | opacity: 0, 105 | }, 106 | xaxis: { 107 | lines: { 108 | show: false, 109 | }, 110 | }, 111 | }, 112 | }, 113 | }, 114 | methods: { 115 | dateTime: value => { 116 | return new Intl.DateTimeFormat(undefined, { 117 | year: 'numeric', 118 | month: 'short', 119 | day: 'numeric', 120 | hour: 'numeric', 121 | minute: 'numeric', 122 | }).format(value); 123 | }, 124 | async refresh({ 125 | updateCharts = false, 126 | } = {}) { 127 | if (!this.authenticated) return; 128 | 129 | const clients = await this.api.getClients(); 130 | this.clients = clients.map(client => { 131 | if (client.name.includes('@') && client.name.includes('.')) { 132 | client.avatar = `https://www.gravatar.com/avatar/${md5(client.name)}?d=blank`; 133 | } 134 | 135 | if (!this.clientsPersist[client.id]) { 136 | this.clientsPersist[client.id] = {}; 137 | this.clientsPersist[client.id].transferRxHistory = Array(50).fill(0); 138 | this.clientsPersist[client.id].transferRxPrevious = client.transferRx; 139 | this.clientsPersist[client.id].transferTxHistory = Array(50).fill(0); 140 | this.clientsPersist[client.id].transferTxPrevious = client.transferTx; 141 | } 142 | 143 | // Debug 144 | // client.transferRx = this.clientsPersist[client.id].transferRxPrevious + Math.random() * 1000; 145 | // client.transferTx = this.clientsPersist[client.id].transferTxPrevious + Math.random() * 1000; 146 | 147 | if (updateCharts) { 148 | this.clientsPersist[client.id].transferRxCurrent = client.transferRx - this.clientsPersist[client.id].transferRxPrevious; 149 | this.clientsPersist[client.id].transferRxPrevious = client.transferRx; 150 | this.clientsPersist[client.id].transferTxCurrent = client.transferTx - this.clientsPersist[client.id].transferTxPrevious; 151 | this.clientsPersist[client.id].transferTxPrevious = client.transferTx; 152 | 153 | this.clientsPersist[client.id].transferRxHistory.push(this.clientsPersist[client.id].transferRxCurrent); 154 | this.clientsPersist[client.id].transferRxHistory.shift(); 155 | 156 | this.clientsPersist[client.id].transferTxHistory.push(this.clientsPersist[client.id].transferTxCurrent); 157 | this.clientsPersist[client.id].transferTxHistory.shift(); 158 | } 159 | 160 | client.transferTxCurrent = this.clientsPersist[client.id].transferTxCurrent; 161 | client.transferRxCurrent = this.clientsPersist[client.id].transferRxCurrent; 162 | 163 | client.transferTxHistory = this.clientsPersist[client.id].transferTxHistory; 164 | client.transferRxHistory = this.clientsPersist[client.id].transferRxHistory; 165 | client.transferMax = Math.max(...client.transferTxHistory, ...client.transferRxHistory); 166 | 167 | client.hoverTx = this.clientsPersist[client.id].hoverTx; 168 | client.hoverRx = this.clientsPersist[client.id].hoverRx; 169 | 170 | return client; 171 | }); 172 | }, 173 | login(e) { 174 | e.preventDefault(); 175 | 176 | if (!this.password) return; 177 | if (this.authenticating) return; 178 | 179 | this.authenticating = true; 180 | this.api.createSession({ 181 | password: this.password, 182 | }) 183 | .then(async () => { 184 | const session = await this.api.getSession(); 185 | this.authenticated = session.authenticated; 186 | this.requiresPassword = session.requiresPassword; 187 | return this.refresh(); 188 | }) 189 | .catch(err => { 190 | alert(err.message || err.toString()); 191 | }) 192 | .finally(() => { 193 | this.authenticating = false; 194 | this.password = null; 195 | }); 196 | }, 197 | logout(e) { 198 | e.preventDefault(); 199 | 200 | this.api.deleteSession() 201 | .then(() => { 202 | this.authenticated = false; 203 | this.clients = null; 204 | }) 205 | .catch(err => { 206 | alert(err.message || err.toString()); 207 | }); 208 | }, 209 | createClient() { 210 | const name = this.clientCreateName; 211 | if (!name) return; 212 | 213 | this.api.createClient({ name }) 214 | .catch(err => alert(err.message || err.toString())) 215 | .finally(() => this.refresh().catch(console.error)); 216 | }, 217 | deleteClient(client) { 218 | this.api.deleteClient({ clientId: client.id }) 219 | .catch(err => alert(err.message || err.toString())) 220 | .finally(() => this.refresh().catch(console.error)); 221 | }, 222 | enableClient(client) { 223 | this.api.enableClient({ clientId: client.id }) 224 | .catch(err => alert(err.message || err.toString())) 225 | .finally(() => this.refresh().catch(console.error)); 226 | }, 227 | disableClient(client) { 228 | this.api.disableClient({ clientId: client.id }) 229 | .catch(err => alert(err.message || err.toString())) 230 | .finally(() => this.refresh().catch(console.error)); 231 | }, 232 | updateClientName(client, name) { 233 | this.api.updateClientName({ clientId: client.id, name }) 234 | .catch(err => alert(err.message || err.toString())) 235 | .finally(() => this.refresh().catch(console.error)); 236 | }, 237 | updateClientAddress(client, address) { 238 | this.api.updateClientAddress({ clientId: client.id, address }) 239 | .catch(err => alert(err.message || err.toString())) 240 | .finally(() => this.refresh().catch(console.error)); 241 | }, 242 | }, 243 | filters: { 244 | bytes, 245 | timeago: value => { 246 | return timeago().format(value); 247 | }, 248 | }, 249 | mounted() { 250 | this.api = new API(); 251 | this.api.getSession() 252 | .then(session => { 253 | this.authenticated = session.authenticated; 254 | this.requiresPassword = session.requiresPassword; 255 | this.refresh({ 256 | updateCharts: true, 257 | }).catch(err => { 258 | alert(err.message || err.toString()); 259 | }); 260 | }) 261 | .catch(err => { 262 | alert(err.message || err.toString()); 263 | }); 264 | 265 | setInterval(() => { 266 | this.refresh({ 267 | updateCharts: true, 268 | }).catch(console.error); 269 | }, 1000); 270 | 271 | Promise.resolve().then(async () => { 272 | const currentRelease = await this.api.getRelease(); 273 | const latestRelease = await fetch('https://wg-easy.github.io/wg-easy/changelog.json') 274 | .then(res => res.json()) 275 | .then(releases => { 276 | const releasesArray = Object.entries(releases).map(([version, changelog]) => ({ 277 | version: parseInt(version, 10), 278 | changelog, 279 | })); 280 | releasesArray.sort((a, b) => { 281 | return b.version - a.version; 282 | }); 283 | 284 | return releasesArray[0]; 285 | }); 286 | 287 | console.log(`Current Release: ${currentRelease}`); 288 | console.log(`Latest Release: ${latestRelease.version}`); 289 | 290 | if (currentRelease >= latestRelease.version) return; 291 | 292 | this.currentRelease = currentRelease; 293 | this.latestRelease = latestRelease; 294 | }).catch(console.error); 295 | }, 296 | }); 297 | -------------------------------------------------------------------------------- /src/www/js/vendor/md5.min.js: -------------------------------------------------------------------------------- 1 | !function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((c=d(d(t,n),d(e,u)))<<(f=o)|c>>>32-f,r);var c,f}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function h(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return a(i(h(t=r(n)),8*t.length));var t}function u(n,t){return function(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,16=l[i]&&i(0===i?9:1)&&(i+=1),d[n](t,i)[agoin].replace("%s",t)}function r(e,n){return n=n?t(n):new Date,(n-t(e))/1e3}function i(t){for(var e=1,n=0,r=Math.abs(t);t>=l[n]&&n1&&(n+="s"),[t+" "+n+" ago","in "+t+" "+n]},zh_CN:function(t,e){if(0===e)return["刚刚","片刻后"];var n=s[parseInt(e/2)];return[t+n+"前",t+n+"后"]}},l=[60,60,24,7,365/7/12,12],p=6,h="datetime";return u.register=function(t,e){d[t]=e},u}); -------------------------------------------------------------------------------- /src/www/js/vendor/vue.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Vue.js v2.6.12 3 | * (c) 2014-2020 Evan You 4 | * Released under the MIT License. 5 | */ 6 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vue=t()}(this,function(){"use strict";var e=Object.freeze({});function t(e){return null==e}function n(e){return null!=e}function r(e){return!0===e}function i(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function o(e){return null!==e&&"object"==typeof e}var a=Object.prototype.toString;function s(e){return"[object Object]"===a.call(e)}function c(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function u(e){return n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function l(e){return null==e?"":Array.isArray(e)||s(e)&&e.toString===a?JSON.stringify(e,null,2):String(e)}function f(e){var t=parseFloat(e);return isNaN(t)?e:t}function p(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}var m=Object.prototype.hasOwnProperty;function y(e,t){return m.call(e,t)}function g(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var _=/-(\w)/g,b=g(function(e){return e.replace(_,function(e,t){return t?t.toUpperCase():""})}),$=g(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),w=/\B([A-Z])/g,C=g(function(e){return e.replace(w,"-$1").toLowerCase()});var x=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function k(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function A(e,t){for(var n in t)e[n]=t[n];return e}function O(e){for(var t={},n=0;n0,Z=J&&J.indexOf("edge/")>0,G=(J&&J.indexOf("android"),J&&/iphone|ipad|ipod|ios/.test(J)||"ios"===K),X=(J&&/chrome\/\d+/.test(J),J&&/phantomjs/.test(J),J&&J.match(/firefox\/(\d+)/)),Y={}.watch,Q=!1;if(z)try{var ee={};Object.defineProperty(ee,"passive",{get:function(){Q=!0}}),window.addEventListener("test-passive",null,ee)}catch(e){}var te=function(){return void 0===B&&(B=!z&&!V&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),B},ne=z&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function re(e){return"function"==typeof e&&/native code/.test(e.toString())}var ie,oe="undefined"!=typeof Symbol&&re(Symbol)&&"undefined"!=typeof Reflect&&re(Reflect.ownKeys);ie="undefined"!=typeof Set&&re(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ae=S,se=0,ce=function(){this.id=se++,this.subs=[]};ce.prototype.addSub=function(e){this.subs.push(e)},ce.prototype.removeSub=function(e){h(this.subs,e)},ce.prototype.depend=function(){ce.target&&ce.target.addDep(this)},ce.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t-1)if(o&&!y(i,"default"))a=!1;else if(""===a||a===C(e)){var c=Pe(String,i.type);(c<0||s0&&(st((u=e(u,(a||"")+"_"+c))[0])&&st(f)&&(s[l]=he(f.text+u[0].text),u.shift()),s.push.apply(s,u)):i(u)?st(f)?s[l]=he(f.text+u):""!==u&&s.push(he(u)):st(u)&&st(f)?s[l]=he(f.text+u.text):(r(o._isVList)&&n(u.tag)&&t(u.key)&&n(a)&&(u.key="__vlist"+a+"_"+c+"__"),s.push(u)));return s}(e):void 0}function st(e){return n(e)&&n(e.text)&&!1===e.isComment}function ct(e,t){if(e){for(var n=Object.create(null),r=oe?Reflect.ownKeys(e):Object.keys(e),i=0;i0,a=t?!!t.$stable:!o,s=t&&t.$key;if(t){if(t._normalized)return t._normalized;if(a&&r&&r!==e&&s===r.$key&&!o&&!r.$hasNormal)return r;for(var c in i={},t)t[c]&&"$"!==c[0]&&(i[c]=pt(n,c,t[c]))}else i={};for(var u in n)u in i||(i[u]=dt(n,u));return t&&Object.isExtensible(t)&&(t._normalized=i),R(i,"$stable",a),R(i,"$key",s),R(i,"$hasNormal",o),i}function pt(e,t,n){var r=function(){var e=arguments.length?n.apply(null,arguments):n({});return(e=e&&"object"==typeof e&&!Array.isArray(e)?[e]:at(e))&&(0===e.length||1===e.length&&e[0].isComment)?void 0:e};return n.proxy&&Object.defineProperty(e,t,{get:r,enumerable:!0,configurable:!0}),r}function dt(e,t){return function(){return e[t]}}function vt(e,t){var r,i,a,s,c;if(Array.isArray(e)||"string"==typeof e)for(r=new Array(e.length),i=0,a=e.length;idocument.createEvent("Event").timeStamp&&(sn=function(){return cn.now()})}function un(){var e,t;for(an=sn(),rn=!0,Qt.sort(function(e,t){return e.id-t.id}),on=0;onon&&Qt[n].id>e.id;)n--;Qt.splice(n+1,0,e)}else Qt.push(e);nn||(nn=!0,Ye(un))}}(this)},fn.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||o(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Re(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},fn.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},fn.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},fn.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||h(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var pn={enumerable:!0,configurable:!0,get:S,set:S};function dn(e,t,n){pn.get=function(){return this[t][n]},pn.set=function(e){this[t][n]=e},Object.defineProperty(e,n,pn)}function vn(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[];e.$parent&&$e(!1);var o=function(o){i.push(o);var a=Me(o,t,n,e);xe(r,o,a),o in e||dn(e,"_props",o)};for(var a in t)o(a);$e(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?S:x(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;s(t=e._data="function"==typeof t?function(e,t){le();try{return e.call(t,t)}catch(e){return Re(e,t,"data()"),{}}finally{fe()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,i=(e.$options.methods,n.length);for(;i--;){var o=n[i];r&&y(r,o)||(a=void 0,36!==(a=(o+"").charCodeAt(0))&&95!==a&&dn(e,"_data",o))}var a;Ce(t,!0)}(e):Ce(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=te();for(var i in t){var o=t[i],a="function"==typeof o?o:o.get;r||(n[i]=new fn(e,a||S,S,hn)),i in e||mn(e,i,o)}}(e,t.computed),t.watch&&t.watch!==Y&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i-1:"string"==typeof e?e.split(",").indexOf(t)>-1:(n=e,"[object RegExp]"===a.call(n)&&e.test(t));var n}function An(e,t){var n=e.cache,r=e.keys,i=e._vnode;for(var o in n){var a=n[o];if(a){var s=xn(a.componentOptions);s&&!t(s)&&On(n,o,r,i)}}}function On(e,t,n,r){var i=e[t];!i||r&&i.tag===r.tag||i.componentInstance.$destroy(),e[t]=null,h(n,t)}!function(t){t.prototype._init=function(t){var n=this;n._uid=bn++,n._isVue=!0,t&&t._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var i=r.componentOptions;n.propsData=i.propsData,n._parentListeners=i.listeners,n._renderChildren=i.children,n._componentTag=i.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(n,t):n.$options=De($n(n.constructor),t||{},n),n._renderProxy=n,n._self=n,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(n),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&qt(e,t)}(n),function(t){t._vnode=null,t._staticTrees=null;var n=t.$options,r=t.$vnode=n._parentVnode,i=r&&r.context;t.$slots=ut(n._renderChildren,i),t.$scopedSlots=e,t._c=function(e,n,r,i){return Pt(t,e,n,r,i,!1)},t.$createElement=function(e,n,r,i){return Pt(t,e,n,r,i,!0)};var o=r&&r.data;xe(t,"$attrs",o&&o.attrs||e,null,!0),xe(t,"$listeners",n._parentListeners||e,null,!0)}(n),Yt(n,"beforeCreate"),function(e){var t=ct(e.$options.inject,e);t&&($e(!1),Object.keys(t).forEach(function(n){xe(e,n,t[n])}),$e(!0))}(n),vn(n),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(n),Yt(n,"created"),n.$options.el&&n.$mount(n.$options.el)}}(wn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=ke,e.prototype.$delete=Ae,e.prototype.$watch=function(e,t,n){if(s(t))return _n(this,e,t,n);(n=n||{}).user=!0;var r=new fn(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Re(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(wn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var i=0,o=e.length;i1?k(t):t;for(var n=k(arguments,1),r='event handler for "'+e+'"',i=0,o=t.length;iparseInt(this.max)&&On(a,s[0],s,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return F}};Object.defineProperty(e,"config",t),e.util={warn:ae,extend:A,mergeOptions:De,defineReactive:xe},e.set=ke,e.delete=Ae,e.nextTick=Ye,e.observable=function(e){return Ce(e),e},e.options=Object.create(null),M.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,A(e.options.components,Tn),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=k(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=De(this.options,e),this}}(e),Cn(e),function(e){M.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&s(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}(e)}(wn),Object.defineProperty(wn.prototype,"$isServer",{get:te}),Object.defineProperty(wn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(wn,"FunctionalRenderContext",{value:Tt}),wn.version="2.6.12";var En=p("style,class"),Nn=p("input,textarea,option,select,progress"),jn=function(e,t,n){return"value"===n&&Nn(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Dn=p("contenteditable,draggable,spellcheck"),Ln=p("events,caret,typing,plaintext-only"),Mn=function(e,t){return Hn(t)||"false"===t?"false":"contenteditable"===e&&Ln(t)?t:"true"},In=p("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Fn="http://www.w3.org/1999/xlink",Pn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Rn=function(e){return Pn(e)?e.slice(6,e.length):""},Hn=function(e){return null==e||!1===e};function Bn(e){for(var t=e.data,r=e,i=e;n(i.componentInstance);)(i=i.componentInstance._vnode)&&i.data&&(t=Un(i.data,t));for(;n(r=r.parent);)r&&r.data&&(t=Un(t,r.data));return function(e,t){if(n(e)||n(t))return zn(e,Vn(t));return""}(t.staticClass,t.class)}function Un(e,t){return{staticClass:zn(e.staticClass,t.staticClass),class:n(e.class)?[e.class,t.class]:t.class}}function zn(e,t){return e?t?e+" "+t:e:t||""}function Vn(e){return Array.isArray(e)?function(e){for(var t,r="",i=0,o=e.length;i-1?hr(e,t,n):In(t)?Hn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Dn(t)?e.setAttribute(t,Mn(t,n)):Pn(t)?Hn(n)?e.removeAttributeNS(Fn,Rn(t)):e.setAttributeNS(Fn,t,n):hr(e,t,n)}function hr(e,t,n){if(Hn(n))e.removeAttribute(t);else{if(q&&!W&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}var mr={create:dr,update:dr};function yr(e,r){var i=r.elm,o=r.data,a=e.data;if(!(t(o.staticClass)&&t(o.class)&&(t(a)||t(a.staticClass)&&t(a.class)))){var s=Bn(r),c=i._transitionClasses;n(c)&&(s=zn(s,Vn(c))),s!==i._prevClass&&(i.setAttribute("class",s),i._prevClass=s)}}var gr,_r,br,$r,wr,Cr,xr={create:yr,update:yr},kr=/[\w).+\-_$\]]/;function Ar(e){var t,n,r,i,o,a=!1,s=!1,c=!1,u=!1,l=0,f=0,p=0,d=0;for(r=0;r=0&&" "===(h=e.charAt(v));v--);h&&kr.test(h)||(u=!0)}}else void 0===i?(d=r+1,i=e.slice(0,r).trim()):m();function m(){(o||(o=[])).push(e.slice(d,r).trim()),d=r+1}if(void 0===i?i=e.slice(0,r).trim():0!==d&&m(),o)for(r=0;r-1?{exp:e.slice(0,$r),key:'"'+e.slice($r+1)+'"'}:{exp:e,key:null};_r=e,$r=wr=Cr=0;for(;!zr();)Vr(br=Ur())?Jr(br):91===br&&Kr(br);return{exp:e.slice(0,wr),key:e.slice(wr+1,Cr)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Ur(){return _r.charCodeAt(++$r)}function zr(){return $r>=gr}function Vr(e){return 34===e||39===e}function Kr(e){var t=1;for(wr=$r;!zr();)if(Vr(e=Ur()))Jr(e);else if(91===e&&t++,93===e&&t--,0===t){Cr=$r;break}}function Jr(e){for(var t=e;!zr()&&(e=Ur())!==t;);}var qr,Wr="__r",Zr="__c";function Gr(e,t,n){var r=qr;return function i(){null!==t.apply(null,arguments)&&Qr(e,i,n,r)}}var Xr=Ve&&!(X&&Number(X[1])<=53);function Yr(e,t,n,r){if(Xr){var i=an,o=t;t=o._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=i||e.timeStamp<=0||e.target.ownerDocument!==document)return o.apply(this,arguments)}}qr.addEventListener(e,t,Q?{capture:n,passive:r}:n)}function Qr(e,t,n,r){(r||qr).removeEventListener(e,t._wrapper||t,n)}function ei(e,r){if(!t(e.data.on)||!t(r.data.on)){var i=r.data.on||{},o=e.data.on||{};qr=r.elm,function(e){if(n(e[Wr])){var t=q?"change":"input";e[t]=[].concat(e[Wr],e[t]||[]),delete e[Wr]}n(e[Zr])&&(e.change=[].concat(e[Zr],e.change||[]),delete e[Zr])}(i),rt(i,o,Yr,Qr,Gr,r.context),qr=void 0}}var ti,ni={create:ei,update:ei};function ri(e,r){if(!t(e.data.domProps)||!t(r.data.domProps)){var i,o,a=r.elm,s=e.data.domProps||{},c=r.data.domProps||{};for(i in n(c.__ob__)&&(c=r.data.domProps=A({},c)),s)i in c||(a[i]="");for(i in c){if(o=c[i],"textContent"===i||"innerHTML"===i){if(r.children&&(r.children.length=0),o===s[i])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===i&&"PROGRESS"!==a.tagName){a._value=o;var u=t(o)?"":String(o);ii(a,u)&&(a.value=u)}else if("innerHTML"===i&&qn(a.tagName)&&t(a.innerHTML)){(ti=ti||document.createElement("div")).innerHTML=""+o+"";for(var l=ti.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}else if(o!==s[i])try{a[i]=o}catch(e){}}}}function ii(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var r=e.value,i=e._vModifiers;if(n(i)){if(i.number)return f(r)!==f(t);if(i.trim)return r.trim()!==t.trim()}return r!==t}(e,t))}var oi={create:ri,update:ri},ai=g(function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach(function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t});function si(e){var t=ci(e.style);return e.staticStyle?A(e.staticStyle,t):t}function ci(e){return Array.isArray(e)?O(e):"string"==typeof e?ai(e):e}var ui,li=/^--/,fi=/\s*!important$/,pi=function(e,t,n){if(li.test(t))e.style.setProperty(t,n);else if(fi.test(n))e.style.setProperty(C(t),n.replace(fi,""),"important");else{var r=vi(t);if(Array.isArray(n))for(var i=0,o=n.length;i-1?t.split(yi).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function _i(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(yi).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function bi(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&A(t,$i(e.name||"v")),A(t,e),t}return"string"==typeof e?$i(e):void 0}}var $i=g(function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}}),wi=z&&!W,Ci="transition",xi="animation",ki="transition",Ai="transitionend",Oi="animation",Si="animationend";wi&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(ki="WebkitTransition",Ai="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Oi="WebkitAnimation",Si="webkitAnimationEnd"));var Ti=z?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ei(e){Ti(function(){Ti(e)})}function Ni(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),gi(e,t))}function ji(e,t){e._transitionClasses&&h(e._transitionClasses,t),_i(e,t)}function Di(e,t,n){var r=Mi(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===Ci?Ai:Si,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c0&&(n=Ci,l=a,f=o.length):t===xi?u>0&&(n=xi,l=u,f=c.length):f=(n=(l=Math.max(a,u))>0?a>u?Ci:xi:null)?n===Ci?o.length:c.length:0,{type:n,timeout:l,propCount:f,hasTransform:n===Ci&&Li.test(r[ki+"Property"])}}function Ii(e,t){for(;e.length1}function Ui(e,t){!0!==t.data.show&&Pi(t)}var zi=function(e){var o,a,s={},c=e.modules,u=e.nodeOps;for(o=0;ov?_(e,t(i[y+1])?null:i[y+1].elm,i,d,y,o):d>y&&$(r,p,v)}(p,h,y,o,l):n(y)?(n(e.text)&&u.setTextContent(p,""),_(p,null,y,0,y.length-1,o)):n(h)?$(h,0,h.length-1):n(e.text)&&u.setTextContent(p,""):e.text!==i.text&&u.setTextContent(p,i.text),n(v)&&n(d=v.hook)&&n(d=d.postpatch)&&d(e,i)}}}function k(e,t,i){if(r(i)&&n(e.parent))e.parent.data.pendingInsert=t;else for(var o=0;o-1,a.selected!==o&&(a.selected=o);else if(N(Wi(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function qi(e,t){return t.every(function(t){return!N(t,e)})}function Wi(e){return"_value"in e?e._value:e.value}function Zi(e){e.target.composing=!0}function Gi(e){e.target.composing&&(e.target.composing=!1,Xi(e.target,"input"))}function Xi(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Yi(e){return!e.componentInstance||e.data&&e.data.transition?e:Yi(e.componentInstance._vnode)}var Qi={model:Vi,show:{bind:function(e,t,n){var r=t.value,i=(n=Yi(n)).data&&n.data.transition,o=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&i?(n.data.show=!0,Pi(n,function(){e.style.display=o})):e.style.display=r?o:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Yi(n)).data&&n.data.transition?(n.data.show=!0,r?Pi(n,function(){e.style.display=e.__vOriginalDisplay}):Ri(n,function(){e.style.display="none"})):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,i){i||(e.style.display=e.__vOriginalDisplay)}}},eo={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function to(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?to(zt(t.children)):e}function no(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var i=n._parentListeners;for(var o in i)t[b(o)]=i[o];return t}function ro(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var io=function(e){return e.tag||Ut(e)},oo=function(e){return"show"===e.name},ao={name:"transition",props:eo,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(io)).length){var r=this.mode,o=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return o;var a=to(o);if(!a)return o;if(this._leaving)return ro(e,o);var s="__transition-"+this._uid+"-";a.key=null==a.key?a.isComment?s+"comment":s+a.tag:i(a.key)?0===String(a.key).indexOf(s)?a.key:s+a.key:a.key;var c=(a.data||(a.data={})).transition=no(this),u=this._vnode,l=to(u);if(a.data.directives&&a.data.directives.some(oo)&&(a.data.show=!0),l&&l.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(a,l)&&!Ut(l)&&(!l.componentInstance||!l.componentInstance._vnode.isComment)){var f=l.data.transition=A({},c);if("out-in"===r)return this._leaving=!0,it(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),ro(e,o);if("in-out"===r){if(Ut(a))return u;var p,d=function(){p()};it(c,"afterEnter",d),it(c,"enterCancelled",d),it(f,"delayLeave",function(e){p=e})}}return o}}},so=A({tag:String,moveClass:String},eo);function co(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function uo(e){e.data.newPos=e.elm.getBoundingClientRect()}function lo(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,i=t.top-n.top;if(r||i){e.data.moved=!0;var o=e.elm.style;o.transform=o.WebkitTransform="translate("+r+"px,"+i+"px)",o.transitionDuration="0s"}}delete so.mode;var fo={Transition:ao,TransitionGroup:{props:so,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var i=Zt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,i(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,i=this.$slots.default||[],o=this.children=[],a=no(this),s=0;s-1?Gn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Gn[e]=/HTMLUnknownElement/.test(t.toString())},A(wn.options.directives,Qi),A(wn.options.components,fo),wn.prototype.__patch__=z?zi:S,wn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=ve),Yt(e,"beforeMount"),r=function(){e._update(e._render(),n)},new fn(e,r,S,{before:function(){e._isMounted&&!e._isDestroyed&&Yt(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,Yt(e,"mounted")),e}(this,e=e&&z?Yn(e):void 0,t)},z&&setTimeout(function(){F.devtools&&ne&&ne.emit("init",wn)},0);var po=/\{\{((?:.|\r?\n)+?)\}\}/g,vo=/[-.*+?^${}()|[\]\/\\]/g,ho=g(function(e){var t=e[0].replace(vo,"\\$&"),n=e[1].replace(vo,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")});var mo={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=Fr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=Ir(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var yo,go={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=Fr(e,"style");n&&(e.staticStyle=JSON.stringify(ai(n)));var r=Ir(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},_o=function(e){return(yo=yo||document.createElement("div")).innerHTML=e,yo.textContent},bo=p("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),$o=p("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),wo=p("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),Co=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,xo=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,ko="[a-zA-Z_][\\-\\.0-9_a-zA-Z"+P.source+"]*",Ao="((?:"+ko+"\\:)?"+ko+")",Oo=new RegExp("^<"+Ao),So=/^\s*(\/?)>/,To=new RegExp("^<\\/"+Ao+"[^>]*>"),Eo=/^]+>/i,No=/^",""":'"',"&":"&"," ":"\n"," ":"\t","'":"'"},Io=/&(?:lt|gt|quot|amp|#39);/g,Fo=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Po=p("pre,textarea",!0),Ro=function(e,t){return e&&Po(e)&&"\n"===t[0]};function Ho(e,t){var n=t?Fo:Io;return e.replace(n,function(e){return Mo[e]})}var Bo,Uo,zo,Vo,Ko,Jo,qo,Wo,Zo=/^@|^v-on:/,Go=/^v-|^@|^:|^#/,Xo=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Yo=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Qo=/^\(|\)$/g,ea=/^\[.*\]$/,ta=/:(.*)$/,na=/^:|^\.|^v-bind:/,ra=/\.[^.\]]+(?=[^\]]*$)/g,ia=/^v-slot(:|$)|^#/,oa=/[\r\n]/,aa=/\s+/g,sa=g(_o),ca="_empty_";function ua(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ma(t),rawAttrsMap:{},parent:n,children:[]}}function la(e,t){Bo=t.warn||Sr,Jo=t.isPreTag||T,qo=t.mustUseProp||T,Wo=t.getTagNamespace||T;t.isReservedTag;zo=Tr(t.modules,"transformNode"),Vo=Tr(t.modules,"preTransformNode"),Ko=Tr(t.modules,"postTransformNode"),Uo=t.delimiters;var n,r,i=[],o=!1!==t.preserveWhitespace,a=t.whitespace,s=!1,c=!1;function u(e){if(l(e),s||e.processed||(e=fa(e,t)),i.length||e===n||n.if&&(e.elseif||e.else)&&da(n,{exp:e.elseif,block:e}),r&&!e.forbidden)if(e.elseif||e.else)a=e,(u=function(e){var t=e.length;for(;t--;){if(1===e[t].type)return e[t];e.pop()}}(r.children))&&u.if&&da(u,{exp:a.elseif,block:a});else{if(e.slotScope){var o=e.slotTarget||'"default"';(r.scopedSlots||(r.scopedSlots={}))[o]=e}r.children.push(e),e.parent=r}var a,u;e.children=e.children.filter(function(e){return!e.slotScope}),l(e),e.pre&&(s=!1),Jo(e.tag)&&(c=!1);for(var f=0;f]*>)","i")),p=e.replace(f,function(e,n,r){return u=r.length,Do(l)||"noscript"===l||(n=n.replace(//g,"$1").replace(//g,"$1")),Ro(l,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});c+=e.length-p.length,e=p,A(l,c-u,c)}else{var d=e.indexOf("<");if(0===d){if(No.test(e)){var v=e.indexOf("--\x3e");if(v>=0){t.shouldKeepComment&&t.comment(e.substring(4,v),c,c+v+3),C(v+3);continue}}if(jo.test(e)){var h=e.indexOf("]>");if(h>=0){C(h+2);continue}}var m=e.match(Eo);if(m){C(m[0].length);continue}var y=e.match(To);if(y){var g=c;C(y[0].length),A(y[1],g,c);continue}var _=x();if(_){k(_),Ro(_.tagName,e)&&C(1);continue}}var b=void 0,$=void 0,w=void 0;if(d>=0){for($=e.slice(d);!(To.test($)||Oo.test($)||No.test($)||jo.test($)||(w=$.indexOf("<",1))<0);)d+=w,$=e.slice(d);b=e.substring(0,d)}d<0&&(b=e),b&&C(b.length),t.chars&&b&&t.chars(b,c-b.length,c)}if(e===n){t.chars&&t.chars(e);break}}function C(t){c+=t,e=e.substring(t)}function x(){var t=e.match(Oo);if(t){var n,r,i={tagName:t[1],attrs:[],start:c};for(C(t[0].length);!(n=e.match(So))&&(r=e.match(xo)||e.match(Co));)r.start=c,C(r[0].length),r.end=c,i.attrs.push(r);if(n)return i.unarySlash=n[1],C(n[0].length),i.end=c,i}}function k(e){var n=e.tagName,c=e.unarySlash;o&&("p"===r&&wo(n)&&A(r),s(n)&&r===n&&A(n));for(var u=a(n)||!!c,l=e.attrs.length,f=new Array(l),p=0;p=0&&i[a].lowerCasedTag!==s;a--);else a=0;if(a>=0){for(var u=i.length-1;u>=a;u--)t.end&&t.end(i[u].tag,n,o);i.length=a,r=a&&i[a-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,o):"p"===s&&(t.start&&t.start(e,[],!1,n,o),t.end&&t.end(e,n,o))}A()}(e,{warn:Bo,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,o,a,l,f){var p=r&&r.ns||Wo(e);q&&"svg"===p&&(o=function(e){for(var t=[],n=0;nc&&(s.push(o=e.slice(c,i)),a.push(JSON.stringify(o)));var u=Ar(r[1].trim());a.push("_s("+u+")"),s.push({"@binding":u}),c=i+r[0].length}return c-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),Mr(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Br(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Br(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Br(t,"$$c")+"}",null,!0)}(e,r,i);else if("input"===o&&"radio"===a)!function(e,t,n){var r=n&&n.number,i=Ir(e,"value")||"null";Er(e,"checked","_q("+t+","+(i=r?"_n("+i+")":i)+")"),Mr(e,"change",Br(t,i),null,!0)}(e,r,i);else if("input"===o||"textarea"===o)!function(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?Wr:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=Br(t,l);c&&(f="if($event.target.composing)return;"+f),Er(e,"value","("+t+")"),Mr(e,u,f,null,!0),(s||a)&&Mr(e,"blur","$forceUpdate()")}(e,r,i);else if(!F.isReservedTag(o))return Hr(e,r,i),!1;return!0},text:function(e,t){t.value&&Er(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&Er(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:bo,mustUseProp:jn,canBeLeftOpenTag:$o,isReservedTag:Wn,getTagNamespace:Zn,staticKeys:function(e){return e.reduce(function(e,t){return e.concat(t.staticKeys||[])},[]).join(",")}(ba)},xa=g(function(e){return p("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))});function ka(e,t){e&&($a=xa(t.staticKeys||""),wa=t.isReservedTag||T,function e(t){t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||d(e.tag)||!wa(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every($a)))}(t);if(1===t.type){if(!wa(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n|^function(?:\s+[\w$]+)?\s*\(/,Oa=/\([^)]*?\);*$/,Sa=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ta={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Ea={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Na=function(e){return"if("+e+")return null;"},ja={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Na("$event.target !== $event.currentTarget"),ctrl:Na("!$event.ctrlKey"),shift:Na("!$event.shiftKey"),alt:Na("!$event.altKey"),meta:Na("!$event.metaKey"),left:Na("'button' in $event && $event.button !== 0"),middle:Na("'button' in $event && $event.button !== 1"),right:Na("'button' in $event && $event.button !== 2")};function Da(e,t){var n=t?"nativeOn:":"on:",r="",i="";for(var o in e){var a=La(e[o]);e[o]&&e[o].dynamic?i+=o+","+a+",":r+='"'+o+'":'+a+","}return r="{"+r.slice(0,-1)+"}",i?n+"_d("+r+",["+i.slice(0,-1)+"])":n+r}function La(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map(function(e){return La(e)}).join(",")+"]";var t=Sa.test(e.value),n=Aa.test(e.value),r=Sa.test(e.value.replace(Oa,""));if(e.modifiers){var i="",o="",a=[];for(var s in e.modifiers)if(ja[s])o+=ja[s],Ta[s]&&a.push(s);else if("exact"===s){var c=e.modifiers;o+=Na(["ctrl","shift","alt","meta"].filter(function(e){return!c[e]}).map(function(e){return"$event."+e+"Key"}).join("||"))}else a.push(s);return a.length&&(i+=function(e){return"if(!$event.type.indexOf('key')&&"+e.map(Ma).join("&&")+")return null;"}(a)),o&&(i+=o),"function($event){"+i+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ma(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ta[e],r=Ea[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Ia={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:S},Fa=function(e){this.options=e,this.warn=e.warn||Sr,this.transforms=Tr(e.modules,"transformCode"),this.dataGenFns=Tr(e.modules,"genData"),this.directives=A(A({},Ia),e.directives);var t=e.isReservedTag||T;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function Pa(e,t){var n=new Fa(t);return{render:"with(this){return "+(e?Ra(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function Ra(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ha(e,t);if(e.once&&!e.onceProcessed)return Ba(e,t);if(e.for&&!e.forProcessed)return za(e,t);if(e.if&&!e.ifProcessed)return Ua(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=qa(e,t),i="_t("+n+(r?","+r:""),o=e.attrs||e.dynamicAttrs?Ga((e.attrs||[]).concat(e.dynamicAttrs||[]).map(function(e){return{name:b(e.name),value:e.value,dynamic:e.dynamic}})):null,a=e.attrsMap["v-bind"];!o&&!a||r||(i+=",null");o&&(i+=","+o);a&&(i+=(o?"":",null")+","+a);return i+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:qa(t,n,!0);return"_c("+e+","+Va(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Va(e,t));var i=e.inlineTemplate?null:qa(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(i?","+i:"")+")"}for(var o=0;o>>0}(a):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var o=function(e,t){var n=e.children[0];if(n&&1===n.type){var r=Pa(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map(function(e){return"function(){"+e+"}"}).join(",")+"]}"}}(e,t);o&&(n+=o+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Ga(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Ka(e){return 1===e.type&&("slot"===e.tag||e.children.some(Ka))}function Ja(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ua(e,t,Ja,"null");if(e.for&&!e.forProcessed)return za(e,t,Ja);var r=e.slotScope===ca?"":String(e.slotScope),i="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(qa(e,t)||"undefined")+":undefined":qa(e,t)||"undefined":Ra(e,t))+"}",o=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+i+o+"}"}function qa(e,t,n,r,i){var o=e.children;if(o.length){var a=o[0];if(1===o.length&&a.for&&"template"!==a.tag&&"slot"!==a.tag){var s=n?t.maybeComponent(a)?",1":",0":"";return""+(r||Ra)(a,t)+s}var c=n?function(e,t){for(var n=0,r=0;r':'
',ts.innerHTML.indexOf(" ")>0}var os=!!z&&is(!1),as=!!z&&is(!0),ss=g(function(e){var t=Yn(e);return t&&t.innerHTML}),cs=wn.prototype.$mount;return wn.prototype.$mount=function(e,t){if((e=e&&Yn(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ss(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){var i=rs(r,{outputSourceRange:!1,shouldDecodeNewlines:os,shouldDecodeNewlinesForHref:as,delimiters:n.delimiters,comments:n.comments},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return cs.call(this,e,t)},wn.compile=rs,wn}); -------------------------------------------------------------------------------- /src/www/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WireGuard", 3 | "display": "standalone", 4 | "background_color": "#fff", 5 | "icons": [ 6 | { 7 | "src": "img/favicon.png", 8 | "type": "image/png" 9 | } 10 | ] 11 | } --------------------------------------------------------------------------------