summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0065/stanza.py
blob: 9701c23707d1d4a006bb4ff6411e86a06117384b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from slixmpp.jid import JID
from slixmpp.xmlstream import ElementBase, register_stanza_plugin


class Socks5(ElementBase):
    name = 'query'
    namespace = 'http://jabber.org/protocol/bytestreams'
    plugin_attrib = 'socks'
    interfaces = {'sid', 'activate'}
    sub_interfaces = {'activate'}

    def add_streamhost(self, jid, host, port):
        sh = StreamHost(parent=self)
        sh['jid'] = jid
        sh['host'] = host
        sh['port'] = port


class StreamHost(ElementBase):
    name = 'streamhost'
    namespace = 'http://jabber.org/protocol/bytestreams'
    plugin_attrib = 'streamhost'
    plugin_multi_attrib = 'streamhosts'
    interfaces = {'host', 'jid', 'port'}

    def set_jid(self, value):
        return self._set_attr('jid', str(value))

    def get_jid(self):
        return JID(self._get_attr('jid'))


class StreamHostUsed(ElementBase):
    name = 'streamhost-used'
    namespace = 'http://jabber.org/protocol/bytestreams'
    plugin_attrib = 'streamhost_used'
    interfaces = {'jid'}

    def set_jid(self, value):
        return self._set_attr('jid', str(value))

    def get_jid(self):
        return JID(self._get_attr('jid'))


register_stanza_plugin(Socks5, StreamHost, iterable=True)
register_stanza_plugin(Socks5, StreamHostUsed)