mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
logging
This commit is contained in:
parent
c9e4de3346
commit
d29f0c066c
|
@ -34,6 +34,7 @@ class HttpCli(object):
|
||||||
self.auth = conn.auth
|
self.auth = conn.auth
|
||||||
self.log_func = conn.log_func
|
self.log_func = conn.log_func
|
||||||
self.log_src = conn.log_src
|
self.log_src = conn.log_src
|
||||||
|
self.tls = hasattr(self.s, "cipher")
|
||||||
|
|
||||||
self.bufsz = 1024 * 32
|
self.bufsz = 1024 * 32
|
||||||
self.absolute_urls = False
|
self.absolute_urls = False
|
||||||
|
@ -134,16 +135,6 @@ class HttpCli(object):
|
||||||
uparam["raw"] = True
|
uparam["raw"] = True
|
||||||
uparam["dots"] = True
|
uparam["dots"] = True
|
||||||
|
|
||||||
if hasattr(self.s, "cipher"):
|
|
||||||
self.ssl_suf = "".join(
|
|
||||||
[
|
|
||||||
" \033[3{}m{}".format(c, s)
|
|
||||||
for c, s in zip([6, 3, 6], self.s.cipher())
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.ssl_suf = ""
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self.mode in ["GET", "HEAD"]:
|
if self.mode in ["GET", "HEAD"]:
|
||||||
return self.handle_get() and self.keepalive
|
return self.handle_get() and self.keepalive
|
||||||
|
@ -221,7 +212,7 @@ class HttpCli(object):
|
||||||
|
|
||||||
logmsg += " [\033[36m" + rval + "\033[0m]"
|
logmsg += " [\033[36m" + rval + "\033[0m]"
|
||||||
|
|
||||||
self.log(logmsg + self.ssl_suf)
|
self.log(logmsg)
|
||||||
|
|
||||||
# "embedded" resources
|
# "embedded" resources
|
||||||
if self.vpath.startswith(".cpr"):
|
if self.vpath.startswith(".cpr"):
|
||||||
|
@ -255,7 +246,7 @@ class HttpCli(object):
|
||||||
return self.tx_browser()
|
return self.tx_browser()
|
||||||
|
|
||||||
def handle_options(self):
|
def handle_options(self):
|
||||||
self.log("OPTIONS " + self.req + self.ssl_suf)
|
self.log("OPTIONS " + self.req)
|
||||||
self.send_headers(
|
self.send_headers(
|
||||||
None,
|
None,
|
||||||
204,
|
204,
|
||||||
|
@ -268,7 +259,7 @@ class HttpCli(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def handle_put(self):
|
def handle_put(self):
|
||||||
self.log("PUT " + self.req + self.ssl_suf)
|
self.log("PUT " + self.req)
|
||||||
|
|
||||||
if self.headers.get("expect", "").lower() == "100-continue":
|
if self.headers.get("expect", "").lower() == "100-continue":
|
||||||
try:
|
try:
|
||||||
|
@ -279,7 +270,7 @@ class HttpCli(object):
|
||||||
return self.handle_stash()
|
return self.handle_stash()
|
||||||
|
|
||||||
def handle_post(self):
|
def handle_post(self):
|
||||||
self.log("POST " + self.req + self.ssl_suf)
|
self.log("POST " + self.req)
|
||||||
|
|
||||||
if self.headers.get("expect", "").lower() == "100-continue":
|
if self.headers.get("expect", "").lower() == "100-continue":
|
||||||
try:
|
try:
|
||||||
|
@ -943,7 +934,7 @@ class HttpCli(object):
|
||||||
# 512 kB is optimal for huge files, use 64k
|
# 512 kB is optimal for huge files, use 64k
|
||||||
open_args = [fsenc(fs_path), "rb", 64 * 1024]
|
open_args = [fsenc(fs_path), "rb", 64 * 1024]
|
||||||
use_sendfile = (
|
use_sendfile = (
|
||||||
not self.ssl_suf
|
not self.tls #
|
||||||
and not self.args.no_sendfile
|
and not self.args.no_sendfile
|
||||||
and hasattr(os, "sendfile")
|
and hasattr(os, "sendfile")
|
||||||
)
|
)
|
||||||
|
|
|
@ -141,6 +141,12 @@ class HttpConn(object):
|
||||||
ctx.set_ciphers(self.args.ciphers)
|
ctx.set_ciphers(self.args.ciphers)
|
||||||
|
|
||||||
self.s = ctx.wrap_socket(self.s, server_side=True)
|
self.s = ctx.wrap_socket(self.s, server_side=True)
|
||||||
|
msg = [
|
||||||
|
"\033[1;3{:d}m{}".format(c, s)
|
||||||
|
for c, s in zip([0, 5, 0], self.s.cipher())
|
||||||
|
]
|
||||||
|
self.log(" ".join(msg) + "\033[0m")
|
||||||
|
|
||||||
if self.args.ssl_dbg and hasattr(self.s, "shared_ciphers"):
|
if self.args.ssl_dbg and hasattr(self.s, "shared_ciphers"):
|
||||||
overlap = [y[::-1] for y in self.s.shared_ciphers()]
|
overlap = [y[::-1] for y in self.s.shared_ciphers()]
|
||||||
lines = [str(x) for x in (["TLS cipher overlap:"] + overlap)]
|
lines = [str(x) for x in (["TLS cipher overlap:"] + overlap)]
|
||||||
|
|
|
@ -78,7 +78,7 @@ class HttpSrv(object):
|
||||||
if not MACOS:
|
if not MACOS:
|
||||||
self.log(
|
self.log(
|
||||||
"%s %s" % addr,
|
"%s %s" % addr,
|
||||||
"shut_rdwr err:\n {}\n {}".format(repr(sck), ex),
|
"\033[1;30mshut({}): {}\033[0m".format(sck.fileno(), ex),
|
||||||
)
|
)
|
||||||
if ex.errno not in [10038, 10054, 107, 57, 9]:
|
if ex.errno not in [10038, 10054, 107, 57, 9]:
|
||||||
# 10038 No longer considered a socket
|
# 10038 No longer considered a socket
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
|
@ -531,9 +532,10 @@ class Up2k(object):
|
||||||
while fsz > 0:
|
while fsz > 0:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
td = now - last_print
|
td = now - last_print
|
||||||
if td >= 0.3:
|
if td >= 0.1:
|
||||||
last_print = now
|
last_print = now
|
||||||
print(" {} \n\033[A".format(fsz), end="")
|
msg = " {} MB \r".format(int(fsz / 1024 / 1024))
|
||||||
|
print(msg, end="", file=sys.stderr)
|
||||||
|
|
||||||
hashobj = hashlib.sha512()
|
hashobj = hashlib.sha512()
|
||||||
rem = min(csz, fsz)
|
rem = min(csz, fsz)
|
||||||
|
@ -575,6 +577,7 @@ class Up2k(object):
|
||||||
# self.log("lmod", "got {}".format(len(ready)))
|
# self.log("lmod", "got {}".format(len(ready)))
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
for path, times in ready:
|
for path, times in ready:
|
||||||
|
self.log("lmod", "setting times {} on {}".format(times, path))
|
||||||
try:
|
try:
|
||||||
os.utime(fsenc(path), times)
|
os.utime(fsenc(path), times)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue