better logging
This commit is contained in:
parent
c7ce20a3b9
commit
6eff308468
2 changed files with 9 additions and 10 deletions
|
@ -245,7 +245,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
}
|
}
|
||||||
self.write_response(response_status, content)
|
self.write_response(response_status, content)
|
||||||
return
|
return
|
||||||
logger.debug('NODE action %s %s (%s)', action, args, user_id)
|
logger.debug('%s requests %s%s', user_id, action, args)
|
||||||
if action == 'ping':
|
if action == 'ping':
|
||||||
content = {
|
content = {
|
||||||
'status': 'ok'
|
'status': 'ok'
|
||||||
|
@ -267,9 +267,11 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
self.send_header('Content-Type', 'application/json')
|
self.send_header('Content-Type', 'application/json')
|
||||||
content = json.dumps(content, ensure_ascii=False).encode('utf-8')
|
content = json.dumps(content, ensure_ascii=False).encode('utf-8')
|
||||||
content = self.gzip_data(content)
|
content = self.gzip_data(content)
|
||||||
self.send_header('Content-Length', str(len(content)))
|
content_length = len(content)
|
||||||
|
self.send_header('Content-Length', str(content_length))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(content)
|
self.wfile.write(content)
|
||||||
|
logger.debug('%s bytes response', content_length)
|
||||||
|
|
||||||
def chunk_size(self, content_length):
|
def chunk_size(self, content_length):
|
||||||
return min(16*1024, content_length)
|
return min(16*1024, content_length)
|
||||||
|
|
13
oml/nodes.py
13
oml/nodes.py
|
@ -71,13 +71,12 @@ class Node(Thread):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self):
|
||||||
url = None
|
|
||||||
if self.local:
|
if self.local:
|
||||||
if ':' in self.local:
|
if ':' in self.local:
|
||||||
url = 'https://[%s]:%s' % (self.local, self.port)
|
url = 'https://[%s]:%s' % (self.local, self.port)
|
||||||
else:
|
else:
|
||||||
url = 'https://%s:%s' % (self.local, self.port)
|
url = 'https://%s:%s' % (self.local, self.port)
|
||||||
elif len(self.user_id) == 16:
|
else:
|
||||||
url = 'https://%s.onion:9851' % self.user_id
|
url = 'https://%s.onion:9851' % self.user_id
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
@ -110,14 +109,12 @@ class Node(Thread):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def request(self, action, *args):
|
def request(self, action, *args):
|
||||||
logger.debug('request[%s] %s%s', self.user_id, action, args)
|
|
||||||
self.resolve()
|
self.resolve()
|
||||||
url = self.url
|
url = self.url
|
||||||
if not url:
|
if self.local:
|
||||||
logger.debug('unable to find host %s', self.user_id)
|
logger.debug('request:%s(%s:%s): %s%s', self.user_id, self.local, self.port, action, list(args))
|
||||||
self.online = False
|
else:
|
||||||
return None
|
logger.debug('request:%s: %s%s', self.user_id, action, list(args))
|
||||||
#logger.debug('url=%s', url)
|
|
||||||
content = json.dumps([action, args]).encode()
|
content = json.dumps([action, args]).encode()
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': settings.USER_AGENT,
|
'User-Agent': settings.USER_AGENT,
|
||||||
|
|
Loading…
Reference in a new issue