Removed everything

master
Keith Irwin 2022-08-27 12:56:20 -06:00
parent d8d41b2088
commit 08a0b6f317
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
27 changed files with 0 additions and 2823 deletions

View File

@ -1,5 +0,0 @@
node_modules
npm-debug.log
.c9/
env*.json
docker-compose.yml

4
.gitignore vendored
View File

@ -1,4 +0,0 @@
node_modules/
.c9/
env*.json
docker-compose.yml

View File

@ -1,10 +0,0 @@
FROM node:16-bullseye
RUN apt-get update && apt-get install -y dnsutils && apt-get upgrade -y && apt-get autoremove -y && apt-get clean
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN npm ci --only=production
COPY . .
EXPOSE 8080
EXPOSE 8081
CMD [ "npm", "run", "start" ]

View File

@ -1,336 +0,0 @@
GNU General Public License
==========================
_Version 2, June 1991_
_Copyright © 1989, 1991 Free Software Foundation, Inc.,_
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
### Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: **(1)** copyright the software, and
**(2)** offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
**0.** This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The “Program”, below,
refers to any such program or work, and a “work based on the Program”
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term “modification”.) Each licensee is addressed as “you”.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
**1.** You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
**2.** You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
* **a)** You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
* **b)** You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
* **c)** If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
**3.** You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
* **a)** Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
* **b)** Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
* **c)** Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
**4.** You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
**5.** You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
**6.** Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
**7.** If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
**8.** If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
**9.** The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and “any
later version”, you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
**10.** If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
### NO WARRANTY
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w` and `show c` should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w` and `show c`; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a “copyright disclaimer” for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

125
README.md
View File

@ -1,125 +0,0 @@
# wgapi
*NodeJS server to add and remove wireguard configs*
## Installation
### with Docker
Install docker and docker-compose. Then create a project directory and pull the sample environment files.
```sh
sudo mkdir /srv/wgapi
cd /srv/wgapi
sudo wget 'https://gitea.gf4.pw/gf4/wgapi/raw/branch/master/docker-compose.yml.sample'
sudo wget 'https://gitea.gf4.pw/gf4/wgapi/raw/branch/master/env.json.sample'
sudo cp docker-compose.yml.sample docker-compose.yml
sudo cp env.json.sample env.json
```
Edit `docker-compose.yml` and `env.json` files according to their comments. Then you can start the service:
```sh
docker-compose up -d
```
The API will modify your wireguard configuration file. Changes will not take effect unless the interface is restarted periodically. One way of doing this is with a systemd timer.
### systemd
The API edits the wireguard config in the background but doesn't restart the service. To have changes take effect every 10 minutes, you can use this repo's systemd unit files:
```sh
cd /etc/systemd/system
sudo wget 'https://gitea.gf4.pw/gf4/wgapi/raw/branch/master/systemd/restart-wg-quick@.service'
sudo wget 'https://gitea.gf4.pw/gf4/wgapi/raw/branch/master/systemd/restart-wg-quick@.timer'
sudo systemctl daemon-reload
# Replace this with your interface
sudo systemctl start restart-wg-quick@wg0.timer
```
If that works, make it run on boot:
```sh
sudo systemctl enable restart-wg-quick@wg0.timer
```
## Usage
Once the server is listening, there are three endpoints that clients can direct requests to.
### List (/list)
This endpoint returns a user's `user` object, including an auth token, containing all the peer information in `user.peers`.
#### Request
Just `GET /list` and this endpoint will detect who you are based on your IP and return your user object.
#### Response
Returns the user object and peers as json.
```json
{
"name": myusername,
"token": longsecrettokenhere,
"subnet": "8",
"peers": [
{
"name": "host1",
"ipv4": "10.5.8.1"
"ipv6": "fd69:1337:0:420:f4:f5:8:1"
},
{
"name": "host2",
"ipv4": "10.5.8.2"
"ipv6": "fd69:1337:0:420:f4:f5:8:2"
}
]
}
```
...
### Add
This endpoint adds a peer to the wireguard servers and adds its IP address to the nameserver. To guard against IP spoofing, it requires a token from a `/list` request.
#### Request
Simply `GET /add?token=MYTOKEN&name=host3` where `MYTOKEN` is the secret token from the `/list` request and `host3` is the new hostname. The backend will add your new peer to its wireguard config and inform other servers of the new peer. Then it will modify the nameserver to add your peer's IP addresses under the domain `host3.myusername.tld`.
#### Response
A successful `/add` request will return the new peer's wireguard configuration as plaintext. Copy and paste it to your client machine's `/etc/wireguard/wg0.conf` file.
A failed requst will return an error code. `5XX` HTTP codes provide have errors in the log.
### Delete
This endpoint deletes a peer from the wireguard servers and removes its domain from the nameserver. To guard against IP spoofing, it requires a token from a `/list` request.
#### Request
After getting a token from a `/list` request, a peer can be identified and deleted using any of these requests:
- `GET /del?token=MYTOKEN&name=host3` using the hostname
- `GET /del?token=MYTOKEN&pubkey=PUBKEY` using a wireguard public key
- `GET /del?token=MYTOKEN&privkey=PRIVKEY` using a wireguard private key
- `GET /del?token=MYTOKEN&psk=PSK` using the wireguard preshared key
- `GET /del?token=MYTOKEN&ip=IP` using an IPv4 or IPv6 address
#### Response
It will simply return `200 OK` in case of success. `5XX` HTTP codes provide have errors in the log.
## License (GPLv2)
Copyright © 2021 Keith Irwin
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

View File

@ -1,23 +0,0 @@
'use strict'
/* admin/add.js
* routes for intra-server peer sharing
*/
const env = require(process.argv[2]||'../env.json')
const fs = require('fs').promises
module.exports = async (req, res) => {
// Add request body to wg config
try {
await fs.appendFile(env.WG_CONFIG_FILE, req.body)
} catch (err) {
console.error(`Failed to save new peer config from ${req.requester} to ${env.WG_CONFIG_FILE}`,err)
return res.sendStatus(500)
}
console.log(`Saved new peer from ${req.requester} to ${env.WG_CONFIG_FILE}`)
// Respond
return res.sendStatus(200)
}

View File

@ -1,45 +0,0 @@
'use strict'
/* admin/del.js
* routes for intra-server peer sharing
*/
const env = require(process.argv[2]||'../env.json')
const fs = require('fs').promises
module.exports = async (req, res) => {
console.log(`Received delete from ${req.requester} for ${req.body}`)
let config
// Read config file
try {
const config_file = await fs.readFile(env.WG_CONFIG_FILE)
config = config_file.toString()
}
catch (err) {
console.error(`Failed to load config from ${env.WG_CONFIG_FILE}:\n`,err)
return res.sendStatus(500)
}
// Find peer in config
const peer = config.split('\n\n')
.filter( (paragraph) => {
return paragraph.includes('[Peer]')
}).filter( (peer) => {
return peer.includes(`PublicKey = ${req.body}`)
})
// Delete peer
try { await fs.writeFile(env.WG_CONFIG_FILE,
config.replace(`\n${peer}`,'')
.replace('\n\n\n','\n\n')
) }
catch (err) {
console.error(`Failed to delete peer config from ${env.WG_CONFIG_FILE}:\n`,err)
return res.sendStatus(500)
}
// Success
console.log(`Deleted peer by requested from ${req.requester}`)
return res.sendStatus(200)
}

View File

@ -1,224 +0,0 @@
'use strict'
/* app/add.js
* route for a client to add a peer
*/
const env = require(process.argv[2]||'../env.json')
const helper = require('../includes/helpers')
const fs = require('fs').promises
const wg = require('../includes/wireguard')
const https = require('https')
// Construct axios in IIFE for async/await
let axios; (async()=>{
try {
axios = require('axios').create({
httpsAgent: new https.Agent({
ca: await fs.readFile(env.CA_CERT_FILE),
}),
})
} catch (err) { console.error(err) }
})()
const dns_key = `hmac-sha512:wgapi-${env.LOCAL_SERVER}:${env.DNS_KEY}`
module.exports = async (req, res) => {
// Parse, sanitize, and validate hostname
const new_hostname = req.body['name'].trim().toLowerCase()
if (!new_hostname) {
console.log(`New peer request from ${req.requester} didn't provide a hostname`)
return res.setHeader('content-type', 'text/plain')
.status(400).send('You must provide a hostname!')
} else if (!/^([\-\_a-z0-9]{3,12})$/.test(new_hostname)) {
console.log(`New peer request from ${req.requester} provided an invalid hostname: ${new_hostname}`)
return res.setHeader('content-type', 'text/plain')
.status(400).send('That name is invalid. It must contain only letters and numbers.')
} else console.log(`New peer request from ${req.requester} for ${new_hostname}`)
// Get user from IP
let user; try { user = await helper.getUserFromIp(req.requester) }
catch (err) {
console.error(`Failed to get user from ${req.requester}`)
return res.setHeader('content-type', 'text/plain')
.status(403).send('User not found!')
} console.log(`${req.requester} identified as ${user.name}`)
// Check token
if (req.query['token']!==helper.getToken(req.requester)) {
console.log(`Invalid token from ${req.requester}: ${req.query['token']}`)
return res.setHeader('content-type', 'text/plain')
.status(403).send('Invalid token!')
}
// Check if new peer already exists
const domain = `${new_hostname}.${user.name}.${env.TLD}`
if (user.peers.map((peer) => peer.name).includes(new_hostname)) {
console.log(`Host already exists for ${domain}`)
return res.setHeader('content-type', 'text/plain')
.setHeader('Access-Control-Allow-Origin', '*')
.status(409).send(`You already have a peer named ${new_hostname}`)
}
// Create IP Addresses and keys
console.log(`Generating new IP addresses and keys...`)
const used_ipv4_hosts = user.peers
.map((host) => host.ipv4).map((found_ipv4) =>
found_ipv4.toString().split('.')[3])
const used_ipv6_hosts = user.peers
.map((host) => host.ipv6).map((found_ipv6) =>
found_ipv6.toString().split(':')[3])
let host = 1
while ([...used_ipv4_hosts,...used_ipv6_hosts].includes(host.toString())) host++
if (host>9999) {
console.error(`ERROR! New host part for ${user.name} is higher than 9999: ${host}`)
return res.setHeader('content-type', 'text/plain')
.status(507).send('No more numeric IPv6 addresses available. Try deleting an old peer first. ')
}
let ipv4_addr; if (host<254)
ipv4_addr = `${env.IPV4_NET}.${user.subnet}.${host}`
const ipv6_addr = `${env.IPV6_NET}:${user.subnet}:${host}`
let keypair; try {
keypair = await wg.generateKeypair()
} catch (err) {
console.error(`ERROR! Unable to generateKeypair.`)
if (err) console.error(err)
return res.setHeader('content-type', 'text/plain')
.status(500).send('Server failed to generate a keypair. Something is broken so your peer was not created.')
}
console.log(`Generated IP addresses and keys.`)
// Peer with each server
let client_peers = []
for (const server of env.SERVERS) {
let psk; try {
psk = await wg.generatePSK()
} catch (err) {
console.error(`Unable to generate PSK:\n${err}`)
return res.setHeader('content-type', 'text/plain')
.status(500).send('Server failed to generate a PSK. Something is broken so your peer was not created.')
}
// Add server to user config as [Peer]
let allowed_ipv4s, allowed_ipv6s
if (server.host===env.LOCAL_SERVER) {
allowed_ipv4s = `${env.IPV4_CIDR_NET}/${env.IPV4_CIDR}`
allowed_ipv6s = `${env.IPV6_CIDR_NET}/${env.IPV6_CIDR}`
} else {
allowed_ipv4s = `${server.ipv4}/32`
allowed_ipv6s = `${server.ipv6}/128`
}
client_peers.push(`
[Peer] # ${server.host}.${env.TLD}
PublicKey = ${server.pubkey}
PresharedKey = ${psk}
AllowedIPs = ${allowed_ipv4s}, ${allowed_ipv6s}
Endpoint = ${server.endpoint}
PersistentKeepAlive = 25`)
// Add new user device to server config as [Peer]
const allowed_ips = ipv4_addr
? `${ipv4_addr}/32, ${ipv6_addr}/128`
: `${ipv6_addr}/128`
const server_config = `
[Peer] # ${domain}
PublicKey = ${keypair[0]}
PresharedKey = ${psk}
AllowedIPs = ${allowed_ips}
`
// Add server_config to local wg0.conf
if (server.host===env.LOCAL_SERVER) {
console.log(`Adding config to local wg.conf at ${env.WG_CONFIG_FILE}...`)
try { await fs.appendFile(env.WG_CONFIG_FILE, server_config) }
catch (err) {
console.error(`ERROR! Failed to write to config file!`)
if (err) console.error(err)
}
console.log(`Added new peer to local wg.conf file.`)
// Remote server: send config
} else {
console.log(`Sending config to ${server.host}.${env.TLD}...`)
try {
await axios.post(`${server.admin_endpoint}/add?secret=${server.secret}`, server_config, {
headers: {'Content-Type': 'text/plain'},
})
} catch (err) {
console.error(`ERROR! Failed to add peer to ${server.host}:\n${server_config} but the peer was created locally.`)
if (err) console.error(err.message)
}
console.log(`Config sent to ${server.host}.${env.TLD}.`)
}
}
// Update nameserver
if (env.ENV!=='prod') console.log(`Skipping nameserver updates because env.ENV != 'prod'`)
else {
console.log(`Sending nsupdates to ${env.DNS_MASTER}...`)
// Forward DNS
try {
await helper.nsUpdate(dns_key, env.DNS_MASTER,
`update add ${domain}. ${env.DNS_TTL} A ${ipv4_addr}
update add ${domain}. ${env.DNS_TTL} AAAA ${ipv6_addr}
update add *.${domain}. ${env.DNS_TTL} CNAME ${domain}.`)
}
catch (err) {
console.error(`ERROR! Failed to add ns record.`)
if (err) console.error(err)
}
console.log(`Added ${domain} fDNS to nameserver.`)
// IPv4 rDNS
const ptr_ipv4 = `${host}.${user.subnet}.${env.IPV4_RNET}.in-addr.arpa`
try {
await helper.nsUpdate(dns_key, env.DNS_MASTER,
`update add ${ptr_ipv4} ${env.DNS_TTL} PTR ${domain}.`)
}
catch (err) {
console.error(`ERROR! Failed to add IPv4 rDNS record.`)
if (err) console.error(err)
}
console.log(`Added ${domain} IPv4 rDNS to nameserver.`)
// IPv6 rDNS
const padded_ipv6 = `${user.subnet.padStart(4,'0')}${host.toString().padStart(4,'0')}`
const ptr_ipv6 = `${padded_ipv6.split('').reverse().join('.')}.${env.IPV6_RNET}.ip6.arpa`
try {
await helper.nsUpdate(dns_key, env.DNS_MASTER,
`update add ${ptr_ipv6} ${env.DNS_TTL} PTR ${domain}.`)
}
catch (err) {
console.error(`ERROR! Failed to add IPv6 rDNS record.`)
if (err) console.error(err)
}
console.log(`Added ${domain} IPv6 rDNS to nameserver.`)
}
// Create new SSL cert
if (env.ENV!=='prod') console.log(`Skipping nameserver updates because env.ENV != 'prod'`)
else {
console.log(`Creating SSL cert for ${new_hostname}.${user.name}...`)
try {
await helper.createCert(new_hostname, user.name, ipv6_addr, ipv4_addr)
}
catch (err) {
console.error(`ERROR! Failed to create SSL cert.`)
if (err) console.error(err)
}
console.log(`Created SSL cert for ${new_hostname}.${user.name}`)
}
// Generate user config and send it back to the user
console.log(`Sending config back to user...`)
const config_address = ipv4_addr
? `${ipv4_addr}/${env.IPV4_CIDR}, ${ipv6_addr}/${env.IPV6_CIDR}`
: `${ipv6_addr}/${env.IPV6_CIDR}`
return res.setHeader('content-type', 'text/plain')
.status(201).send(`[Interface] # ${domain}
PrivateKey = ${keypair[1]}
Address = ${config_address}
DNS = ${res.locals.DNS_SERVERS_STRING}
${client_peers.join('\n')}`)
}

View File

@ -1,244 +0,0 @@
'use strict'
/* app/del.js
* route to let clients delete a peer
*/
const fs = require('fs').promises
const env = require(process.argv[2]||'../env.json')
const helper = require('../includes/helpers')
const wg = require('../includes/wireguard')
const https = require('https')
// Construct axios in IIFE for async/await
let axios; (async()=>{
try {
axios = require('axios').create({
httpsAgent: new https.Agent({
ca: await fs.readFile(env.CA_CERT_FILE),
}),
})
} catch (err) { console.log(err) }
})()
const dns_key = `hmac-sha512:wgapi-${env.LOCAL_SERVER}:${env.DNS_KEY}`
module.exports = async (req, res) => {
const target = req.body['name']
|| req.body['psk']
|| req.body['ip']
|| req.body['pubkey']
|| req.body['privkey']
console.log(`Received request from ${req.requester} to delete ${target}`)
// Get user from IP
let user; try { user = await helper.getUserFromIp(req.requester) }
catch (err) {
console.error(`Failed to get user from ${req.requester}`)
return res.setHeader('content-type', 'text/plain')
.status(404).send(`User for ${req.requester} not found`)
}
console.log(`${req.requester} identified as ${user.name}`)
// Check token
if (req.query['token']!==helper.getToken(req.requester)) {
console.log(`Invalid token from ${req.requester}: ${req.query['token']}`)
return res.setHeader('content-type', 'text/plain')
.status(403).send(`Invalid token!`)
}
// Load wg.conf
let config_file
try { config_file = await fs.readFile(env.WG_CONFIG_FILE) }
catch (err) {
console.error(`Failed to read config file from ${env.WG_CONFIG_FILE}`)
if (err) console.error(err)
return res.setHeader('content-type', 'text/plain')
.status(500).send('Server error! Something is broken.')
}
// Search for peer
let peer_pubkey
const config = config_file.toString()
console.log(`Checking ${env.WG_CONFIG_FILE} for peer to be deleted...`)
const peer = config.split('\n\n')
.filter( (paragraph) => {
return paragraph.includes('[Peer]')
}).filter( (peer) => {
if (req.body['name']) {
return peer.includes(`[Peer] # ${req.body['name']}.`)
} else if (req.body['pubkey']) {
peer_pubkey = req.body['pubkey']
return peer.includes(`PublicKey = ${req.body['pubkey']}`)
} else if (req.body['psk']) {
return peer.includes(`PresharedKey = ${req.body['psk']}`)
} else if (req.body['ip']) {
return peer.split('\n').some( (line) => (
line.includes('AllowedIPs') &&
line.includes(` ${req.body['ip']}/`)
) )
} else if (req.body['privkey']) {
// .filter() doesn't support async so use then/catch in this block
wg.getPubkeyFromPrivkey(req.body['privkey'])
.then((pubkey) => {
peer_pubkey = pubkey
return peer.includes(`PublicKey = ${pubkey}`)
})
.catch((err) => {
console.error(`ERROR! Failed to generate public key from private key during delete request`)
if (err) console.error(err)
res.setHeader('content-type', 'text/plain')
.status(500).send('Failed to generate public key to delete host. Something is broken!')
})
} else {
console.error(`ERROR! ${req.requester} sent delete request without specifying a peer`)
res.setHeader('content-type', 'text/plain')
.status(400).send('Peer not specified!')
}
})[0]
if (peer===undefined) {
console.log(`No peer found for delete request from ${req.requester}`)
return res.setHeader('content-type', 'text/plain')
.status(404).send('Peer not found')
}
// Parse peer
const peer_lines = peer.split('\n')
const peer_name = peer_lines
.filter( (line) => line.includes('[Peer] # ') )[0]
.split(' # ')[1]
console.log(`Found peer: ${peer_name}.`)
const peer_ips = peer_lines
.filter( (line) => line.includes('AllowedIPs = '))[0]
.split(' = ')[1].split(', ')
let ipv4, ipv6
for (const ip of peer_ips) {
if (ip.indexOf(env.IPV4_NET)!==-1) ipv4 = ip
else if (ip.indexOf(env.IPV6_NET)!==-1) ipv6 = ip
else console.error(`ERROR! Unable to parse this IP: ${ip}`)
}
const ipv4_split = ipv4.split('/')[0].split('.')
const ipv4_user = ipv4_split[2]
const ipv4_device = ipv4_split[3]
const ipv6_split = ipv6.split('/')[0].split(':')
const ipv6_user = ipv6_split[ipv6_split.length-2]
const ipv6_device = ipv6_split[ipv6_split.length-1]
if (peer_pubkey===undefined) {
peer_pubkey = peer_lines
.filter( (line) => line.includes('PublicKey = ') )[0]
.split(' = ')[1]
}
// Make sure this checks out...
if (ipv4 && ipv6) {
if (!ipv4_user===ipv6_user) {
console.error(`HEY! ipv4_user!==ipv6_user
${ipv4_user}!==${ipv6_user}`)
return res.setHeader('content-type', 'text/plain')
.status(500).send('There was an error on the server! Please report this to Keith <ki9@gf4.pw>. ')
}
if (!ipv4_device===ipv6_device) {
console.error(`HEY! ipv4_device!==ipv6_device
${ipv4_user}!==${ipv6_user}`)
return res.setHeader('content-type', 'text/plain')
.status(500).send('There was an error on the server! Please report this to Keith <ki9@gf4.pw>. ')
}
}
// Make sure requester can't delete self
if (peer_ips.includes(req.requester)) {
console.log(`Refused to let ${req.requester} delete self: ${peer_name}`)
return res.setHeader('content-type', 'text/plain')
.status(409).send('You can not delete the peer you are using!')
}
// Delete from local wg config
console.log(`Deleting ${peer_name} from ${env.WG_CONFIG_FILE}...`); try {
await fs.writeFile(env.WG_CONFIG_FILE,
config.replace(`\n${peer}`,'')
.replace('\n\n\n','\n\n')
)
} catch (err) {
console.error(`ERROR! Failed to delete ${peer_name}`)
if (err) console.error(err)
return res.setHeader('content-type', 'text/plain')
.status(500).send('Failed to delete! Try again?')
}
console.log(`${peer_name} deleted. `)
// Inform other servers
for (const server of env.SERVERS) {
if (server.host!==env.LOCAL_SERVER) {
try {
console.log(`Informing ${server.host} to delete ${peer_name}...`)
await axios.post(`${server.admin_endpoint}/del?secret=${server.secret}`, peer_pubkey, {
headers: {'Content-Type': 'text/plain'},
})
} catch (err) {
console.error(`ERROR! Failed to inform ${server.host} to delete ${peer_name}!`)
if (err) console.error(err)
return res.setHeader('content-type', 'text/plain')
.status(500).send('Peer was added but did not propogate to the other server')
}
console.log(`Informed ${server.host} to delete ${peer_name}.`)
}
}
// Delete domains from nameserver
if (env.ENV!=='prod') console.log(`Skipping nameserver updates because env.ENV != 'prod'`)
else {
console.log(`Sending nsupdates to ${env.DNS_MASTER}...`)
// Forward DNS
try {
await helper.nsUpdate(dns_key, env.DNS_MASTER,
`update delete ${peer_name}. A
update delete ${peer_name}. AAAA
update delete *.${peer_name}. CNAME`)
}
catch (err) {
console.error(`ERROR! Failed to delete fDNS record`)
if (err) console.error(err)
}
console.log(`Updated nameserver to delete ${peer_name} fDNS.`)
// IPv4 reverse DNS
const ptr_ipv4 = `${ipv4_device}.${ipv4_user}.${env.IPV4_RNET}.in-addr.arpa`
try {
await helper.nsUpdate(dns_key, env.DNS_MASTER,
`update delete ${ptr_ipv4} PTR`)
}
catch (err) {
console.error(`ERROR! Failed to delete ipv4 rDNS record`)
if (err) console.error(err)
}
console.log(`Updated nameserver to delete ${peer_name} IPv4 rDNS.`)
// IPv6 reverse DNS
const padded_ipv6 = `${ipv6_user.padStart(4,'0')}${ipv6_device.padStart(4,'0')}`
const ptr_ipv6 = `${padded_ipv6.split('').reverse().join('.')}.${env.IPV6_RNET}.ip6.arpa`
try {
await helper.nsUpdate(dns_key, env.DNS_MASTER,
`update delete ${ptr_ipv6} PTR`)
}
catch (err) {
console.error(`ERROR! Failed to delete ipv6 rDNS record`)
if (err) console.error(err)
}
console.log(`Updated nameserver to delete ${peer_name} IPv6 rDNS.`)
}
// Delete SSL cert
if (env.ENV!=='prod') console.log(`Skipping nameserver updates because env.ENV != 'prod'`)
else {
console.log(`Deleting SSL cert for ${peer_name}...`)
try {
await helper.deleteCert(peer_name.split('.')[0], peer_name.split('.')[1])
}
catch (err) {
console.error(`ERROR! Failed to create SSL cert.`)
if (err) console.error(err)
}
console.log(`Deleted SSL cert for ${peer_name}`)
}
return res.sendStatus(200)
}

View File

@ -1,34 +0,0 @@
'use strict'
/* app/list.js
* route for a client to add a peer
*/
const helper = require('../includes/helpers')
module.exports = async (req, res) => {
console.log(`${req.requester} loaded dashboard`)
// Get user from IP
let user
try { user = await helper.getUserFromIp(req.requester) }
catch (err) {
console.error(`Failed to get user from ${req.requester}`)
if (err) console.error(err)
return res.setHeader('content-type', 'text/plain')
.status(403).send(`Could not find user for ${req.requester}`)
}
console.log(`${req.requester} must be ${user.name}`)
// Get or generate token
try { user.token = helper.getToken(req.requester) || await helper.setToken(req.requester) }
catch (err) {
console.error(`Failed to set token for ${req.requester}`)
return res.setHeader('content-type', 'text/plain')
.status(500).send(`Server error: Failed to set user token. Something is broken and it's not your fault!`)
}
// Send user
return res.setHeader('content-type', 'text/json')
.status(200).send(user)
}

View File

@ -1,18 +0,0 @@
version: '3'
services:
wgapi:
image: keith24/wgapi:latest
restart: unless-stopped
container_name: wgapi
volumes:
# Set this (mywg.conf) to the wireguard config you want to manage
- "/etc/wireguard/mywg.conf:/etc/wireguard/wg.conf"
# Truested CA cert for self-signed SSL
- "/etc/ssl/certs/mycert.pem:/etc/ssl/certs/ca.pem:ro"
# Environment
- "./env.json:/app/env.json:ro"
ports:
# Change 8080 to the port you want to listen on
- "8080:8080/tcp"
# Admin UI here
- "8081:8081/tcp"

View File

@ -1,46 +0,0 @@
{
"ENV": "dev",
"PORT": 8080,
"ADMIN_PORT": 8081,
"IPV4_CIDR_NET": "10.72.0.0",
"IPV4_CIDR": 16,
"IPV4_NET": "10.72",
"IPV4_RNET": "72.10",
"IPV6_CIDR_NET": "fd69:1337:0:420:f4::",
"IPV6_CIDR": 80,
"IPV6_NET": "fd69:1337:0:420:f4:abc2",
"IPV6_RNET": "2.c.b.a.4.f.0.0.0.2.4.0.0.0.0.0.7.3.3.1.9.6.d.f",
"TEST_REQUESTER": "10.72.1.1",
"TEST_ADMIN": "10.72.0.1",
"WG_CONFIG_FILE": "/etc/wireguard/wg.conf",
"CA_CERT_FILE": "/etc/ssl/certs/ca.pem",
"NEW_SSL_DEVICE_SCRIPT": "/path/to/new-device-cert",
"DEL_SSL_DEVICE_SCRIPT": "/path/to/del-device-cert",
"TLD": "tld",
"LOCAL_SERVER": "host1",
"DNS_KEY": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxw==",
"CA_PASSPHRASE": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx",
"DNS_MASTER": "10.72.0.1",
"DNS_TTL": "86400",
"SERVERS": [
{
"host": "host1",
"ipv4": "10.72.0.1",
"ipv6": "fd69:1337:0:420:f4:abc2::1",
"pubkey": "EJc/mCHDOkT2c3Ua7cqfE9bbIzc37A2dZeV30lg9wxY=",
"endpoint": "130.170.78.54:57268",
"admin_endpoint": "https://wgapi-admin.host1.tld",
"secret": "CHANGEME",
"dns": true
}, {
"host": "host2",
"ipv4": "10.72.0.2",
"ipv6": "fd69:1337:0:420:f4:abc2::2",
"pubkey": "YHIRsn6cPoh1K1wrHMW/kzKmh8bmNIh4GxshfLKejT0=",
"endpoint": "204.133.93.33:52334",
"admin_endpoint": "https://wgapi-admin.host2.tld",
"secret": "CHANGEME",
"dns": true
}
]
}

View File

@ -1,196 +0,0 @@
'use strict'
const crypto = require('crypto')
const env = require(process.argv[2]||'../env.json')
const fs = require('fs').promises
const spawn = require('child_process').spawn
let tokens = {}
//TODO: Reduce duplcated code in methods that call spawn()
module.exports = {
getUserFromIp: (ip) => new Promise( async (resolve, reject) => {
// Get subnet (number)
let subnet
if (ip.includes(env.IPV4_NET)) subnet = ip.split('.').slice(-2,-1)[0]
else if (ip.includes(env.IPV6_NET)) subnet = ip.split(':').slice(-2,-1)[0]
else console.log(`Received request from ${ip}, which does not appear to be from the network.`)
// Read wg.conf file for this user's other devices
let userpeers; try {
userpeers = (await fs.readFile(env.WG_CONFIG_FILE)).toString()
.split('\n\n').filter(
(paragraph) => paragraph.includes('[Peer]')
).filter(
(peer) => peer.includes(`${env.IPV4_NET}.${subnet}`)
|| peer.includes(`${env.IPV6_NET}:${subnet}`)
)
} catch (err) { console.log(err); reject(500) }
let found_usernames = []
let found_hosts = []
for (const userpeer of userpeers) {
let userpeer_obj = {}
for (const line of userpeer.split('\n')) {
if (line.includes('[Peer] # ')) {
const domain = line.split(' # ')[1].split('.')
userpeer_obj.name = domain[0]
found_usernames.push(domain[1])
}
else if (line.includes('AllowedIPs = ')) {
const ips = line.split('=')[1].split(', ')
userpeer_obj.ipv4 = ips.filter( (ip) => ip.includes(env.IPV4_NET) )[0].trim().split('/')[0]
userpeer_obj.ipv6 = ips.filter( (ip) => ip.includes(env.IPV6_NET) )[0].trim().split('/')[0]
}
}
found_hosts.push(userpeer_obj)
}
// Check that all IP addresses are in correct subnet or error out
if (!found_hosts.every((host) =>
host.ipv4.includes(`${env.IPV4_NET}.${subnet}.`) &&
host.ipv6.includes(`${env.IPV6_NET}:${subnet}:`)
)) {
console.error(
`ERROR! Found unmatching IP address subnets for ${ip}: \
${found_hosts.map( (host) => [host.ipv4,host.ipv6] )}`
); reject(500)
// Check that the ip is "on the list"
// Should never get here because this ip can't access this IP!
} else if (found_usernames.length ===0) {
console.error(`Received request from ${ip} not in wg.conf!`)
reject(403)
// Check that all usernames are the same correct or error out
// https://stackoverflow.com/a/35568895
} else if (!found_usernames.every( (v,i,r) => v === r[0] )) {
console.error(`ERROR! Found unmatching usernames for ${ip}: ${found_usernames.toString()}`)
reject(500)
} else {
resolve({
name: found_usernames[0],
subnet: subnet,
peers: found_hosts,
})
}
}),
getToken: (ip) => tokens[ip],
setToken: (ip) => new Promise ( async (resolve, reject) => {
try {
tokens[ip] = await crypto.randomBytes(40).toString('hex')
} catch (err) { reject(err) }
resolve(tokens[ip])
}),
nsUpdate: (key, server, payload) => new Promise( (resolve, reject) => {
try {
let nsupdate = spawn('nsupdate', ['-y', key])
// Collect output
let errors = ''
nsupdate.stdout.on('data', (data) => {
console.log(`nsupdate stdout: ${data}`)
})
nsupdate.stderr.on('data', (data) => {
console.error(`nsupdate stderr: ${data}`)
errors += data
})
// Send data
nsupdate.stdin.write(`server ${server}\n${payload}\nsend\nquit`)
nsupdate.stdin.end()
// Handle exit
nsupdate.on('error', (err) => {
console.error(`ERROR! nsupdate threw an error.`)
if (err) console.error(err)
reject(err)
})
nsupdate.on('exit', (status) => {
if (status!==0) {
console.error(`ERROR! nsupdate threw a nonzero exit code.`)
reject(errors)
}
else resolve()
})
// Something went wrong with the spawn?
} catch (err) {
console.error('ERROR! nsupdate failed to spawn or something.')
if (err) console.error(err)
reject(err)
}
}),
createCert: (device, username, ipv6, ipv4) => new Promise( (resolve, reject) => {
const ipstring = `IP:${ipv6}${ipv4?',IP:'+ipv4:''}`
try {
let createCert = spawn(env.NEW_SSL_DEVICE_SCRIPT, [device, username, ipstring, '365', env.CA_PASSPHRASE])
// Collect output
let errors = ''
createCert.stdout.on('data', (data) => {
console.log(`new-device-cert stdout: ${data}`)
})
createCert.stderr.on('data', (data) => {
console.error(`new-device-cert stdout: ${data}`)
errors += data
})
createCert.on('error', (err) => {
console.error(`ERROR! new-device-cert threw an error.`)
if (err) console.error(err)
reject(err)
})
createCert.on('exit', (status) => {
if (status!==0) {
console.error(`ERROR! new-device-cert threw a nonzero exit code.`)
reject(errors)
} else resolve()
})
// Something went wrong with the spawn?
} catch (err) {
console.error(`ERROR! Failed to spawn ${env.NEW_SSL_DEVICE_SCRIPT}`)
if (err) console.error(err)
reject(err)
}
}),
deleteCert: (device, username) => new Promise( (resolve, reject) => {
try {
let deleteCert = spawn(env.DEL_SSL_DEVICE_SCRIPT, [device, username])
// Collect output
let errors = ''
deleteCert.stdout.on('data', (data) => {
console.log(`del-device-cert stdout: ${data}`)
})
deleteCert.stderr.on('data', (data) => {
console.error(`del-device-cert stderr: ${data}`)
errors += data
})
deleteCert.on('error', (err) => {
console.error(`ERROR! del-device-cert threw an error.`)
if (err) console.error(err)
reject(err)
})
deleteCert.on('exit', (status) => {
if (status!==0) {
console.error(`ERROR! del-device-cert threw a nonzero exit code.`)
reject(errors)
} else resolve()
})
// Something went wrong with the spawn?
} catch (err) {
console.error(`ERROR! Failed to spawn ${env.DEL_SSL_DEVICE_SCRIPT}`)
if (err) console.error(err)
reject(err)
}
}),
}

View File

@ -1,61 +0,0 @@
'use strict'
const env = require(process.argv[2]||'../env.json')
// Get DNS Servers in a string for peer configs
let DNS_SERVERS = []
let SERVER_IPS = []
for (const server of env.SERVERS) {
if (server.ipv4) {
SERVER_IPS.push(server.ipv4)
if (server.dns) DNS_SERVERS.push(server.ipv4)
}
if (server.ipv6) {
SERVER_IPS.push(server.ipv6)
if (server.dns) DNS_SERVERS.push(server.ipv6)
}
}
const DNS_SERVERS_STRING = DNS_SERVERS.join(', ')
const local_secret = env.SERVERS.filter(
(server) => server.host === env.LOCAL_SERVER
)[0].secret
// Actual middleware
// These functions run every request so keep them lean
module.exports = {
getDnsServers: (req,res,next) => {
res.locals.DNS_SERVERS_STRING = DNS_SERVERS_STRING
next()
},
getRequester: (env.ENV==='prod')?
(req, res, next) => {
req.requester = req.headers['x-forwarded-for'] || req.ip.replace('::ffff:','')
next()
}:
(req, res, next) => {
req.requester = env.TEST_REQUESTER
next()
},
getAdminRequester: (env.ENV==='prod')?
(req, res, next) => {
req.requester = req.ip.replace('::ffff:','')
next()
}:
(req, res, next) => {
req.requester = env.TEST_ADMIN
next()
},
// Authenticate servers with secret
allowServers: (req, res, next) => {
// Check secret
if (req.query['secret']!==local_secret) {
console.log(`Peer sent from ${req.requester} without correct secret querystring!`)
return res.sendStatus(403)
} else next()
},
}

View File

@ -1,193 +0,0 @@
/*! SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/
'use strict'
const crypto = require('crypto').webcrypto
const gf = (init) => {
let r = new Float64Array(16);
if (init) {
for (let i = 0; i < init.length; ++i)
r[i] = init[i]
}
return r
}
const pack = (o, n) => {
let b, m = gf(), t = gf()
for (let i = 0; i < 16; ++i)
t[i] = n[i]
carry(t)
carry(t)
carry(t)
for (let j = 0; j < 2; ++j) {
m[0] = t[0] - 0xffed
for (let i = 1; i < 15; ++i) {
m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1)
m[i - 1] &= 0xffff
}
m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1)
b = (m[15] >> 16) & 1
m[14] &= 0xffff
cswap(t, m, 1 - b)
}
for (let i = 0; i < 16; ++i) {
o[2 * i] = t[i] & 0xff
o[2 * i + 1] = t[i] >> 8
}
}
const carry = (o) => {
for (let i = 0; i < 16; ++i) {
o[(i + 1) % 16] += (i < 15 ? 1 : 38) * Math.floor(o[i] / 65536)
o[i] &= 0xffff
}
}
const cswap = (p, q, b) => {
let t, c = ~(b - 1)
for (let i = 0; i < 16; ++i) {
t = c & (p[i] ^ q[i])
p[i] ^= t
q[i] ^= t
}
}
const add = (o, a, b) => {
for (let i = 0; i < 16; ++i)
o[i] = (a[i] + b[i]) | 0
}
const subtract = (o, a, b) => {
for (let i = 0; i < 16; ++i)
o[i] = (a[i] - b[i]) | 0
}
const multmod = (o, a, b) => {
let t = new Float64Array(31)
for (let i = 0; i < 16; ++i) {
for (let j = 0; j < 16; ++j)
t[i + j] += a[i] * b[j]
}
for (let i = 0; i < 15; ++i)
t[i] += 38 * t[i + 16]
for (let i = 0; i < 16; ++i)
o[i] = t[i]
carry(o)
carry(o)
}
const invert = (o, i) => {
let c = gf()
for (let a = 0; a < 16; ++a)
c[a] = i[a]
for (let a = 253; a >= 0; --a) {
multmod(c, c, c)
if (a !== 2 && a !== 4)
multmod(c, c, i)
}
for (let a = 0; a < 16; ++a)
o[a] = c[a]
}
const clamp = (z) => {
z[31] = (z[31] & 127) | 64
z[0] &= 248
}
const generatePublicKey = (privateKey) => {
let r, z = new Uint8Array(32)
let a = gf([1]),
b = gf([9]),
c = gf(),
d = gf([1]),
e = gf(),
f = gf(),
_121665 = gf([0xdb41, 1]),
_9 = gf([9])
for (let i = 0; i < 32; ++i)
z[i] = privateKey[i]
clamp(z)
for (let i = 254; i >= 0; --i) {
r = (z[i >>> 3] >>> (i & 7)) & 1
cswap(a, b, r)
cswap(c, d, r)
add(e, a, c)
subtract(a, a, c)
add(c, b, d)
subtract(b, b, d)
multmod(d, e, e)
multmod(f, a, a)
multmod(a, c, a)
multmod(c, b, e)
add(e, a, c)
subtract(a, a, c)
multmod(b, a, a)
subtract(c, d, f)
multmod(a, c, _121665)
add(a, a, d)
multmod(c, c, a)
multmod(a, d, f)
multmod(d, b, _9)
multmod(b, e, e)
cswap(a, b, r)
cswap(c, d, r)
}
invert(c, c)
multmod(a, a, c)
pack(z, a)
return z
}
const generatePresharedKey = () => {
let privateKey = new Uint8Array(32)
crypto.getRandomValues(privateKey)
return privateKey
}
const generatePrivateKey = () => {
let privateKey = generatePresharedKey()
clamp(privateKey)
return privateKey
}
const encodeBase64 = (dest, src) => {
let input = Uint8Array.from([(src[0] >> 2) & 63, ((src[0] << 4) | (src[1] >> 4)) & 63, ((src[1] << 2) | (src[2] >> 6)) & 63, src[2] & 63]);
for (let i = 0; i < 4; ++i)
dest[i] = input[i] + 65 +
(((25 - input[i]) >> 8) & 6) -
(((51 - input[i]) >> 8) & 75) -
(((61 - input[i]) >> 8) & 15) +
(((62 - input[i]) >> 8) & 3);
}
const keyToBase64 = (key) => {
let i, base64 = new Uint8Array(44);
for (i = 0; i < 32 / 3; ++i)
encodeBase64(base64.subarray(i * 4), key.subarray(i * 3));
encodeBase64(base64.subarray(i * 4), Uint8Array.from([key[i * 3 + 0], key[i * 3 + 1], 0]));
base64[43] = 61;
return String.fromCharCode.apply(null, base64);
}
module.exports = {
generateKeypair: async () => {
let privateKey, publicKey
try {
privateKey = await generatePrivateKey()
} catch (err) { console.error(err) }
try {
publicKey = await generatePublicKey(privateKey)
} catch (err) { console.error(err) }
return [
keyToBase64(publicKey),
keyToBase64(privateKey),
]
},
generatePSK: async () => {
try {
return keyToBase64(await generatePresharedKey())
} catch (err) { return console.error(err) }
},
getPubkeyFromPrivkey: async (privKey) => {
try {
return await generatePublicKey(privKey)
} catch (err) { return console.error(err) }
},
}

View File

@ -1,42 +0,0 @@
'use strict'
/* index.js
* Entrypoint and server listener
*/
const env = require(process.argv[2]||'./env.json')
const mw = require('./includes/middleware.js')
const express = require('express')
const fs = require('fs').promises
const app = express()
const admin = express()
// Check the wireguard config file for '::'
;(async (f) => {
let config; try {
config = (await fs.readFile(f)).toString()
} catch (err) {
console.error(`Failed to read ${f}!`)
if (err) console.error(err.message)
}
if (config.includes('::'))
console.error(`Found double colons (::) in ${f}! Please expand all IPv6 addresses to prevent parsing issues!`)
})(env.WG_CONFIG_FILE)
app.use(express.json())
.set('trust proxy', true)
.use(mw.getRequester)
.get('/', require('./app/list.js'))
.post('/', mw.getDnsServers, require('./app/add.js'))
.delete('/', require('./app/del.js'))
.listen(env.PORT)
admin.use(express.json())
.set('trust proxy', true)
.use(mw.getAdminRequester)
.use(mw.allowServers)
.use(express.text())
.post('/add', require('./admin/add.js'))
.post('/del', require('./admin/del.js'))
.listen(env.ADMIN_PORT)
console.log('Server started')

View File

@ -1,4 +0,0 @@
#!/bin/sh
npm install
mkdir -p "${DESTDIR}/usr/local/lib"
cp -r "${SRCDIR}" "${DESTDIR}/usr/local/lib/wgapi"

View File

@ -1,13 +0,0 @@
[Distribution]
Distribution=arch
[Output]
Format=directory
Output=/var/lib/machines/wgapi
[Packages]
Packages=npm
[Content]
Password=root
WithNetwork=yes

View File

@ -1,34 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIF7zCCA9egAwIBAgIUL/Lx0bFmVYjHfBLYYNZAJZ3Fj/4wDQYJKoZIhvcNAQEL
BQAwgYYxCzAJBgNVBAYTAlVTMREwDwYDVQQIDAhDb2xvcmFkbzEPMA0GA1UEBwwG
QmxhbmNhMRwwGgYDVQQKDBNHYWxhY3RpYyBGb3J0cmVzcyA0MQwwCgYDVQQLDANr
aTkxDDAKBgNVBAMMA2dmNDEZMBcGCSqGSIb3DQEJARYKa2k5QGdmNC5wdzAeFw0y
MTAyMTYwNzA1MTFaFw0yMzEyMDcwNzA1MTFaMIGGMQswCQYDVQQGEwJVUzERMA8G
A1UECAwIQ29sb3JhZG8xDzANBgNVBAcMBkJsYW5jYTEcMBoGA1UECgwTR2FsYWN0
aWMgRm9ydHJlc3MgNDEMMAoGA1UECwwDa2k5MQwwCgYDVQQDDANnZjQxGTAXBgkq
hkiG9w0BCQEWCmtpOUBnZjQucHcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK
AoICAQCzjqhEgXhjzWl62JHYHvWRx+PU+b9P+Z9iaE43CWNCaD8+kpOBlsNFxqZO
ZQCvMDmpGUyXEA941UqeJ9Pq7iPyHmFhxI+LPgdDpJtMlMYhhX6Bk5r6FtOKkjA0
855CnoUIlztLKnz3Z75tblKuCKhWBx+AZL4WCzSIK2/SWronUKI3EzLgQbpstYX2
RGLJK6GA7Eb66TfaAB1PjdsJmmJK/a13Sdlv/3HkAH1PVzvReo0ATKFspIu5jeSp
MRMhNoVsRwmpe3G15Ss6ZlqFAUd3ahtrykaW8qr3i0hW28dyGJcjEHzL4vlCWl4f
BQDE4uwae2TCtS6d4nQap4T6Vd1NEGuxqc5pRFlCYBy5UkuP8Kx+BnDnjpOeizft
B2gZSj8oYffK9lD/E3Eg0/ozL/ChnXpu+T58xCiPkXLhTHXhoN4oNMBxBr6/hE8V
U75JfB5XxzaVC6EOSkQBkPylt1WhUE8QAIiwZXZ2kgcZ9mHy64QDGtqQfVcCGmBD
Dypm7C2YY9Nix29vOwvn1HO0slH6uN85FOUkjPZRNlqcGPoLPfB5AdwbyoDPlYYD
n0ZyUTIC/DNqqAAANpiv/b8GqRvExU+/8/paLF2X1+LmjCvvNeOmpDHMGKaxDNSq
nZroFzvHHtOeOXrra8M+G+6lMqdx9NVLfx0zVw/nmB8/zN5FhwIDAQABo1MwUTAd
BgNVHQ4EFgQUvqxVtSSfih0gyTRngtWTJQfR2Z4wHwYDVR0jBBgwFoAUvqxVtSSf
ih0gyTRngtWTJQfR2Z4wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC
AgEAZgh9PqG+jsRrtSAdEqE2bzTufnBQFLne7lxB3SwOn6tbF2CP16P/HvHafDCw
wBDteb9HVPn3T6jABiEBrGrNGuYWQ8JpUh/Iee1QhwrKT4fPAnpQfuudtnp9wC7s
KZqJXR6LsmwRCtoYrKVzNJB8yLP3Q24BIZv9oDZLMza0Bv2IIQ6JxZ7MmNycYeVe
zxLY/rec48yp8H5DJfCboyiN27wI+z+vbgYJLFbNYs5DuxfkTQBRWJdlIx8siOrQ
47TYVoTIvhI90P9AcDeuEje0fWgZu73MOPSlVPU9fUfc+kqxgLb0fXyVj/Iy993n
faWWBsgh++ZxOw1ySGApwCzphLHD7b4RUAbOd+bBmCduucYja5Z2PXSvhvjyq8yL
MnWmVBAnErRv9qu7oHkHvHo+ZpWmNx3fOr1Y5B9bcOcuU5HnOap34IoaEiPoI+Sv
zXU/0H8WMu2ArqrpZDfCaL1hSXLqVyU2tKdbXYwQzxc2SD0IPuTzxZsS8JAXWR7x
3U7w8nnWepZEi/zvtHCyEuleca/tS8ZIGdyfyQQg9uJc0995IedxZ+ckkhXYLoqm
c4Y0mulZ7EqyRTV2dMy9ZcX9toKfk2n4pjIzVw4w8AqGnZwV4ydN8+NnxzUh2RF+
kMqCWaotcnevd74RI7rj3DG9RRM4+JJju2vi8JgENQQMXsY=
-----END CERTIFICATE-----

View File

@ -1 +0,0 @@
../../../../usr/local/lib/systemd/wgapi.service

View File

@ -1,189 +0,0 @@
[sudo] password for ki9:
Sorry, try again.
[sudo] password for ki9:
[Interface]
PrivateKey = wE9g7CrPnn1shOp7alObdh4LNk+HL4bNwr2APmhFQmM=
Address = fd69:1337:0:420:f4:f4:0:1/80, 10.4.0.1/16
#DNS = fd69:1337:0:420:f4:f4:0:1, 10.4.0.1, fd69:1337:0:420:f4:f4:0:3, 10.4.0.3
ListenPort = 52348
PostUp = resolvectl dns %i 10.4.0.1 fd69:1337:0:420:f4:f4::1 10.4.0.3 fd69:1337:0:420:f4:f4::3
PostUp = resolvectl domain %i gf4
PostUp = iptables -A FORWARD -i gf4 -o gf4 -j ACCEPT
PostUp = iptables -A FORWARD -i gf4 -j ACCEPT
PostUp = iptables -A FORWARD -o gf4 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
PostUp = ip6tables -A FORWARD -i gf4 -o gf4 -j ACCEPT
PostUp = ip6tables -A FORWARD -i gf4 -j ACCEPT
PostUp = ip6tables -A FORWARD -o gf4 -j ACCEPT
PostUp = ip6tables -t nat -A POSTROUTING -o ens3 -j MASQUERADE
PostDown = iptables -D FORWARD -i gf4 -o gf4 -j ACCEPT
PostDown = iptables -D FORWARD -i gf4 -j ACCEPT
PostDown = iptables -D FORWARD -o gf4 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o enp3s0 -j MASQUERADE
PostDown = ip6tables -D FORWARD -i gf4 -o gf4 -j ACCEPT
PostDown = ip6tables -D FORWARD -i gf4 -j ACCEPT
PostDown = ip6tables -D FORWARD -o gf4 -j ACCEPT
PostDown = ip6tables -t nat -D POSTROUTING -o enp3s0 -j MASQUERADE
[Peer] # krow.gf4
PublicKey = 6VA79LOmlUaJSD1AiLEMCtnjMRZ7rwRrdbtNSCDtO2k=
PresharedKey = u3ZaKx4ydnGz4NXaccQ91PA6wd8bGrdBzNJIbqCn7Zk=
AllowedIPs = fd69:1337:0:420:f4:f4:0:0/96, 10.4.0.0/16
Endpoint = 85.17.214.157:56333
[Peer] # nginx-ksn.gf4
PublicKey = gJ81HBDqs9SmFf6PqFeoyXkMu6CYDlePGJxD456Nmig=
PresharedKey = FdpV0xKsxIeKWt1Q+uFtfo0RneiSHD1/hOhcNYKufXM=
AllowedIPs = fd69:1337:0:420:f4:f4:0:101/128, 10.4.0.101/32
Endpoint = 172.93.54.60:62194
[Peer] # cfx.chris.gf4
PublicKey = sJ3WF4xThDkuF/JI14XbjbFL38oJU7WF0oEGtZr2bnY=
PresharedKey = G/pI6TQ1JPJfEMhtTxPZ7BGfIopOh9Hz6lGokqF9JI8=
AllowedIPs = fd69:1337:0:420:f4:f4:2:1/128, 10.4.2.1/32
[Peer] # kvr.ki9.gf4
PublicKey = Oxu9igRGQQcsZ40vUnb7YiTu7vVhQ/oQb5jKd6V3JBc=
PresharedKey = hjEjwra1LlbIUAzBUwSt6gWmIc+1tiKIOY+cmcY1Pew=
AllowedIPs = fd69:1337:0:420:f4:f4:1:5/128, 10.4.1.5/32
[Peer] # knr.ki9.gf4
PublicKey = Qd9c2buI39yKZuJDN4r+ShgIUBpoETjvZR9hR+bNvVI=
PresharedKey = l74QRRniTaIjwjtyR0NWC30xH+/0LWPDAI2Fs6YToDo=
AllowedIPs = fd69:1337:0:420:f4:f4:1:6/128, 10.4.1.6/32
[Peer] # kp3.ki9.gf4
PublicKey = Cx1VK1PZddMu1sOv+kdp6GVr6oX4jGqOXF1WnZjnyBc=
PresharedKey = VehQr/QY5lWSZ8UQ17g7ob7DebB0I1VgTfUrUlPnm0Q=
AllowedIPs = fd69:1337:0:420:f4:f4:1:3/128, 10.4.1.3/32
[Peer] # kp4.ki9.gf4
PublicKey = 1JXIwB7yEAQTTbrUtGRmUFq6uKlOG9bsdiiODSIO+V8=
PresharedKey = SD+4d7rX+kNwxsG0567VXxTzRfyl+mXdGqHMATopCGs=
AllowedIPs = fd69:1337:0:420:f4:f4:1:4/128, 10.4.1.4/32
[Peer] # bhp.ki9.gf4
PublicKey = nZcMK7EslQNl8QHZrUpTGXCcPOJhQIMdReK90pQDqnE=
PresharedKey = S8IYZIGjg+rHn4JJT8PI+/bRd2zS26l7BRKFGvCf7RM=
AllowedIPs = fd69:1337:0:420:f4:f4:1:70/128, 10.4.1.70/32
[Peer] # op1.ki9.gf4
PublicKey = rjIcYsJEXtmNCHfC3XHT7txpAqhMY9PXhR/LvHgKDkE=
PresharedKey = 0IfTYf/lBBUWIguEs6q/eYiTAZsafgSW06zGGz8tvgY=
AllowedIPs = fd69:1337:0:420:f4:f4:1:11/128, 10.4.1.11/32
[Peer] # phone.chris.gf4
PublicKey = 9cQQ5lcs6JqCTuLBw/j22olAf5yuZoVfR6jqu9t40xE=
PresharedKey = ItfoABRB/vUBaNJu2XkYzh8IZZC3Sc2XernFNUXMTls=
AllowedIPs = fd69:1337:0:420:f4:f4:2:2/128, 10.4.2.2/32
[Peer] # x230.chris.gf4
PublicKey = B1/UaM8lrydA9TiT9K2PAO9+AO/l6KdhiKKG3Szn+FQ=
PresharedKey = aHgoFAOG9hCtBDPKd1XjltnsEpK9o9AYKsjHJmJTmnk=
AllowedIPs = fd69:1337:0:420:f4:f4:2:3/128, 10.4.2.3/32
[Peer] # cpu.ico.gf4
PublicKey = KW4q9oK635AbopBrHD1pWIe6YMi3aRtWfTk3UO//TBI=
PresharedKey = Ddk24UOBMlVFMe4+xWZ/76y6fKap4n8FT1jJOJr5sMU=
AllowedIPs = fd69:1337:0:420:f4:f4:3:1/128, 10.4.3.1/32
[Peer] # phone.ico.gf4
PublicKey = p6fsL3TmOnGbev7nq5x1UEvZfX0sYt54DwN+MCI8eWU=
PresharedKey = koLI00VX8IZDhEZ4sRloB4+rnG+Z8yxjRKOpwoamrgI=
AllowedIPs = fd69:1337:0:420:f4:f4:3:2/128, 10.4.3.2/32
[Peer] # cpu2.ico.gf4
PublicKey = mI692IzLnqtUVoQ+HwHbNsgBvtd2bB7+u3q4QDwkHgQ=
PresharedKey = ej8MUmKTo0b4+M4YAJXMHj0NDI34Jk40Xom0WjL0RrY=
AllowedIPs = 10.4.3.3/32, fd69:1337:0:420:f4:f4:3:3/128
[Peer] # cpu3.ico.gf4
PublicKey = biVvNHJQsjvGri6TADZcJyNPYSv6VxfQW45nfdOXBBA=
PresharedKey = Bv53eLjb0+zKqyI4cukgUk7ppwNJ+nXY312WJQQRIUk=
AllowedIPs = 10.4.3.4/32, fd69:1337:0:420:f4:f4:3:4/128
[Peer] # laptop.ico.gf4
PublicKey = F6nPbGSfudVRlfnfiNyB2ZZcu0Tw2Zz1i4PbMPw1dhE=
PresharedKey = UWOtprs1xvRwZ9+p8fvLzC301+5GcjyJEBJ24jDPeTs=
AllowedIPs = 10.4.3.5/32, fd69:1337:0:420:f4:f4:3:5/128
[Peer] # phone0.chris.gf4
PublicKey = YmuAGeAXs+0BSsdEiTKlq2mpYTzyK1hzDDTmxINdL1Y=
PresharedKey = 9yg/LHFP/BAHwEQd1fwpU3bonLE3VQzjZ8j3fiNOChs=
AllowedIPs = 10.4.2.5/32, fd69:1337:0:420:f4:f4:2:5/128
[Peer] # dpi.ki9.gf4
PublicKey = /WxektsH9OyOqGgm5baF8adbtKBbO6tm4juCstelTF0=
PresharedKey = +rFuWUer0boUXyA+DhlkGjD2VzX9go1VSnYbUaUygQo=
AllowedIPs = 10.4.1.16/32, fd69:1337:0:420:f4:f4:1:16/128
[Peer] # cpu4.ico.gf4
PublicKey = qhHTXRBodnuzNWyPhZzJjV5hSwDmshbdPI7AMNoIhRA=
PresharedKey = SIfrh5Nb0xAjKbSaoYJuLv+d/c78feOPPOI/WRrLeqI=
AllowedIPs = 10.4.3.6/32, fd69:1337:0:420:f4:f4:3:6/128
[Peer] # macmini.don.gf4
PublicKey = 2mDVjfhmbryoikrAF++9FWWmQi7cDJy7XTmGIqOUtAE=
PresharedKey = p/8p6OsTfydz4OdgoxTVVn5v+IUHbUUiqKal5suULG4=
AllowedIPs = 10.4.5.1/32, fd69:1337:0:420:f4:f4:5:1/128
[Peer] # cpu5.ico.gf4
PublicKey = MKG3VjyYXTq1MIX8bzsdawX+zB3tPTgvXYJPP87pv18=
PresharedKey = fmz3oQ/nPUiwdVKwuYGmtxuW1ztRhvzy/74NZxFP5qQ=
AllowedIPs = 10.4.3.7/32, fd69:1337:0:420:f4:f4:3:7/128
[Peer] # cpu.test.gf4
PublicKey = ys6bQ0C+QsYVja7Piy/3KSObf+dP2wqQTICfPH0C7nw=
PresharedKey = WNnWMeB4d/Zs5GElsqJtSPtfgBI/msPkKaX21ZXLSCw=
AllowedIPs = 10.4.4.1/32, fd69:1337:0:420:f4:f4:4:1/128
[Peer] # kg5.ki9.gf4
PublicKey = C6+34ICDYxnrQz4vpcL3/4kYuwUTcgED9YhdGPwqGDo=
PresharedKey = 6Ia9/Kebauc1OsrHTorom7HsktYbnasRJ/opGwNQ4fc=
AllowedIPs = 10.4.1.9/32, fd69:1337:0:420:f4:f4:1:9/128
[Peer] # ocean.fal.gf4
PublicKey = fePYBPIVz7hKbh4to0iXgHqkJ1UioJ0pA8g0k5gt71Q=
PresharedKey = faP6oyRHVm+J2v+mW6r9JPXOjb1xZr8obnm7LQuPfH4=
AllowedIPs = 10.4.6.1/32, fd69:1337:0:420:f4:f4:6:1/128
[Peer] # wrd.woody.gf4
PublicKey = W/wEIt1AghFFqx5C2yy2isYa400+43HJve/YGsoyZFc=
PresharedKey = ylBsLXYccjsPs5MALAC+EPwiDaVlQ36tRCIEy1hQP4s=
AllowedIPs = 10.4.7.1/32, fd69:1337:0:420:f4:f4:7:1/128
[Peer] # cpu.aaruni.gf4
PublicKey = fy/hRTZF+oyzV21mnDJfZFXamKTyqG1sQol0bDG0RmQ=
PresharedKey = Exma2Np6qxnp6eslViA+OTNRRhp1DmZrIatYKTbfB2I=
AllowedIPs = 10.4.8.1/32, fd69:1337:0:420:f4:f4:8:1/128
[Peer] # cpu6.ico.gf4
PublicKey = EWiKE/wsJOO6T00hZt4hIP1wte2Gi6XTbJ3xwN68WSA=
PresharedKey = z8pAmuRZIpZ+t0Mi7cA0UaxgHo8l7e9/uVB6mOkZ4fU=
AllowedIPs = 10.4.3.8/32, fd69:1337:0:420:f4:f4:3:8/128
[Peer] # cpu7.ico.gf4
PublicKey = Jx6wvtZGPYR68e6Jbn5tTp+FN6md7gww6lU25FATszs=
PresharedKey = 2OfhD2WQ6dXv8cZYJWx2DZcMYU1uPSqJ0X7ipMMymNQ=
AllowedIPs = 10.4.3.9/32, fd69:1337:0:420:f4:f4:3:9/128
[Peer] # ci3.chris.gf4
PublicKey = Vg4McMRsP1gtYtpimLWZjgBLaXoV8UeP6o9s8AVkV24=
PresharedKey = bgDLIN0Mvd4NGhyoqzCm4yjJ1AJmvhexbOK4LmQI6vc=
AllowedIPs = 10.4.2.4/32, fd69:1337:0:420:f4:f4:2:4/128
[Peer] # dha.ki9.gf4
PublicKey = eWKJe9gRanowDwXMBdlvN9P4ORHBIak1jqaD23vfD1k=
PresharedKey = bZa4y7l9UpbfOaVeznpyVcq9/HEp+xV2eNEma4l6JUY=
AllowedIPs = 10.4.1.10/32, fd69:1337:0:420:f4:f4:1:10/128
[Peer] # zeus.ki9.gf4
PublicKey = p1AwQ4URYdWKrHAUa+idkkFosCwCcgPTv3oXvvfd51E=
PresharedKey = kEOxQlpO5HzFqMJ1uStQt62GgDIpost1QxJn/0m0rl8=
AllowedIPs = 10.4.1.2/32, fd69:1337:0:420:f4:f4:1:2/128
[Peer] # kamut.ki9.gf4
PublicKey = m36oh4XyW4gWLOVXl8VdASFtgdI3hHY9ZqxNkbaOiG4=
PresharedKey = MaUCTkbgEWwuA7MAaqra6sFwd/009q3qEijvD97j81M=
AllowedIPs = 10.4.1.1/32, fd69:1337:0:420:f4:f4:1:1/128

View File

@ -1,10 +0,0 @@
[Unit]
Description=Wireguard API
After=network.target
[Service]
WorkingDirectory=/usr/local/lib/wgapi/
ExecStart=/usr/bin/npm run start
[Install]
WantedBy=multi-user.target

View File

@ -1,2 +0,0 @@
[Exec]
NotifyReady=true

927
package-lock.json generated
View File

@ -1,927 +0,0 @@
{
"name": "wgapi",
"version": "1.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "wgapi",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
"axios": "^0.23.0",
"express": "^4.17.1",
"wireguard-tools": "^0.1.0"
}
},
"node_modules/accepts": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
"integrity": "sha1-UxvHJlF6OytB+FACHGzBXqq1B80=",
"dependencies": {
"mime-types": "~2.1.24",
"negotiator": "0.6.2"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"node_modules/axios": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.23.0.tgz",
"integrity": "sha512-NmvAE4i0YAv5cKq8zlDoPd1VLKAqX5oLuZKs8xkJa4qi6RGn0uhCYFjWtHHC9EM/MwOwYWOs53W+V0aqEXq1sg==",
"dependencies": {
"follow-redirects": "^1.14.4"
}
},
"node_modules/body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
"integrity": "sha1-lrJwnlfJxOCab9Zqj9l5hE9p8Io=",
"dependencies": {
"bytes": "3.1.0",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "~1.1.2",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"on-finished": "~2.3.0",
"qs": "6.7.0",
"raw-body": "2.4.0",
"type-is": "~1.6.17"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha1-9s95M6Ng4FiPqf3oVlHNx/gF0fY=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/content-disposition": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
"integrity": "sha1-4TDK9+cnkIfFYWwgB9BIVpiYT70=",
"dependencies": {
"safe-buffer": "5.1.2"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha1-4TjMdeBAxyexlm/l5fjJruJW/js=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
"integrity": "sha1-vrQ35wIrO21JAZ0IhmUwPr6cFLo=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=",
"dependencies": {
"ms": "2.0.0"
}
},
"node_modules/depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/destroy": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
"integrity": "sha1-RJH8OGBc9R+GKdOcK10Cb5ikwTQ=",
"dependencies": {
"accepts": "~1.3.7",
"array-flatten": "1.1.1",
"body-parser": "1.19.0",
"content-disposition": "0.5.3",
"content-type": "~1.0.4",
"cookie": "0.4.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "~1.1.2",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.1.2",
"fresh": "0.5.2",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.5",
"qs": "6.7.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.1.2",
"send": "0.17.1",
"serve-static": "1.14.1",
"setprototypeof": "1.1.1",
"statuses": "~1.5.0",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"engines": {
"node": ">= 0.10.0"
}
},
"node_modules/finalhandler": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
"integrity": "sha1-t+fQAP/RGTjQ/bBTUG9uur6fWH0=",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"statuses": "~1.5.0",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz",
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha1-ImmTZCiq1MFcfr6XeahL8LKoGBE=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/http-errors": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
"integrity": "sha1-T1ApzxMjnzEDblsuVSkrz7zIXI8=",
"dependencies": {
"depd": "~1.1.2",
"inherits": "2.0.3",
"setprototypeof": "1.1.1",
"statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha1-v/OFQ+64mEglB5/zoqjmy9RngbM=",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/lodash.mergewith": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz",
"integrity": "sha1-YXEh+JrFX1kEfHrsHM1mVMZZD1U="
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha1-Ms2eXGRVO9WNGaVor0Uqz/BJgbE=",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/mime-db": {
"version": "1.50.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz",
"integrity": "sha1-q9SslOmNPA4YUBbGerRdX95AwR8=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.33",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz",
"integrity": "sha1-H6EqkERy+v0GjkjZ6EAfdNP3Dts=",
"dependencies": {
"mime-db": "1.50.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha1-/qz3zPUlp3rpY0Q2pkiD/+yjRvs=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
"integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha1-naGee+6NEt/wUT7Vt2lXeTvC6NQ=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha1-8Z/mnOqzEe65S0LnDowgcPm6ECU=",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha1-QdwaAV49WB8WIXdr4xr7KHapsbw=",
"engines": {
"node": ">=0.6"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha1-PPNwI9GZ4cJNGlW4SADC8+ZGgDE=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/raw-body": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
"integrity": "sha1-oc5vucm8NWylLoklarWQWeE9AzI=",
"dependencies": {
"bytes": "3.1.0",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0="
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo="
},
"node_modules/send": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
"integrity": "sha1-wdiwWfeQD3Rm3Uk4vcROEd2zdsg=",
"dependencies": {
"debug": "2.6.9",
"depd": "~1.1.2",
"destroy": "~1.0.4",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "~1.7.2",
"mime": "1.6.0",
"ms": "2.1.1",
"on-finished": "~2.3.0",
"range-parser": "~1.2.1",
"statuses": "~1.5.0"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha1-MKWGTrPrsKZvLr5tcnrwagnYbgo="
},
"node_modules/serve-static": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
"integrity": "sha1-Zm5jbcTwEPfvKZcKiKZ0MgiYsvk=",
"dependencies": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.17.1"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/setprototypeof": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha1-fpWsskqpL1iF4KvvW6ExMw1K5oM="
},
"node_modules/statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha1-fhvjRw8ed5SLxD2Uo8j013UrpVM=",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha1-TlUs0F3wlGfcvE73Od6J8s83wTE=",
"dependencies": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/wireguard-tools": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/wireguard-tools/-/wireguard-tools-0.1.0.tgz",
"integrity": "sha1-bV+Nv5Dp6ffUIqqiSCJNizzmkqM=",
"dependencies": {
"lodash.mergewith": "^4.6.2"
}
}
},
"dependencies": {
"accepts": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
"integrity": "sha1-UxvHJlF6OytB+FACHGzBXqq1B80=",
"requires": {
"mime-types": "~2.1.24",
"negotiator": "0.6.2"
}
},
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"axios": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.23.0.tgz",
"integrity": "sha512-NmvAE4i0YAv5cKq8zlDoPd1VLKAqX5oLuZKs8xkJa4qi6RGn0uhCYFjWtHHC9EM/MwOwYWOs53W+V0aqEXq1sg==",
"requires": {
"follow-redirects": "^1.14.4"
}
},
"body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
"integrity": "sha1-lrJwnlfJxOCab9Zqj9l5hE9p8Io=",
"requires": {
"bytes": "3.1.0",
"content-type": "~1.0.4",
"debug": "2.6.9",
"depd": "~1.1.2",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"on-finished": "~2.3.0",
"qs": "6.7.0",
"raw-body": "2.4.0",
"type-is": "~1.6.17"
}
},
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha1-9s95M6Ng4FiPqf3oVlHNx/gF0fY="
},
"content-disposition": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
"integrity": "sha1-4TDK9+cnkIfFYWwgB9BIVpiYT70=",
"requires": {
"safe-buffer": "5.1.2"
}
},
"content-type": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha1-4TjMdeBAxyexlm/l5fjJruJW/js="
},
"cookie": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
"integrity": "sha1-vrQ35wIrO21JAZ0IhmUwPr6cFLo="
},
"cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=",
"requires": {
"ms": "2.0.0"
}
},
"depd": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
},
"destroy": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
},
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
},
"express": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
"integrity": "sha1-RJH8OGBc9R+GKdOcK10Cb5ikwTQ=",
"requires": {
"accepts": "~1.3.7",
"array-flatten": "1.1.1",
"body-parser": "1.19.0",
"content-disposition": "0.5.3",
"content-type": "~1.0.4",
"cookie": "0.4.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "~1.1.2",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"finalhandler": "~1.1.2",
"fresh": "0.5.2",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.5",
"qs": "6.7.0",
"range-parser": "~1.2.1",
"safe-buffer": "5.1.2",
"send": "0.17.1",
"serve-static": "1.14.1",
"setprototypeof": "1.1.1",
"statuses": "~1.5.0",
"type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
}
},
"finalhandler": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
"integrity": "sha1-t+fQAP/RGTjQ/bBTUG9uur6fWH0=",
"requires": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "~2.3.0",
"parseurl": "~1.3.3",
"statuses": "~1.5.0",
"unpipe": "~1.0.0"
}
},
"follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz",
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA=="
},
"forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha1-ImmTZCiq1MFcfr6XeahL8LKoGBE="
},
"fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"http-errors": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
"integrity": "sha1-T1ApzxMjnzEDblsuVSkrz7zIXI8=",
"requires": {
"depd": "~1.1.2",
"inherits": "2.0.3",
"setprototypeof": "1.1.1",
"statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0"
}
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha1-ICK0sl+93CHS9SSXSkdKr+czkIs=",
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha1-v/OFQ+64mEglB5/zoqjmy9RngbM="
},
"lodash.mergewith": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz",
"integrity": "sha1-YXEh+JrFX1kEfHrsHM1mVMZZD1U="
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
"integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
},
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha1-Ms2eXGRVO9WNGaVor0Uqz/BJgbE="
},
"mime-db": {
"version": "1.50.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz",
"integrity": "sha1-q9SslOmNPA4YUBbGerRdX95AwR8="
},
"mime-types": {
"version": "2.1.33",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz",
"integrity": "sha1-H6EqkERy+v0GjkjZ6EAfdNP3Dts=",
"requires": {
"mime-db": "1.50.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha1-/qz3zPUlp3rpY0Q2pkiD/+yjRvs="
},
"on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
"integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
"requires": {
"ee-first": "1.1.1"
}
},
"parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha1-naGee+6NEt/wUT7Vt2lXeTvC6NQ="
},
"path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha1-8Z/mnOqzEe65S0LnDowgcPm6ECU=",
"requires": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
}
},
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha1-QdwaAV49WB8WIXdr4xr7KHapsbw="
},
"range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha1-PPNwI9GZ4cJNGlW4SADC8+ZGgDE="
},
"raw-body": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
"integrity": "sha1-oc5vucm8NWylLoklarWQWeE9AzI=",
"requires": {
"bytes": "3.1.0",
"http-errors": "1.7.2",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0="
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo="
},
"send": {
"version": "0.17.1",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
"integrity": "sha1-wdiwWfeQD3Rm3Uk4vcROEd2zdsg=",
"requires": {
"debug": "2.6.9",
"depd": "~1.1.2",
"destroy": "~1.0.4",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
"fresh": "0.5.2",
"http-errors": "~1.7.2",
"mime": "1.6.0",
"ms": "2.1.1",
"on-finished": "~2.3.0",
"range-parser": "~1.2.1",
"statuses": "~1.5.0"
},
"dependencies": {
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha1-MKWGTrPrsKZvLr5tcnrwagnYbgo="
}
}
},
"serve-static": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
"integrity": "sha1-Zm5jbcTwEPfvKZcKiKZ0MgiYsvk=",
"requires": {
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"parseurl": "~1.3.3",
"send": "0.17.1"
}
},
"setprototypeof": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha1-fpWsskqpL1iF4KvvW6ExMw1K5oM="
},
"statuses": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
},
"toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha1-fhvjRw8ed5SLxD2Uo8j013UrpVM="
},
"type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
"integrity": "sha1-TlUs0F3wlGfcvE73Od6J8s83wTE=",
"requires": {
"media-typer": "0.3.0",
"mime-types": "~2.1.24"
}
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
},
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
},
"wireguard-tools": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/wireguard-tools/-/wireguard-tools-0.1.0.tgz",
"integrity": "sha1-bV+Nv5Dp6ffUIqqiSCJNizzmkqM=",
"requires": {
"lodash.mergewith": "^4.6.2"
}
}
}
}

View File

@ -1,17 +0,0 @@
{
"name": "wgapi",
"version": "1.1.1",
"description": "HTTP API to add and remove wireguard configs",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Keith Irwin <ki9@gf4.pw> (ki9.gf4.pw)",
"license": "MIT",
"dependencies": {
"axios": "^0.23.0",
"express": "^4.17.1",
"wireguard-tools": "^0.1.0"
}
}

View File

@ -1,10 +0,0 @@
[Unit]
Description=Restart a wireguard service
After=wg-quick@%i.service
[Service]
Type=oneshot
ExecStart=systemctl restart wg-quick@%i
[Install]
WantedBy=multi-user.target

View File

@ -1,10 +0,0 @@
[Unit]
Description=Restart wg-quick@%i every 10 minutes
After=wg-quick@%i.service
[Timer]
OnCalendar=*:0/10
Unit=restart-wg-quick@%i.service
[Install]
WantedBy=timers.target