Fix password encryption
@@ -128,23 +128,26 @@ class Connection(object):
return data
- def send(self, data, timeout=30,
- encrypt=False): # TODO: should timeout be property of IO? We timeout whole connection-observer.
+ # TODO: should timeout be property of IO? We timeout whole connection-observer.
+ def send(self, data, timeout=30, encrypt=False):
"""Outgoing-IO API: Send data over external-IO."""
- self._log_data(msg=data, level=logging.INFO, extra={'transfer_direction': '>'})
+ msg = data
+ if encrypt:
+ length = len(data)
+ msg = "*" * length
+
+ self._log_data(msg=msg, level=logging.INFO, extra={'transfer_direction': '>'})
self._log(level=logging.INFO,
- msg=self._strip_data(data),
+ msg=self._strip_data(msg),
extra={
'transfer_direction': '>',
'log_name': self.name
})
- data2send = self.encode(data)
- msg = data2send
- if encrypt:
- length = len(data2send)
- msg = "*" * length
+
+ encoded_data = self.encode(data)
self._log_data(msg=msg, level=RAW_DATA, extra={'transfer_direction': '>'})
- self.how2send(data2send)
+
+ self.how2send(encoded_data)
def sendline(self, data, timeout=30, encrypt=False):
"""Outgoing-IO API: Send data line over external-IO."""
