Compare commits
25 Commits
v0.10.0
...
994db90ecc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
994db90ecc | ||
|
|
3e7d34a92a | ||
|
|
4d2aa5c8c7 | ||
|
|
6856727985 | ||
|
|
991fcffa68 | ||
|
|
2b4cbae49c | ||
|
|
0902341322 | ||
|
|
ab2837817d | ||
|
|
82a6d47bc9 | ||
|
|
cd2ec23ccb | ||
|
|
f89f5d5083 | ||
|
|
db78964033 | ||
|
|
bb28b8f340 | ||
|
|
a205f3acef | ||
|
|
8bf30b345b | ||
|
|
b0ff07aad6 | ||
|
|
96e7916721 | ||
|
|
3877ec5f35 | ||
|
|
747d73890f | ||
|
|
e9dffee2de | ||
|
|
b8344a20b9 | ||
|
|
cad200b9cc | ||
|
|
199f774ed3 | ||
|
|
b972784d90 | ||
|
|
8b2c9709fc |
12
README.md
12
README.md
@@ -1,5 +1,11 @@
|
|||||||
# vppn: Virtual Potentially Private Network
|
# vppn: Virtual Potentially Private Network
|
||||||
|
|
||||||
|
## TO DO
|
||||||
|
|
||||||
|
* peer - write status to file instead of using sockets
|
||||||
|
* peer - improve relay selection
|
||||||
|
* Double buffering in IFReader and ConnReader ?
|
||||||
|
|
||||||
## Hub Server Configuration
|
## Hub Server Configuration
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -53,17 +59,15 @@ Sign-in and configure.
|
|||||||
|
|
||||||
Install the binary somewhere, for example `~/bin/vppn`.
|
Install the binary somewhere, for example `~/bin/vppn`.
|
||||||
|
|
||||||
Add the API key for your network name in `~/.vppn/<netname>/apikey`.
|
|
||||||
|
|
||||||
Create systemd file in `/etc/systemd/system/vppn.service`.
|
Create systemd file in `/etc/systemd/system/vppn.service`.
|
||||||
|
|
||||||
```
|
```
|
||||||
[Service]
|
[Service]
|
||||||
AmbientCapabilities=AP_NET_ADMIN CAP_DAC_OVERRIDE CAP_CHOWN
|
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_ADMIN
|
||||||
Type=simple
|
Type=simple
|
||||||
User=user
|
User=user
|
||||||
WorkingDirectory=/home/user/
|
WorkingDirectory=/home/user/
|
||||||
ExecStart=/home/user/bin/vppn -name my_net_name -hub https://my.hub
|
ExecStart=/home/user/vppn run my_net_name https://my.hub my_api_key
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=8
|
RestartSec=8
|
||||||
TimeoutStopSec=24
|
TimeoutStopSec=24
|
||||||
|
|||||||
@@ -11,3 +11,9 @@ func Peer_GetByAPIKey(tx TX, apiKey string) (*Peer, error) {
|
|||||||
Peer_SelectQuery+` WHERE APIKey=?`,
|
Peer_SelectQuery+` WHERE APIKey=?`,
|
||||||
apiKey)
|
apiKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Peer_Exists(tx TX, networkID int64, ip byte) (exists bool, err error) {
|
||||||
|
const query = `SELECT EXISTS(SELECT 1 FROM peers WHERE NetworkID=? AND PeerIP=?)`
|
||||||
|
err = tx.QueryRow(query, networkID, ip).Scan(&exists)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package hub
|
package hub
|
||||||
|
|
||||||
const (
|
const (
|
||||||
sessionIDCookieName = "SessionID"
|
SESSION_ID_COOKIE_NAME = "SessionID"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type handlerFunc func(s *api.Session, w http.ResponseWriter, r *http.Request) er
|
|||||||
|
|
||||||
func (app *App) handlePub(pattern string, fn handlerFunc) {
|
func (app *App) handlePub(pattern string, fn handlerFunc) {
|
||||||
wrapped := func(w http.ResponseWriter, r *http.Request) {
|
wrapped := func(w http.ResponseWriter, r *http.Request) {
|
||||||
sessionID := app.getCookie(r, sessionIDCookieName)
|
sessionID := app.getCookie(r, SESSION_ID_COOKIE_NAME)
|
||||||
s, err := app.api.Session_Get(sessionID)
|
s, err := app.api.Session_Get(sessionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to get session: %v", err)
|
log.Printf("Failed to get session: %v", err)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func (a *App) _signinSubmit(s *api.Session, w http.ResponseWriter, r *http.Reque
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
a.setCookie(w, sessionIDCookieName, sess.SessionID)
|
a.setCookie(w, SESSION_ID_COOKIE_NAME, sess.SessionID)
|
||||||
|
|
||||||
return a.redirect(w, r, "/")
|
return a.redirect(w, r, "/")
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ func (a *App) _adminSignOutSubmit(s *api.Session, w http.ResponseWriter, r *http
|
|||||||
if err := a.api.Session_Delete(s.SessionID); err != nil {
|
if err := a.api.Session_Delete(s.SessionID); err != nil {
|
||||||
log.Printf("Failed to delete session cookie %s: %v", s.SessionID, err)
|
log.Printf("Failed to delete session cookie %s: %v", s.SessionID, err)
|
||||||
}
|
}
|
||||||
a.deleteCookie(w, sessionIDCookieName)
|
a.deleteCookie(w, SESSION_ID_COOKIE_NAME)
|
||||||
return a.redirect(w, r, "/")
|
return a.redirect(w, r, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,12 +57,7 @@ func (a *App) devSetRelay(p *Peer, endpoint netip.AddrPort) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) devPromote(p *Peer) {
|
func (a *App) devPromote(p *Peer) {
|
||||||
ep := p.WGEndpoint()
|
log.Printf("PROMOTED: %s - %s @ %s", p.Name, p.VPNIP.String(), p.WGEndpoint().String())
|
||||||
if ep.IsValid() {
|
|
||||||
log.Printf("PROMOTED: %s - %s @ %s", p.Name, p.VPNIP.String(), p.WGEndpoint().String())
|
|
||||||
} else {
|
|
||||||
log.Printf("PROMOTED: %s - %s (no IP)", p.Name, p.VPNIP.String())
|
|
||||||
}
|
|
||||||
devRetry(p.VPNIP, "Promote", func() error { return a.dev.Promote(p.PubKey(), p.VPNIP) })
|
devRetry(p.VPNIP, "Promote", func() error { return a.dev.Promote(p.PubKey(), p.VPNIP) })
|
||||||
p.State = StateDirect
|
p.State = StateDirect
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user