mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
add --https-only
This commit is contained in:
parent
3365b1c355
commit
94521cdc1a
|
@ -205,6 +205,7 @@ def main():
|
|||
ap.add_argument("--no-sendfile", action="store_true", help="disable sendfile")
|
||||
ap.add_argument("--urlform", type=str, default="print,get", help="how to handle url-forms")
|
||||
ap.add_argument("--ssl-ver", type=str, help="ssl/tls versions to allow")
|
||||
ap.add_argument("--https-only", action="store_true", help="disable plaintext")
|
||||
al = ap.parse_args()
|
||||
# fmt: on
|
||||
|
||||
|
|
|
@ -75,9 +75,8 @@ class HttpConn(object):
|
|||
def log(self, msg):
|
||||
self.log_func(self.log_src, msg)
|
||||
|
||||
def run(self):
|
||||
def _detect_https(self):
|
||||
method = None
|
||||
self.sr = None
|
||||
if self.cert_path:
|
||||
try:
|
||||
method = self.s.recv(4, socket.MSG_PEEK)
|
||||
|
@ -102,7 +101,16 @@ class HttpConn(object):
|
|||
self.s.send(b"HTTP/1.1 400 Bad Request\r\n\r\n" + err.encode("utf-8"))
|
||||
return
|
||||
|
||||
if method not in [None, b"GET ", b"HEAD", b"POST", b"PUT ", b"OPTI"]:
|
||||
return method not in [None, b"GET ", b"HEAD", b"POST", b"PUT ", b"OPTI"]
|
||||
|
||||
def run(self):
|
||||
self.sr = None
|
||||
if self.args.https_only:
|
||||
is_https = True
|
||||
else:
|
||||
is_https = self._detect_https()
|
||||
|
||||
if is_https:
|
||||
if self.sr:
|
||||
self.log("\033[1;31mTODO: cannot do https in jython\033[0m")
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue