Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
Total 1 files
■ ■ ■ ■ ■ ■
synergy_httpx.py
skipped 4 lines
5
5
6
6
from http.server import HTTPServer, BaseHTTPRequestHandler
7
7
import ssl, sys, base64, re, os, argparse
8
+
import netifaces as ni
8
9
from warnings import filterwarnings
9
10
from datetime import date, datetime
10
11
from urllib.parse import unquote, urlparse
skipped 39 lines
50
51
GET_REQ = f'[{BLUE}GET-request{END}]'
51
52
META = '[\001\033[38;5;93m\002M\001\033[38;5;129m\002e\001\033[38;5;165m\002t\001\033[38;5;201m\002a\001\033[0m\002]'
52
53
54
+
# Check interface
55
+
def get_ip_from_iface(iface):
56
+
try:
57
+
# Check if valid interface
58
+
ip = ni.ifaddresses(iface)[ni.AF_INET][0]['addr']
59
+
return ip
53
60
61
+
except:
62
+
return False
63
+
64
+
65
+
def debug(msg):
66
+
print(f'{DBG} {msg}{END}')
67
+
68
+
69
+
# Parse arguments
54
70
parser = argparse.ArgumentParser()
55
71
parser.add_argument("-c", "--cert", action="store", help = "Your certificate.")
56
72
parser.add_argument("-k", "--key", action="store", help = "The private key for your certificate. ")
57
73
parser.add_argument("-p", "--port", action="store", help = "Server port.", type = int)
58
74
parser.add_argument("-q", "--quiet", action="store_true", help = "Do not print the banner on startup.")
75
+
parser.add_argument("-i", "--interface", action="store", help = "Supply an interface to adjust the server URLs automatically to the corresponding IP address. If omitted, your public IP will be used instead.", type = str)