106 lines
2.0 KiB
Markdown
106 lines
2.0 KiB
Markdown
# vppn: Virtual Potentially Private Network
|
|
|
|
## TO DO
|
|
|
|
* Double buffering in IFReader and ConnReader ?
|
|
* Replace time-based counter with startup counter
|
|
* 16 byte startupCounter
|
|
* (startupCount << 48) + counter
|
|
* pass startup count to newRoutingTable function (or global?)
|
|
* write / increment on startup
|
|
* Clean up state machine - one class w/
|
|
* type stateFunc func(msg any) stateFunc
|
|
* "init" funcs: func enterDisconnected() stateFunc
|
|
* ~~Idea: Use a bufferSet object to manager buffers. In function calls, buffers
|
|
should get used up, can panic if we run out of buffers to ensure we never
|
|
allocate~~
|
|
* Idea: bufferSize should be large enough to split and use parts of the
|
|
buffer for encryption, etc. Yes.
|
|
|
|
### Peer State Messages
|
|
|
|
* peerUpdateMsg
|
|
* packetInit
|
|
* packetSyn
|
|
* packetAck
|
|
* packetProbe
|
|
* packetLocalDiscovery
|
|
* pingTimerMsg
|
|
|
|
## Hub Server Configuration
|
|
|
|
```
|
|
# Create user.
|
|
adduser user
|
|
|
|
# Enable ssh.
|
|
cp -r ~/.ssh /home/user/
|
|
chown -R user:user /home/user/.ssh
|
|
```
|
|
|
|
Upload `hub` executable:
|
|
|
|
```
|
|
scp hub user@<remote>:~/
|
|
```
|
|
|
|
Create systemd file in `/etc/systemd/system/hub.service
|
|
|
|
```
|
|
[Service]
|
|
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
|
Type=simple
|
|
User=user
|
|
WorkingDirectory=/home/user/
|
|
ExecStart=/home/user/hub -listen <addr>:https -root-dir=/home/user
|
|
Restart=always
|
|
RestartSec=8
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
```
|
|
|
|
Add and start the hub server:
|
|
|
|
```
|
|
systemctl daemon-reload
|
|
systemctl enable hub
|
|
systemctl start hub
|
|
```
|
|
|
|
Get initial password from logs:
|
|
|
|
```
|
|
journalctl -f -u hub -n 100
|
|
```
|
|
|
|
Sign-in and configure.
|
|
|
|
## Peer Configuration
|
|
|
|
Install the binary somewhere, for example `~/bin/vppn`.
|
|
|
|
Create systemd file in `/etc/systemd/system/vppn.service`.
|
|
|
|
```
|
|
[Service]
|
|
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_ADMIN
|
|
Type=simple
|
|
User=user
|
|
WorkingDirectory=/home/user/
|
|
ExecStart=/home/user/vppn -hub-address https://my.hub -api-key 1234567890
|
|
Restart=always
|
|
RestartSec=8
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
Add and start the service:
|
|
|
|
```
|
|
systemctl daemon-reload
|
|
systemctl enable vppn
|
|
systemctl start vppn
|
|
```
|