updating configuration
This commit is contained in:
@@ -13,3 +13,8 @@ services:
|
||||
restart: always
|
||||
volumes:
|
||||
- ./openvpn/settings/conf:/etc/openvpn
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "5"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
daemon
|
||||
|
||||
nserver 10.2.67.10
|
||||
|
||||
auth none
|
||||
log
|
||||
proxy -p9080
|
||||
|
||||
@@ -30,6 +30,7 @@ RUN set -ex \
|
||||
RUN apk update && apk add python3 curl && pip3 install pyotp
|
||||
ADD run.sh /run.sh
|
||||
ADD generate.py /generate.py
|
||||
ADD nserver.py /nserver.py
|
||||
ADD 3pr.cfg /3pr.cfg
|
||||
RUN chmod +x /run.sh
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@ user = os.getenv('USERNAME')
|
||||
password = os.getenv('PASSWORD')
|
||||
secret = os.getenv('SECRET')
|
||||
|
||||
if user == "":
|
||||
if user == None:
|
||||
print("USERNAME not specified")
|
||||
os.exit(-1)
|
||||
os._exit(-1)
|
||||
|
||||
if password == "":
|
||||
if password == None:
|
||||
print("PASSWORD not specified")
|
||||
os.exit(-1)
|
||||
os._exit(-1)
|
||||
|
||||
if secret == "":
|
||||
if secret == None:
|
||||
print("SECRET not specified")
|
||||
os.exit(-1)
|
||||
os._exit(-1)
|
||||
|
||||
totp = pyotp.TOTP(secret)
|
||||
token = totp.now()
|
||||
@@ -25,4 +25,4 @@ f.write("{}\n".format(user))
|
||||
f.write('{}{}\n'.format(password, token))
|
||||
f.close()
|
||||
|
||||
print("Generated OTP token for user ({}): {}".format(user,token))
|
||||
print("Generated OTP token for user ({}): {}".format(user,token))
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
nameserver = os.getenv('NAMESERVER')
|
||||
if nameserver == None:
|
||||
print("NAMESERVER not specified, skipping proxy configuration")
|
||||
os._exit(-1)
|
||||
|
||||
filename = "/3pr.cfg"
|
||||
|
||||
with open(filename, 'r') as file :
|
||||
filedata = file.read()
|
||||
|
||||
if 'nserver' in filedata:
|
||||
filedata = re.sub(r'nserver .*', 'nserver {}'.format(nameserver), filedata)
|
||||
else:
|
||||
filedata = filedata.replace('daemon', 'daemon\nnserver {}'.format(nameserver))
|
||||
|
||||
with open(filename, 'w') as file:
|
||||
file.write(filedata)
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
python3 /nserver.py
|
||||
3proxy /3pr.cfg
|
||||
python3 /generate.py
|
||||
openvpn --config /etc/openvpn/client.ovpn --auth-user-pass /auth.txt
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
USERNAME=xxxxxxxxx
|
||||
PASSWORD=xxxxxxxxx
|
||||
SECRET=xxxxxxxxx
|
||||
NAMESERVER=xxxxxxxxx
|
||||
|
||||
Reference in New Issue
Block a user