192
193
self.group.Commit()
193
194
def entry_group_state_changed(self, state, error):
194
195
"""Derived from the Avahi example code"""
195
logger.debug(u"Avahi state change: %i", state)
196
logger.debug(u"Avahi entry group state change: %i", state)
197
198
if state == avahi.ENTRY_GROUP_ESTABLISHED:
198
199
logger.debug(u"Zeroconf service established.")
211
212
self.group = None
212
213
def server_state_changed(self, state):
213
214
"""Derived from the Avahi example code"""
215
logger.debug(u"Avahi server state change: %i", state)
214
216
if state == avahi.SERVER_COLLISION:
215
217
logger.error(u"Zeroconf server name collision")
1006
1008
gnutls.connection
1007
1009
.X509Credentials()))
1009
line = self.request.makefile().readline()
1010
logger.debug(u"Protocol version: %r", line)
1012
if int(line.strip().split()[0]) > 1:
1014
except (ValueError, IndexError, RuntimeError), error:
1015
logger.error(u"Unknown protocol version: %s", error)
1018
1011
# Note: gnutls.connection.X509Credentials is really a
1019
1012
# generic GnuTLS certificate credentials object so long as
1020
1013
# no X.509 keys are added to it. Therefore, we can use it
1032
1025
.gnutls_priority_set_direct(session._c_object,
1033
1026
priority, None))
1028
# Start communication using the Mandos protocol
1029
# Get protocol number
1030
line = self.request.makefile().readline()
1031
logger.debug(u"Protocol version: %r", line)
1033
if int(line.strip().split()[0]) > 1:
1035
except (ValueError, IndexError, RuntimeError), error:
1036
logger.error(u"Unknown protocol version: %s", error)
1039
# Start GnuTLS connection
1036
1041
session.handshake()
1037
1042
except gnutls.errors.GNUTLSError, error:
1057
1062
ipc.write(u"NOTFOUND %s %s\n"
1058
1063
% (fpr, unicode(self.client_address)))
1066
class ClientProxy(object):
1067
"""Client proxy object. Not for calling methods."""
1068
def __init__(self, client):
1069
self.client = client
1070
def __getattr__(self, name):
1071
if name.startswith("ipc_"):
1073
ipc.write("%s %s\n" % (name[4:].upper(),
1076
if not hasattr(self.client, name):
1077
raise AttributeError
1078
ipc.write(u"GETATTR %s %s\n"
1079
% (name, self.client.fingerprint))
1080
return pickle.load(ipc_return)
1081
clientproxy = ClientProxy(client)
1060
1082
# Have to check if client.enabled, since it is
1061
1083
# possible that the client was disabled since the
1062
1084
# GnuTLS session was established.
1063
ipc.write(u"GETATTR enabled %s\n" % fpr)
1064
enabled = pickle.load(ipc_return)
1066
ipc.write(u"DISABLED %s\n" % client.name)
1085
if not clientproxy.enabled:
1086
clientproxy.ipc_disabled()
1068
ipc.write(u"SENDING %s\n" % client.name)
1089
clientproxy.ipc_sending()
1070
1091
while sent_size < len(client.secret):
1071
1092
sent = session.send(client.secret[sent_size:])