mirror of
https://github.com/flant/ovpn-admin.git
synced 2026-02-04 01:10:22 -08:00
Compare commits
3 Commits
e0b00af49d
...
371ce54ca6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
371ce54ca6 | ||
|
|
39f95e3d2c | ||
|
|
213e1d7b0f |
16
README.md
16
README.md
@ -69,14 +69,14 @@ You can also download and use prebuilt binaries from the [releases](https://gith
|
|||||||
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
* this tool uses external calls for `bash`, `coreutils` and `easy-rsa`, thus **Linux systems only are supported** at the moment.
|
* This tool uses external calls for `bash`, `coreutils` and `easy-rsa`, thus **Linux systems only are supported** at the moment.
|
||||||
* to enable additional password authentication provide `--auth` and `--auth.db="/etc/easyrsa/pki/users.db`" flags and install [openvpn-user](https://github.com/pashcovich/openvpn-user/releases/latest). This tool should be available in your `$PATH` and its binary should be executable (`+x`).
|
* To enable additional password authentication, provide `--auth` and `--auth.db="/etc/easyrsa/pki/users.db`" flags and install [openvpn-user](https://github.com/pashcovich/openvpn-user/releases/latest). This tool should be available in your `$PATH` and its binary should be executable (`+x`).
|
||||||
* master-replica synchronization does not work with `--storage.backend=kubernetes.secrets` - **WIP**
|
* If you use `--ccd` and `--ccd.path="/etc/openvpn/ccd"` and plan to use static address setup for users, do not forget to provide `--ovpn.network="172.16.100.0/24"` with valid openvpn-server network.
|
||||||
* additional password authentication does not work with `--storage.backend=kubernetes.secrets` - **WIP**
|
* If you want to pass all the traffic generated by the user, you need to edit `ovpn-admin/templates/client.conf.tpl` and uncomment `redirect-gateway def1`.
|
||||||
* if you use `--ccd` and `--ccd.path="/etc/openvpn/ccd"` abd plan to use static address setup for users do not forget to provide `--ovpn.network="172.16.100.0/24"` with valid openvpn-server network
|
* Tested with openvpn-server versions 2.4 and 2.5 and with tls-auth mode only.
|
||||||
* tested only with Openvpn-server versions 2.4 and 2.5 with only tls-auth mode
|
* Not tested with Easy-RSA version > 3.0.8.
|
||||||
* not tested with EasyRsa version > 3.0.8
|
* Status of user connections update every 28 seconds.
|
||||||
* status of users connections update every 28 second(*no need to ask why =)*)
|
* Master-replica synchronization and additional password authentication do not work with `--storage.backend=kubernetes.secrets` - **WIP**
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
11
helpers.go
11
helpers.go
@ -288,6 +288,17 @@ func extractFromArchive(archive, path string) error {
|
|||||||
log.Fatalf("extractFromArchive: Mkdir() failed: %s", err.Error())
|
log.Fatalf("extractFromArchive: Mkdir() failed: %s", err.Error())
|
||||||
}
|
}
|
||||||
case tar.TypeReg:
|
case tar.TypeReg:
|
||||||
|
s := strings.Split(header.Name, "/")
|
||||||
|
dir := ""
|
||||||
|
|
||||||
|
for len(s) > 1 {
|
||||||
|
dir, s = dir+"/"+s[0], s[1:]
|
||||||
|
if _, err := os.Stat(path + dir); os.IsNotExist(err) {
|
||||||
|
if err := os.Mkdir(path+dir, 0755); err != nil {
|
||||||
|
log.Fatalf("extractFromArchive: Mkdir() subdir failed: %s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
outFile, err := os.Create(path + "/" + header.Name)
|
outFile, err := os.Create(path + "/" + header.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("extractFromArchive: Create() failed: %s", err.Error())
|
log.Fatalf("extractFromArchive: Create() failed: %s", err.Error())
|
||||||
|
|||||||
19
main.go
19
main.go
@ -9,11 +9,7 @@ import (
|
|||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/client-go/kubernetes"
|
|
||||||
"k8s.io/client-go/rest"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -25,6 +21,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
"k8s.io/client-go/rest"
|
||||||
|
|
||||||
"github.com/gobuffalo/packr/v2"
|
"github.com/gobuffalo/packr/v2"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
@ -520,6 +521,11 @@ func main() {
|
|||||||
ovpnAdmin.mgmtInterfaces[parts[0]] = parts[len(parts)-1]
|
ovpnAdmin.mgmtInterfaces[parts[0]] = parts[len(parts)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ovpnAdmin.role == "slave" {
|
||||||
|
ovpnAdmin.syncDataFromMaster()
|
||||||
|
go ovpnAdmin.syncWithMaster()
|
||||||
|
}
|
||||||
|
|
||||||
ovpnAdmin.mgmtSetTimeFormat()
|
ovpnAdmin.mgmtSetTimeFormat()
|
||||||
|
|
||||||
ovpnAdmin.registerMetrics()
|
ovpnAdmin.registerMetrics()
|
||||||
@ -547,11 +553,6 @@ func main() {
|
|||||||
ovpnAdmin.modules = append(ovpnAdmin.modules, "ccd")
|
ovpnAdmin.modules = append(ovpnAdmin.modules, "ccd")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ovpnAdmin.role == "slave" {
|
|
||||||
ovpnAdmin.syncDataFromMaster()
|
|
||||||
go ovpnAdmin.syncWithMaster()
|
|
||||||
}
|
|
||||||
|
|
||||||
ovpnAdmin.templates = packr.New("template", "./templates")
|
ovpnAdmin.templates = packr.New("template", "./templates")
|
||||||
|
|
||||||
staticBox := packr.New("static", "./frontend/static")
|
staticBox := packr.New("static", "./frontend/static")
|
||||||
|
|||||||
@ -15,7 +15,7 @@ if [ -e "$SERVER_CERT" ]; then
|
|||||||
else
|
else
|
||||||
if [ ${OVPN_ROLE:-"master"} = "slave" ]; then
|
if [ ${OVPN_ROLE:-"master"} = "slave" ]; then
|
||||||
echo "Waiting for initial sync data from master"
|
echo "Waiting for initial sync data from master"
|
||||||
while [ $(wget -q localhost/api/sync/last/try -O - | wc -m) -lt 1 ]
|
while [ $(wget -q localhost:${OVPN_LISTEN_PORT:-8080}/api/sync/last/try -O - | wc -m) -lt 1 ]
|
||||||
do
|
do
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user