some cleanup

This commit is contained in:
waldek 2023-03-06 10:01:15 +11:00
parent ca56b974b8
commit 1942a2bcc7
2 changed files with 15 additions and 17 deletions

View File

@ -70,6 +70,13 @@ group.add_argument(
help="A directory containing CA files for validating clients",
metavar="DIR",
)
group.add_argument(
"--reverse-proxy",
help="Enable reverse proxy mode where TLS is handled by a reverse proxy such as Nginx",
action='store_true',
default=False,
dest="reverse_proxy",
)
group = parser.add_argument_group("fileserver configuration")
group.add_argument(
"--dir",
@ -105,13 +112,6 @@ group.add_argument(
default=None,
dest="rate_limit",
)
group.add_argument(
"--reverse-proxy",
help="Enable reverse proxy mode where TLS is handled by a reverse proxy such as Nginx",
action='store_true',
default=False,
dest="reverse_proxy",
)
group.add_argument(
"--markdown",
help="Enable markdown to gemini mode.",
@ -128,6 +128,12 @@ def main() -> None:
app_class = StaticMarkdownDirectoryApplication
else:
app_class = StaticDirectoryApplication
if args.reverse_proxy:
server_class = ReverseProxyGeminiServer
args.certfile = False
args.keyfile = False
else:
server_class = GeminiServer
app = app_class(
root_directory=args.root_directory,
index_file=args.index_file,
@ -135,15 +141,7 @@ def main() -> None:
default_lang=args.default_lang,
rate_limiter=rate_limiter,
)
if args.reverse_proxy:
server = ReverseProxyGeminiServer(
app=app,
host=args.host,
port=args.port,
hostname=args.hostname,
)
else:
server = GeminiServer(
server = server_class(
app=app,
host=args.host,
port=args.port,

View File

@ -143,7 +143,7 @@ class ReverseProxyGeminiServer(GeminiServer):
endpoint_class = TCP4ServerEndpoint
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs, certfile=False)
super().__init__(*args, **kwargs)
def initialize(self) -> None:
"""