Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -48,7 +48,7 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
|
|||
# FIXME: request IQ is not send to check available fields,
|
||||
# while XEP recommand to use it
|
||||
# FIXME: doesn't handle data form or oob
|
||||
namespace = 'jabber:client'
|
||||
namespace = "jabber:client"
|
||||
|
||||
def __init__(self, jid_, password, email=None, check_certificate=True):
|
||||
log.debug(_("Registration asked for {jid}").format(jid=jid_))
|
||||
|
|
@ -70,15 +70,25 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
|
|||
tls_required = False
|
||||
configurationForTLS = ssl.CertificateOptions(trustRoot=None)
|
||||
tls_init = xmlstream.TLSInitiatingInitializer(
|
||||
xs, required=tls_required, configurationForTLS=configurationForTLS)
|
||||
xs, required=tls_required, configurationForTLS=configurationForTLS
|
||||
)
|
||||
|
||||
xs.initializers.append(tls_init)
|
||||
|
||||
def register(self, xmlstream):
|
||||
log.debug(_("Stream started with {server}, now registering"
|
||||
.format(server=self.jid.host)))
|
||||
iq = XEP_0077.build_register_iq(self.xmlstream, self.jid, self.password, self.email)
|
||||
d = iq.send(self.jid.host).addCallbacks(self.registration_cb, self.registration_eb)
|
||||
log.debug(
|
||||
_(
|
||||
"Stream started with {server}, now registering".format(
|
||||
server=self.jid.host
|
||||
)
|
||||
)
|
||||
)
|
||||
iq = XEP_0077.build_register_iq(
|
||||
self.xmlstream, self.jid, self.password, self.email
|
||||
)
|
||||
d = iq.send(self.jid.host).addCallbacks(
|
||||
self.registration_cb, self.registration_eb
|
||||
)
|
||||
d.chainDeferred(self.registered)
|
||||
|
||||
def registration_cb(self, answer):
|
||||
|
|
@ -261,10 +271,11 @@ class XEP_0077(object):
|
|||
@param port(int): port of the server to register to
|
||||
"""
|
||||
if host is None:
|
||||
host = self.host.memory.config_get("", "xmpp_domain", "127.0.0.1")
|
||||
host = self.host.memory.config_get("", "xmpp_domain", "127.0.0.1")
|
||||
check_certificate = host != "127.0.0.1"
|
||||
authenticator = RegisteringAuthenticator(
|
||||
jid_, password, email, check_certificate=check_certificate)
|
||||
jid_, password, email, check_certificate=check_certificate
|
||||
)
|
||||
registered_d = authenticator.registered
|
||||
server_register = ServerRegister(authenticator)
|
||||
reactor.connectTCP(host, port, server_register)
|
||||
|
|
@ -288,11 +299,7 @@ class XEP_0077(object):
|
|||
client = self.host.get_client(profile_key)
|
||||
return self.unregister(client, jid.JID(to_jid_s))
|
||||
|
||||
def unregister(
|
||||
self,
|
||||
client: SatXMPPEntity,
|
||||
to_jid: jid.JID
|
||||
) -> defer.Deferred:
|
||||
def unregister(self, client: SatXMPPEntity, to_jid: jid.JID) -> defer.Deferred:
|
||||
"""remove registration from a server/service
|
||||
|
||||
BEWARE! if you remove registration from profile own server, this will
|
||||
|
|
@ -309,4 +316,3 @@ class XEP_0077(object):
|
|||
if not to_jid or to_jid == jid.JID(client.jid.host):
|
||||
d.addCallback(lambda __: client.entity_disconnect())
|
||||
return d
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue