Exemple #1
0
 def disco_get_info(self, node, iq):
     to = iq.get_to()
     try:
         network = self.config.get_network(to)
     except KeyError:
         return iq.make_error_response("recipient-unavailable")
     if to.node is None and to.resource is None:
         di = DiscoInfo()
         if node is None:
             di.add_feature("jabber:iq:version")
             di.add_feature("jabber:iq:register")
             di.add_feature(MUC_NS)
             if network.name:
                 name = network.name
             else:
                 name = "IRC gateway"
             DiscoIdentity(di, name, "conference", "irc")
             DiscoIdentity(di, name, "conference", "text")
             DiscoIdentity(di, name, "gateway", "x-irc")
         return di
     elif len(
             to.node) > 1 and to.node[0] in u"&#+!" and to.resource is None:
         di = DiscoInfo()
         di.add_feature(MUC_NS)
         if network.name:
             name = "%s channel on %s IRC network" % (to.node, network.name)
         else:
             name = "%s IRC channel" % (to.node, )
         DiscoIdentity(di, name, "conference", "text")
         DiscoIdentity(di, name, "conference", "irc")
         return di
     return iq.make_error_response("feature-not-implemented")
Exemple #2
0
    def __init__(self,
                 jid=None,
                 password=None,
                 server=None,
                 port=5222,
                 auth_methods=("sasl:DIGEST-MD5", "digest"),
                 tls_settings=None,
                 keepalive=0,
                 disco_name=u"pyxmpp based Jabber client",
                 disco_category=u"client",
                 disco_type=u"pc"):
        """Initialize a JabberClient object.

        :Parameters:
            - `jid`: user full JID for the connection.
            - `password`: user password.
            - `server`: server to use. If not given then address will be derived form the JID.
            - `port`: port number to use. If not given then address will be derived form the JID.
            - `auth_methods`: sallowed authentication methods. SASL authentication mechanisms
              in the list should be prefixed with "sasl:" string.
            - `tls_settings`: settings for StartTLS -- `TLSSettings` instance.
            - `keepalive`: keepalive output interval. 0 to disable.
            - `disco_name`: name of the client identity in the disco#info
              replies.
            - `disco_category`: category of the client identity in the disco#info
              replies. The default of u'client' should be the right choice in
              most cases.
            - `disco_type`: type of the client identity in the disco#info
              replies. Use `the types registered by Jabber Registrar <http://www.jabber.org/registrar/disco-categories.html>`__
        :Types:
            - `jid`: `pyxmpp.JID`
            - `password`: `unicode`
            - `server`: `unicode`
            - `port`: `int`
            - `auth_methods`: sequence of `str`
            - `tls_settings`: `pyxmpp.TLSSettings`
            - `keepalive`: `int`
            - `disco_name`: `unicode`
            - `disco_category`: `unicode`
            - `disco_type`: `unicode`
        """

        Client.__init__(self, jid, password, server, port, auth_methods,
                        tls_settings, keepalive)
        self.stream_class = LegacyClientStream
        self.disco_items = DiscoItems()
        self.disco_info = DiscoInfo()
        self.disco_identity = DiscoIdentity(self.disco_info, disco_name,
                                            disco_category, disco_type)
        self.register_feature(u"dnssrv")
        self.register_feature(u"stringprep")
        self.register_feature(u"urn:ietf:params:xml:ns:xmpp-sasl#c2s")
        self.cache = CacheSuite(max_items=1000)
        self.__logger = logging.getLogger("pyxmpp.jabber.JabberClient")
Exemple #3
0
    def __init__(self, jid=None, secret=None, server=None, port=5347,
            disco_name=u"PyXMPP based component", disco_category=u"x-service",
            disco_type=u"x-unknown", keepalive=0):
        """Initialize a `Component` object.

        :Parameters:
            - `jid`: component JID (should contain only the domain part).
            - `secret`: the authentication secret.
            - `server`: server name or address the component should connect.
            - `port`: port number on the server where the component should connect.
            - `disco_name`: disco identity name to be used in the
              disco#info responses.
            - `disco_category`: disco identity category to be used in the
              disco#info responses.  Use `the categories registered by Jabber Registrar <http://www.jabber.org/registrar/disco-categories.html>`__
            - `disco_type`: disco identity type to be used in the component's
              disco#info responses.  Use `the types registered by Jabber Registrar <http://www.jabber.org/registrar/disco-categories.html>`__
            - `keepalive`: keepalive interval for the stream.

        :Types:
            - `jid`:  `pyxmpp.JID`
            - `secret`: `unicode`
            - `server`: `str` or `unicode`
            - `port`: `int`
            - `disco_name`: `unicode`
            - `disco_category`: `unicode`
            - `disco_type`: `unicode`
            - `keepalive`: `int`"""
        self.jid=jid
        self.secret=secret
        self.server=server
        self.port=port
        self.keepalive=keepalive
        self.stream=None
        self.lock=threading.RLock()
        self.state_changed=threading.Condition(self.lock)
        self.stream_class=ComponentStream
        self.disco_items=DiscoItems()
        self.disco_info=DiscoInfo()
        self.disco_identity=DiscoIdentity(self.disco_info,
                            disco_name, disco_category, disco_type)
        self.register_feature("stringprep")
        self.__logger=logging.getLogger("pyxmpp.jabberd.Component")