some cleanup
This commit is contained in:
parent
ca56b974b8
commit
1942a2bcc7
|
@ -70,6 +70,13 @@ group.add_argument(
|
||||||
help="A directory containing CA files for validating clients",
|
help="A directory containing CA files for validating clients",
|
||||||
metavar="DIR",
|
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 = parser.add_argument_group("fileserver configuration")
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--dir",
|
"--dir",
|
||||||
|
@ -105,13 +112,6 @@ group.add_argument(
|
||||||
default=None,
|
default=None,
|
||||||
dest="rate_limit",
|
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(
|
group.add_argument(
|
||||||
"--markdown",
|
"--markdown",
|
||||||
help="Enable markdown to gemini mode.",
|
help="Enable markdown to gemini mode.",
|
||||||
|
@ -128,6 +128,12 @@ def main() -> None:
|
||||||
app_class = StaticMarkdownDirectoryApplication
|
app_class = StaticMarkdownDirectoryApplication
|
||||||
else:
|
else:
|
||||||
app_class = StaticDirectoryApplication
|
app_class = StaticDirectoryApplication
|
||||||
|
if args.reverse_proxy:
|
||||||
|
server_class = ReverseProxyGeminiServer
|
||||||
|
args.certfile = False
|
||||||
|
args.keyfile = False
|
||||||
|
else:
|
||||||
|
server_class = GeminiServer
|
||||||
app = app_class(
|
app = app_class(
|
||||||
root_directory=args.root_directory,
|
root_directory=args.root_directory,
|
||||||
index_file=args.index_file,
|
index_file=args.index_file,
|
||||||
|
@ -135,15 +141,7 @@ def main() -> None:
|
||||||
default_lang=args.default_lang,
|
default_lang=args.default_lang,
|
||||||
rate_limiter=rate_limiter,
|
rate_limiter=rate_limiter,
|
||||||
)
|
)
|
||||||
if args.reverse_proxy:
|
server = server_class(
|
||||||
server = ReverseProxyGeminiServer(
|
|
||||||
app=app,
|
|
||||||
host=args.host,
|
|
||||||
port=args.port,
|
|
||||||
hostname=args.hostname,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
server = GeminiServer(
|
|
||||||
app=app,
|
app=app,
|
||||||
host=args.host,
|
host=args.host,
|
||||||
port=args.port,
|
port=args.port,
|
||||||
|
|
|
@ -143,7 +143,7 @@ class ReverseProxyGeminiServer(GeminiServer):
|
||||||
endpoint_class = TCP4ServerEndpoint
|
endpoint_class = TCP4ServerEndpoint
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs, certfile=False)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue