Browse Source

Add optional option to anonymise logs (remove IP addresses)

master
Johann Bauer 8 years ago
parent
commit
d45321927e
  1. 1
      samples/scripts/NOTES
  2. 1
      server/env.py
  3. 12
      server/protocol.py

1
samples/scripts/NOTES

@ -33,6 +33,7 @@ RPC_PORT - Listen on this port for local RPC connections, defaults to
BANNER_FILE - a path to a banner file to serve to clients. The banner file
is re-read for each new client.
DONATION_ADDRESS - server donation address. Defaults to none.
ANON_LOGS - set to remove IP addresses from logs. Default: disabled
If you want IRC connectivity to advertise your node:

1
server/env.py

@ -40,6 +40,7 @@ class Env(LoggedClass):
self.rpc_port = self.integer('RPC_PORT', 8000)
self.max_subscriptions = self.integer('MAX_SUBSCRIPTIONS', 10000)
self.banner_file = self.default('BANNER_FILE', None)
self.anon_logs = self.default('ANON_LOGS', False)
# The electrum client takes the empty string as unspecified
self.donation_address = self.default('DONATION_ADDRESS', '')
self.db_engine = self.default('DB_ENGINE', 'leveldb')

12
server/protocol.py

@ -202,7 +202,7 @@ class Session(JSONRPC):
def connection_made(self, transport):
'''Handle an incoming client connection.'''
super().connection_made(transport)
self.logger.info('connection from {}'.format(self.peername()))
self.logger.info('connection from {}'.format(self.peername(True)))
self.manager.add_session(self)
def connection_lost(self, exc):
@ -211,7 +211,7 @@ class Session(JSONRPC):
if self.error_count or self.send_size >= 250000:
self.logger.info('{} disconnected. '
'Sent {:,d} bytes in {:,d} messages {:,d} errors'
.format(self.peername(), self.send_size,
.format(self.peername(True), self.send_size,
self.send_count, self.error_count))
self.manager.remove_session(self)
@ -223,8 +223,12 @@ class Session(JSONRPC):
'''Queue the request for asynchronous handling.'''
self.manager.add_task(self, self.handle_json_request(request))
def peername(self):
info = self.peer_info
def peername(self, for_log=False):
# Anonymi{z, s}e all IP addresses that will be stored in a log
if for_log and self.env.anon_logs and self.peer_info:
info = ["XX.XX.XX.XX", "XX"]
else:
info = self.peer_info
return 'unknown' if not info else '{}:{}'.format(info[0], info[1])
def tx_hash_from_param(self, param):

Loading…
Cancel
Save