Update for Pritunl v1.30.3108.50

This commit is contained in:
Simon Beginn
2022-03-18 23:47:31 +01:00
parent 0e7ab6900b
commit abb00d3b74
9 changed files with 125 additions and 102 deletions

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:280be8e934ce996ccaca169429463d81a2450ad20769330f7ae520714ec2a895
size 5053764

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2fc70b1940bbb57bd1f344d9fe7fe2a03237e6f403cb9e35ce19129193372f18
size 5095046

100
server/setup.py Normal file
View File

@@ -0,0 +1,100 @@
#!/usr/lib/python3
import os
import glob
import time
import base64
import argparse
originalApiServer = 'app.pritunl.com'
originalAuthServer = 'auth.pritunl.com'
newApiServer = 'pritunl-api.simonmicro.de'
searchIn = [*glob.glob('/usr/lib/python3*'), '/usr/lib/pritunl/', '/usr/share/pritunl/www/', '/usr/lib/pritunl/', '/usr/share/pritunl/www/']
print(" ____ _ _ _ _____ _ _ ____ ___ ")
print(" | _ \ _ __(_) |_ _ _ _ __ | | | ___|_ _| | _____ / \ | _ \_ _|")
print(" | |_) | '__| | __| | | | '_ \| | | |_ / _` | |/ / _ \ / _ \ | |_) | | ")
print(" | __/| | | | |_| |_| | | | | | | _| (_| | < __/ / ___ \| __/| | ")
print(" |_| |_| |_|\__|\__,_|_| |_|_| |_| \__,_|_|\_\___| /_/ \_\_| |___|")
print(" ")
sel = None
interactive = True
parser = argparse.ArgumentParser()
parser.add_argument('--install', type=str, default='DEFAULT', nargs='?', help='Do not ask and install new API endpoint.')
parser.add_argument('--reset', type=str, default='DEFAULT', nargs='?', help='Do not ask and remove new API endpoint.')
args = parser.parse_args()
if args.install != 'DEFAULT':
interactive = False
newApiServer = args.install if args.install is not None else newApiServer
sel = 'I'
if args.reset != 'DEFAULT':
interactive = False
newApiServer = args.reset if args.reset is not None else newApiServer
sel = 'R'
if interactive:
while sel not in ['I', 'U', 'B', 'Q']:
sel = input('[I]nstall, [R]eset, [B]uy Pritunl, [Q]uit? ').upper()
print()
def doTheReplace(fromApiStr, toApiStr, fromAuthStr, toAuthStr):
print(f'Okay. We will change "{fromApiStr}" to "{toApiStr}" and "{fromAuthStr}" to "{toAuthStr}" now...')
numFiles = 0
for i in range(len(searchIn)):
print(f'[{i+1}/{len(searchIn)}] Replacing in {searchIn[i]}...')
for p, d, f in os.walk(searchIn[i]):
for ff in f:
try:
fh = open(os.path.join(p, ff), 'r')
lines = fh.read()
fh.close()
newLines = lines.replace(fromApiStr, toApiStr)
newLines = newLines.replace(fromAuthStr, toAuthStr)
# Special case for changes from c1772d9b3268f91de409ad552e3d4d54d5ae1125
newLines = newLines.replace(base64.b64encode(f'https://{fromApiStr}/subscription'.encode()).decode(), base64.b64encode(f'https://{toApiStr}/subscription'.encode()).decode())
if newLines != lines:
numFiles += 1
fh = open(os.path.join(p, ff), 'w')
fh.writelines(newLines)
fh.close()
except UnicodeDecodeError:
# Brrr - binary files...
pass
print(f'Modified {numFiles} files in {len(searchIn)} paths.')
if sel == 'I':
if interactive:
print(f'By default, the Pritunl API endpoint is hosted at "{originalApiServer}".')
print(f'In case you want to use your own instance, you also have to support HTTPS!')
print(f'Note, that the SSO implementation of Pritunl is hosted at their servers (closed source) and will just be "disabled".')
ownApiServer = input(f'Please enter the new API endpoint [{newApiServer}]: ')
if ownApiServer == '':
ownApiServer = newApiServer
else:
ownApiServer = newApiServer
doTheReplace(originalApiServer, ownApiServer, originalAuthServer, ownApiServer + '/auth/')
print('Please make sure to restart the Pritunl daemon now and please support the developer.')
elif sel == 'R':
if interactive:
print(f'To properly revert any changes to your Pritunl server, this script must exactly know what (custom) API endpoint you have choosen.')
ownApiServer = input(f'Please enter the current API endpoint [{newApiServer}]: ')
if ownApiServer == '':
ownApiServer = newApiServer
print('Make sure to REMOVE ANY FAKED SUBSCRIPTION KEY (by not entering an other command - just remove them). You have now 30 seconds time to hit CTRL+C and do this.')
time.sleep(30)
else:
ownApiServer = newApiServer
doTheReplace(ownApiServer, originalApiServer, ownApiServer + '/auth/', originalAuthServer)
print('Please make sure to restart the Pritunl daemon now.')
elif sel == 'B':
print('Sure thing, buddy... Why did you try to use this?')
print('Visit https://pritunl.com/ for you own license!')
try:
import webbrowser
webbrowser.open('https://pritunl.com/')
print('Let me help you...')
except:
pass
elif sel == 'Q':
print('Bye!')

View File

@@ -1,69 +0,0 @@
ORIG_API_SERVER='app.pritunl.com'
ORIG_AUTH_SERVER='auth.pritunl.com'
if hash dialog 2>/dev/null; then
echo "Dialog found..."
else
echo "Error: Package 'dialog' missing!"
exit 1
fi
if hash find 2>/dev/null; then
echo "Find found..."
else
echo "Error: Package 'find' missing!"
exit 1
fi
if hash sed 2>/dev/null; then
echo "Sed found..."
else
echo "Error: Package 'sed' missing!"
exit 1
fi
winX=80
winY=8
choices=$(dialog --menu "What can I do for you?" 0 $winX 0 "Change" "Changes the API endpoint to your choice" "Reset" "Changes the API endpoint back to $ORIG_API_SERVER" 2>&1 >/dev/tty)
ORIG_API_SERVER_ESCAPED=$(echo "$ORIG_API_SERVER" | sed -e 's/\./\\./g')
ORIG_AUTH_SERVER_ESCAPED=$(echo "$ORIG_AUTH_SERVER" | sed -e 's/\./\\./g')
get_fake_api() {
FAKE_API_SERVER=$(dialog --title "Fake API address" --inputbox "Please enter the address from your faked API (with a valid HTTPS certificate). If you don't have one yourself, just leave the default." $winY $winX 'pritunl-api.simonmicro.de' 2>&1 >/dev/tty)
FAKE_API_SERVER_ESCAPED=$(echo "$FAKE_API_SERVER" | sed -e 's/\./\\./g')
FAKE_AUTH_SERVER="$FAKE_API_SERVER\/auth\/"
FAKE_AUTH_SERVER_ESCAPED=$(echo "$FAKE_AUTH_SERVER" | sed -e 's/\./\\./g')
echo "Please wait, while this script is modifying all necessary parts of the server. This can take up to several minutes..."
}
show_info() {
dialog --msgbox "$1" $winY $winX
}
set -e
for choice in $choices
do
case $choice in
Change)
get_fake_api
find /usr/lib/pritunl/ -type f -print0 | xargs -0 sed -i "s/$ORIG_API_SERVER_ESCAPED/$FAKE_API_SERVER_ESCAPED/g"
find /usr/share/pritunl/www/ -type f -print0 | xargs -0 sed -i "s/$ORIG_API_SERVER_ESCAPED/$FAKE_API_SERVER_ESCAPED/g"
find /usr/lib/pritunl/ -type f -print0 | xargs -0 sed -i "s/$ORIG_AUTH_SERVER_ESCAPED/$FAKE_AUTH_SERVER_ESCAPED/g"
find /usr/share/pritunl/www/ -type f -print0 | xargs -0 sed -i "s/$ORIG_AUTH_SERVER_ESCAPED/$FAKE_AUTH_SERVER_ESCAPED/g"
sleep 4
show_info "Changed $ORIG_API_SERVER to $FAKE_API_SERVER (and blocked any SSO server). Please make sure to restart the pritunl daemon now."
;;
Reset)
echo "Make sure to REMOVE ANY FAKED SUBSCRIPTION KEY (not by entering an other command - just remove them). You have now 30 seconds time to hit CTRL+C and do this."
sleep 30
get_fake_api
find /usr/lib/pritunl/ -type f -print0 | xargs -0 sed -i "s/$FAKE_API_SERVER_ESCAPED/$ORIG_API_SERVER_ESCAPED/g"
find /usr/share/pritunl/www/ -type f -print0 | xargs -0 sed -i "s/$FAKE_API_SERVER_ESCAPED/$ORIG_API_SERVER_ESCAPED/g"
find /usr/lib/pritunl/ -type f -print0 | xargs -0 sed -i "s/$FAKE_AUTH_SERVER_ESCAPED/$ORIG_AUTH_SERVER_ESCAPED/g"
find /usr/share/pritunl/www/ -type f -print0 | xargs -0 sed -i "s/$FAKE_AUTH_SERVER_ESCAPED/$ORIG_AUTH_SERVER_ESCAPED/g"
sleep 4
show_info "Changed $FAKE_API_SERVER to $ORIG_API_SERVER (and unblocked SSO features). Please make sure to restart the pritunl daemon now."
;;
esac
done
exit 0