Mercurial > libervia-backend
annotate src/plugins/plugin_xep_0065.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | 9902ec2d8d9b |
children | beaf6bec2fcd |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 """ | |
4 SAT plugin for managing xep-0065 | |
5 | |
6 Copyright (C) | |
251
dbe1803eca7c
minor copyright update, date format harmonisation
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
7 2002, 2003, 2004 Dave Smith (dizzyd@jabber.org) |
dbe1803eca7c
minor copyright update, date format harmonisation
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
8 2007, 2008 Fabio Forno (xmpp:ff@jabber.bluendo.com) |
572 | 9 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
0 | 10 |
11 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
12 it under the terms of the GNU Affero General Public License as published by |
0 | 13 the Free Software Foundation, either version 3 of the License, or |
14 (at your option) any later version. | |
15 | |
16 This program is distributed in the hope that it will be useful, | |
17 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
19 GNU Affero General Public License for more details. |
0 | 20 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
21 You should have received a copy of the GNU Affero General Public License |
0 | 22 along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | |
24 -- | |
25 | |
26 This program is based on proxy65 (http://code.google.com/p/proxy65), | |
27 originaly written by David Smith and modified by Fabio Forno. | |
28 It is sublicensed under GPL v3 (or any later version) as allowed by the original | |
29 license. | |
30 | |
31 -- | |
32 | |
33 Here is a copy of the original license: | |
34 | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
35 Copyright (C) |
0 | 36 2002-2004 Dave Smith (dizzyd@jabber.org) |
37 2007-2008 Fabio Forno (xmpp:ff@jabber.bluendo.com) | |
38 | |
39 Permission is hereby granted, free of charge, to any person obtaining a copy | |
40 of this software and associated documentation files (the "Software"), to deal | |
41 in the Software without restriction, including without limitation the rights | |
42 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
43 copies of the Software, and to permit persons to whom the Software is | |
44 furnished to do so, subject to the following conditions: | |
45 | |
46 The above copyright notice and this permission notice shall be included in | |
47 all copies or substantial portions of the Software. | |
48 | |
49 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
50 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
51 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
52 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
53 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
54 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
55 THE SOFTWARE. | |
56 """ | |
57 | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
58 from logging import debug, info, warning, error |
0 | 59 from twisted.internet import protocol, reactor |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
60 from twisted.internet import error as jab_error |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
61 from twisted.words.protocols.jabber import jid, client as jabber_client |
0 | 62 from twisted.protocols.basic import FileSender |
63 from twisted.words.xish import domish | |
20
fc8c202cda87
refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
64 from twisted.web.client import getPage |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
65 from sat.core.exceptions import ProfileNotInCacheError |
0 | 66 import struct |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
67 import hashlib |
0 | 68 |
15
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
69 from zope.interface import implements |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
70 |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
71 try: |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
72 from twisted.words.protocols.xmlstream import XMPPHandler |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
73 except ImportError: |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
74 from wokkel.subprotocols import XMPPHandler |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
75 |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
76 from wokkel import disco, iwokkel |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
77 |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
78 IQ_SET = '/iq[@type="set"]' |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
79 NS_BS = 'http://jabber.org/protocol/bytestreams' |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
80 BS_REQUEST = IQ_SET + '/query[@xmlns="' + NS_BS + '"]' |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
81 TIMEOUT = 60 #timeout for workflow |
15
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
82 |
218ec9984fa5
wokkel integration part III + memory saved again
Goffi <goffi@goffi.org>
parents:
9
diff
changeset
|
83 |
0 | 84 |
85 PLUGIN_INFO = { | |
86 "name": "XEP 0065 Plugin", | |
291 | 87 "import_name": "XEP-0065", |
0 | 88 "type": "XEP", |
48 | 89 "protocols": ["XEP-0065"], |
0 | 90 "main": "XEP_0065", |
64 | 91 "handler": "yes", |
69 | 92 "description": _("""Implementation of SOCKS5 Bytestreams""") |
0 | 93 } |
94 | |
95 STATE_INITIAL = 0 | |
96 STATE_AUTH = 1 | |
97 STATE_REQUEST = 2 | |
98 STATE_READY = 3 | |
99 STATE_AUTH_USERPASS = 4 | |
100 STATE_TARGET_INITIAL = 5 | |
101 STATE_TARGET_AUTH = 6 | |
102 STATE_TARGET_REQUEST = 7 | |
103 STATE_TARGET_READY = 8 | |
104 STATE_LAST = 9 | |
105 | |
106 STATE_CONNECT_PENDING = STATE_LAST + 1 | |
107 | |
108 SOCKS5_VER = 0x05 | |
109 | |
110 ADDR_IPV4 = 0x01 | |
111 ADDR_DOMAINNAME = 0x03 | |
112 ADDR_IPV6 = 0x04 | |
113 | |
114 CMD_CONNECT = 0x01 | |
115 CMD_BIND = 0x02 | |
116 CMD_UDPASSOC = 0x03 | |
117 | |
118 AUTHMECH_ANON = 0x00 | |
119 AUTHMECH_USERPASS = 0x02 | |
120 AUTHMECH_INVALID = 0xFF | |
121 | |
122 REPLY_SUCCESS = 0x00 | |
123 REPLY_GENERAL_FAILUR = 0x01 | |
124 REPLY_CONN_NOT_ALLOWED = 0x02 | |
125 REPLY_NETWORK_UNREACHABLE = 0x03 | |
126 REPLY_HOST_UNREACHABLE = 0x04 | |
127 REPLY_CONN_REFUSED = 0x05 | |
128 REPLY_TTL_EXPIRED = 0x06 | |
129 REPLY_CMD_NOT_SUPPORTED = 0x07 | |
130 REPLY_ADDR_NOT_SUPPORTED = 0x08 | |
131 | |
132 | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
133 def calculateHash(from_jid, to_jid, sid): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
134 """Calculate SHA1 Hash according to XEP-0065 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
135 @param from_jid: jid of the requester |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
136 @param to_jid: jid of the target |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
137 @param sid: session id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
138 @return: hash (string)""" |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
139 return hashlib.sha1((sid + from_jid.full() + to_jid.full()).encode('utf-8')).hexdigest() |
0 | 140 |
141 | |
142 | |
143 class SOCKSv5(protocol.Protocol, FileSender): | |
144 def __init__(self): | |
69 | 145 debug(_("Protocol init")) |
0 | 146 self.state = STATE_INITIAL |
147 self.buf = "" | |
148 self.supportedAuthMechs = [ AUTHMECH_ANON ] | |
149 self.supportedAddrs = [ ADDR_DOMAINNAME ] | |
150 self.enabledCommands = [ CMD_CONNECT ] | |
151 self.peersock = None | |
152 self.addressType = 0 | |
153 self.requestType = 0 | |
154 | |
155 def _startNegotiation(self): | |
156 debug("_startNegotiation") | |
157 self.state = STATE_TARGET_AUTH | |
158 self.transport.write(struct.pack('!3B', SOCKS5_VER, 1, AUTHMECH_ANON)) | |
159 | |
160 def _parseNegotiation(self): | |
161 debug("_parseNegotiation") | |
162 try: | |
163 # Parse out data | |
164 ver, nmethod = struct.unpack('!BB', self.buf[:2]) | |
165 methods = struct.unpack('%dB' % nmethod, self.buf[2:nmethod+2]) | |
166 | |
167 # Ensure version is correct | |
168 if ver != 5: | |
169 self.transport.write(struct.pack('!BB', SOCKS5_VER, AUTHMECH_INVALID)) | |
170 self.transport.loseConnection() | |
171 return | |
172 | |
173 # Trim off front of the buffer | |
174 self.buf = self.buf[nmethod+2:] | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
175 |
0 | 176 # Check for supported auth mechs |
177 for m in self.supportedAuthMechs: | |
178 if m in methods: | |
179 # Update internal state, according to selected method | |
180 if m == AUTHMECH_ANON: | |
181 self.state = STATE_REQUEST | |
182 elif m == AUTHMECH_USERPASS: | |
183 self.state = STATE_AUTH_USERPASS | |
184 # Complete negotiation w/ this method | |
185 self.transport.write(struct.pack('!BB', SOCKS5_VER, m)) | |
186 return | |
187 | |
188 # No supported mechs found, notify client and close the connection | |
189 self.transport.write(struct.pack('!BB', SOCKS5_VER, AUTHMECH_INVALID)) | |
190 self.transport.loseConnection() | |
191 except struct.error: | |
192 pass | |
193 | |
194 def _parseUserPass(self): | |
195 debug("_parseUserPass") | |
196 try: | |
197 # Parse out data | |
198 ver, ulen = struct.unpack('BB', self.buf[:2]) | |
199 uname, = struct.unpack('%ds' % ulen, self.buf[2:ulen + 2]) | |
200 plen, = struct.unpack('B', self.buf[ulen + 2]) | |
201 password, = struct.unpack('%ds' % plen, self.buf[ulen + 3:ulen + 3 + plen]) | |
202 # Trim off fron of the buffer | |
203 self.buf = self.buf[3 + ulen + plen:] | |
204 # Fire event to authenticate user | |
205 if self.authenticateUserPass(uname, password): | |
206 # Signal success | |
207 self.state = STATE_REQUEST | |
208 self.transport.write(struct.pack('!BB', SOCKS5_VER, 0x00)) | |
209 else: | |
210 # Signal failure | |
211 self.transport.write(struct.pack('!BB', SOCKS5_VER, 0x01)) | |
212 self.transport.loseConnection() | |
213 except struct.error: | |
214 pass | |
215 | |
216 def sendErrorReply(self, errorcode): | |
217 debug("sendErrorReply") | |
218 # Any other address types are not supported | |
219 result = struct.pack('!BBBBIH', SOCKS5_VER, errorcode, 0, 1, 0, 0) | |
220 self.transport.write(result) | |
221 self.transport.loseConnection() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
222 |
0 | 223 def _parseRequest(self): |
224 debug("_parseRequest") | |
225 try: | |
226 # Parse out data and trim buffer accordingly | |
227 ver, cmd, rsvd, self.addressType = struct.unpack('!BBBB', self.buf[:4]) | |
228 | |
229 # Ensure we actually support the requested address type | |
230 if self.addressType not in self.supportedAddrs: | |
231 self.sendErrorReply(REPLY_ADDR_NOT_SUPPORTED) | |
232 return | |
233 | |
234 # Deal with addresses | |
235 if self.addressType == ADDR_IPV4: | |
236 addr, port = struct.unpack('!IH', self.buf[4:10]) | |
237 self.buf = self.buf[10:] | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
238 elif self.addressType == ADDR_DOMAINNAME: |
0 | 239 nlen = ord(self.buf[4]) |
240 addr, port = struct.unpack('!%dsH' % nlen, self.buf[5:]) | |
241 self.buf = self.buf[7 + len(addr):] | |
242 else: | |
243 # Any other address types are not supported | |
244 self.sendErrorReply(REPLY_ADDR_NOT_SUPPORTED) | |
245 return | |
246 | |
247 # Ensure command is supported | |
248 if cmd not in self.enabledCommands: | |
249 # Send a not supported error | |
250 self.sendErrorReply(REPLY_CMD_NOT_SUPPORTED) | |
251 return | |
252 | |
253 # Process the command | |
254 if cmd == CMD_CONNECT: | |
255 self.connectRequested(addr, port) | |
256 elif cmd == CMD_BIND: | |
257 self.bindRequested(addr, port) | |
258 else: | |
259 # Any other command is not supported | |
260 self.sendErrorReply(REPLY_CMD_NOT_SUPPORTED) | |
261 | |
262 except struct.error, why: | |
263 return None | |
264 | |
265 def _makeRequest(self): | |
266 debug("_makeRequest") | |
267 self.state = STATE_TARGET_REQUEST | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
268 sha1 = calculateHash(self.data["from"], self.data["to"], self.sid) |
0 | 269 request = struct.pack('!5B%dsH' % len(sha1), SOCKS5_VER, CMD_CONNECT, 0, ADDR_DOMAINNAME, len(sha1), sha1, 0) |
270 self.transport.write(request) | |
271 | |
272 def _parseRequestReply(self): | |
273 debug("_parseRequestReply") | |
274 try: | |
275 ver, rep, rsvd, self.addressType = struct.unpack('!BBBB', self.buf[:4]) | |
276 # Ensure we actually support the requested address type | |
277 if self.addressType not in self.supportedAddrs: | |
278 self.sendErrorReply(REPLY_ADDR_NOT_SUPPORTED) | |
279 return | |
280 | |
281 # Deal with addresses | |
282 if self.addressType == ADDR_IPV4: | |
283 addr, port = struct.unpack('!IH', self.buf[4:10]) | |
284 self.buf = self.buf[10:] | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
285 elif self.addressType == ADDR_DOMAINNAME: |
0 | 286 nlen = ord(self.buf[4]) |
287 addr, port = struct.unpack('!%dsH' % nlen, self.buf[5:]) | |
288 self.buf = self.buf[7 + len(addr):] | |
289 else: | |
290 # Any other address types are not supported | |
291 self.sendErrorReply(REPLY_ADDR_NOT_SUPPORTED) | |
292 return | |
293 | |
294 # Ensure reply is OK | |
295 if rep != REPLY_SUCCESS: | |
296 self.loseConnection() | |
297 return | |
298 | |
398 | 299 if self.factory.proxy: |
300 self.state = STATE_READY | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
301 self.factory.activateCb(self.sid, self.factory.iq_id, self.startTransfer, self.profile) |
398 | 302 else: |
303 self.state = STATE_TARGET_READY | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
304 self.factory.activateCb(self.sid, self.factory.iq_id, self.profile) |
0 | 305 |
306 except struct.error, why: | |
307 return None | |
308 | |
309 def connectionMade(self): | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
310 debug("connectionMade (mode = %s)" % "requester" if isinstance(self.factory, Socks5ServerFactory) else "target") |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
311 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
312 if isinstance(self.factory, Socks5ClientFactory): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
313 self.sid = self.factory.sid |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
314 self.profile = self.factory.profile |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
315 self.data = self.factory.data |
0 | 316 self.state = STATE_TARGET_INITIAL |
317 self._startNegotiation() | |
318 | |
319 def connectRequested(self, addr, port): | |
69 | 320 debug("connectRequested") |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
321 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
322 # Check that this session is expected |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
323 if not self.factory.hash_sid_map.has_key(addr): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
324 #no: we refuse it |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
325 self.sendErrorReply(REPLY_CONN_REFUSED) |
0 | 326 return |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
327 self.sid, self.profile = self.factory.hash_sid_map[addr] |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
328 client = self.factory.host.getClient(self.profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
329 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
330 raise ProfileNotInCacheError |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
331 client.xep_0065_current_stream[self.sid]["start_transfer_cb"] = self.startTransfer |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
332 self.connectCompleted(addr, 0) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
333 self.transport.stopReading() |
0 | 334 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
335 def startTransfer(self, file_obj): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
336 """Callback called when the result iq is received""" |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
337 d = self.beginFileTransfer(file_obj, self.transport) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
338 d.addCallback(self.fileTransfered) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
339 |
0 | 340 def fileTransfered(self, d): |
69 | 341 info(_("File transfer completed, closing connection")) |
0 | 342 self.transport.loseConnection() |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
343 self.factory.finishedCb(self.sid, True, self.profile) |
0 | 344 |
345 def connectCompleted(self, remotehost, remoteport): | |
346 debug("connectCompleted") | |
347 if self.addressType == ADDR_IPV4: | |
348 result = struct.pack('!BBBBIH', SOCKS5_VER, REPLY_SUCCESS, 0, 1, remotehost, remoteport) | |
349 elif self.addressType == ADDR_DOMAINNAME: | |
350 result = struct.pack('!BBBBB%dsH' % len(remotehost), SOCKS5_VER, REPLY_SUCCESS, 0, | |
351 ADDR_DOMAINNAME, len(remotehost), remotehost, remoteport) | |
352 self.transport.write(result) | |
353 self.state = STATE_READY | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
354 |
0 | 355 def bindRequested(self, addr, port): |
356 pass | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
357 |
0 | 358 def authenticateUserPass(self, user, passwd): |
359 debug("User/pass: %s/%s", user, passwd) | |
360 return True | |
361 | |
362 def dataReceived(self, buf): | |
363 if self.state == STATE_TARGET_READY: | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
364 self.data["file_obj"].write(buf) |
0 | 365 return |
366 | |
367 self.buf = self.buf + buf | |
368 if self.state == STATE_INITIAL: | |
369 self._parseNegotiation() | |
370 if self.state == STATE_AUTH_USERPASS: | |
371 self._parseUserPass() | |
372 if self.state == STATE_REQUEST: | |
373 self._parseRequest() | |
374 if self.state == STATE_TARGET_AUTH: | |
375 ver, method = struct.unpack('!BB', buf) | |
376 self.buf = self.buf[2:] | |
377 if ver!=SOCKS5_VER or method!=AUTHMECH_ANON: | |
378 self.transport.loseConnection() | |
379 else: | |
380 self._makeRequest() | |
381 if self.state == STATE_TARGET_REQUEST: | |
382 self._parseRequestReply() | |
383 | |
384 | |
385 def clientConnectionLost(self, reason): | |
386 debug("clientConnectionLost") | |
387 self.transport.loseConnection() | |
388 | |
389 def connectionLost(self, reason): | |
390 debug("connectionLost") | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
391 if self.state != STATE_CONNECT_PENDING: |
0 | 392 self.transport.unregisterProducer() |
393 if self.peersock != None: | |
394 self.peersock.peersock = None | |
395 self.peersock.transport.unregisterProducer() | |
396 self.peersock = None | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
397 |
0 | 398 |
399 class Socks5ServerFactory(protocol.ServerFactory): | |
400 protocol = SOCKSv5 | |
401 | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
402 def __init__(self, host, hash_sid_map, finishedCb): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
403 self.host = host |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
404 self.hash_sid_map = hash_sid_map |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
405 self.finishedCb = finishedCb |
0 | 406 |
407 def startedConnecting(self, connector): | |
69 | 408 debug (_("Socks 5 server connection started")) |
0 | 409 |
410 def clientConnectionLost(self, connector, reason): | |
69 | 411 debug (_("Socks 5 server connection lost (reason: %s)"), reason) |
0 | 412 |
413 class Socks5ClientFactory(protocol.ClientFactory): | |
414 protocol = SOCKSv5 | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
415 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
416 def __init__(self, current_stream, sid, iq_id, activateCb, finishedCb, proxy=False, profile=None): |
398 | 417 """Init the Client Factory |
418 @param current_stream: current streams data | |
419 @param sid: Session ID | |
420 @param iq_id: iq id used to initiate the stream | |
421 @param activateCb: method to call to activate the stream | |
422 @param finishedCb: method to call when the stream session is finished | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
423 @param proxy: True if we are connecting throught a proxy (and we are a requester) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
424 @param profile: %(doc_profile)s""" |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
425 assert(profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
426 self.data = current_stream[sid] |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
427 self.sid = sid |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
428 self.iq_id = iq_id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
429 self.activateCb = activateCb |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
430 self.finishedCb = finishedCb |
398 | 431 self.proxy = proxy |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
432 self.profile = profile |
0 | 433 |
434 def startedConnecting(self, connector): | |
69 | 435 debug (_("Socks 5 client connection started")) |
0 | 436 |
437 def clientConnectionLost(self, connector, reason): | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
438 debug (_("Socks 5 client connection lost (reason: %s)"), reason) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
439 self.finishedCb(self.sid, reason.type == jab_error.ConnectionDone, self.profile) #TODO: really check if the state is actually successful |
0 | 440 |
441 | |
64 | 442 class XEP_0065(): |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
443 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
444 NAMESPACE = NS_BS |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
445 |
19
f2a745ca0fbc
refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
446 params = """ |
f2a745ca0fbc
refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
447 <params> |
60
9764e027ecc0
SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
448 <general> |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
449 <category name="File Transfer"> |
20
fc8c202cda87
refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
450 <param name="IP" value='0.0.0.0' default_cb='yes' type="string" /> |
19
f2a745ca0fbc
refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
451 <param name="Port" value="28915" type="string" /> |
f2a745ca0fbc
refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
452 </category> |
60
9764e027ecc0
SàT: multi-profile parameters, first draft
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
453 </general> |
398 | 454 <individual> |
455 <category name="File Transfer"> | |
456 <param name="Proxy" value="" type="string" /> | |
457 <param name="Proxy host" value="" type="string" /> | |
458 <param name="Proxy port" value="" type="string" /> | |
459 </category> | |
460 </individual> | |
19
f2a745ca0fbc
refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
461 </params> |
f2a745ca0fbc
refactoring: using xml params part III (parameters import)
Goffi <goffi@goffi.org>
parents:
15
diff
changeset
|
462 """ |
20
fc8c202cda87
refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
463 |
0 | 464 def __init__(self, host): |
69 | 465 info(_("Plugin XEP_0065 initialization")) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
466 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
467 #session data |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
468 self.hash_sid_map = {} #key: hash of the transfer session, value: (session id, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
469 |
0 | 470 self.host = host |
69 | 471 debug(_("registering")) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
472 self.server_factory = Socks5ServerFactory(host, self.hash_sid_map, lambda sid, success, profile: self._killId(sid, success, profile=profile)) |
21
633c5ed65701
parameters: new button type (not finished)
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
473 |
633c5ed65701
parameters: new button type (not finished)
Goffi <goffi@goffi.org>
parents:
20
diff
changeset
|
474 #parameters |
38 | 475 host.memory.importParams(XEP_0065.params) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
476 host.memory.setDefault("IP", "File Transfer", self.getExternalIP) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
477 port = int(self.host.memory.getParamA("Port", "File Transfer")) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
478 |
69 | 479 info(_("Launching Socks5 Stream server on port %d"), port) |
0 | 480 reactor.listenTCP(port, self.server_factory) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
481 |
72 | 482 def getHandler(self, profile): |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
483 return XEP_0065_handler(self) |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
484 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
485 def profileConnected(self, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
486 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
487 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
488 raise ProfileNotInCacheError |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
489 client.xep_0065_current_stream = {} #key: stream_id, value: data(dict) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
490 |
20
fc8c202cda87
refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
491 def getExternalIP(self): |
fc8c202cda87
refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
492 """Return IP visible from outside, by asking to a website""" |
fc8c202cda87
refactoring: using xml params part IV (default values)
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
493 return getPage("http://www.goffi.org/sat_tools/get_ip.php") |
0 | 494 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
495 def getProgress(self, sid, data, profile): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
496 """Fill data with position of current transfer""" |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
497 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
498 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
499 raise ProfileNotInCacheError |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
500 try: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
501 file_obj = client.xep_0065_current_stream[sid]["file_obj"] |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
502 data["position"] = str(file_obj.tell()) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
503 data["size"] = str(client.xep_0065_current_stream[sid]["size"]) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
504 except: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
505 pass |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
506 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
507 def _timeOut(self, sid, profile): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
508 """Delecte current_stream id, called after timeout |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
509 @param id: id of client.xep_0065_current_stream""" |
585
9902ec2d8d9b
Remove useless trailing semicolons.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
510 info(_("Socks5 Bytestream: TimeOut reached for id %s [%s]") % (sid, profile)) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
511 self._killId(sid, False, "TIMEOUT", profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
512 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
513 def _killId(self, sid, success=False, failure_reason="UNKNOWN", profile=None): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
514 """Delete an current_stream id, clean up associated observers |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
515 @param sid: id of client.xep_0065_current_stream""" |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
516 assert(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
517 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
518 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
519 warning(_("Client no more in cache")) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
520 return |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
521 if not client.xep_0065_current_stream.has_key(sid): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
522 warning(_("kill id called on a non existant id")) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
523 return |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
524 if client.xep_0065_current_stream[sid].has_key("observer_cb"): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
525 xmlstream = client.xep_0065_current_stream[sid]["xmlstream"] |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
526 xmlstream.removeObserver(client.xep_0065_current_stream[sid]["event_data"], client.xep_0065_current_stream[sid]["observer_cb"]) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
527 if client.xep_0065_current_stream[sid]['timer'].active(): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
528 client.xep_0065_current_stream[sid]['timer'].cancel() |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
529 if client.xep_0065_current_stream[sid].has_key("size"): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
530 self.host.removeProgressCB(sid, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
531 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
532 file_obj = client.xep_0065_current_stream[sid]['file_obj'] |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
533 success_cb = client.xep_0065_current_stream[sid]['success_cb'] |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
534 failure_cb = client.xep_0065_current_stream[sid]['failure_cb'] |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
535 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
536 session_hash = client.xep_0065_current_stream[sid].get('hash') |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
537 del client.xep_0065_current_stream[sid] |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
538 if session_hash in self.hash_sid_map: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
539 #FIXME: check that self.hash_sid_map is correctly cleaned in all cases (timeout, normal flow, etc). |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
540 del self.hash_sid_map[session_hash] |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
541 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
542 if success: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
543 success_cb(sid, file_obj, NS_BS, profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
544 else: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
545 failure_cb(sid, file_obj, NS_BS, failure_reason, profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
546 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
547 def startStream(self, file_obj, to_jid, sid, length, successCb, failureCb, size = None, profile=None): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
548 """Launch the stream workflow |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
549 @param file_obj: file_obj to send |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
550 @param to_jid: JID of the recipient |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
551 @param sid: Stream session id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
552 @param length: number of byte to send, or None to send until the end |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
553 @param successCb: method to call when stream successfuly finished |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
554 @param failureCb: method to call when something goes wrong |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
555 @param profile: %(doc_profile)s""" |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
556 assert(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
557 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
558 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
559 error(_("Unknown profile, this should not happen")) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
560 raise ProfileNotInCacheError |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
561 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
562 if length != None: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
563 error(_('stream length not managed yet')) |
585
9902ec2d8d9b
Remove useless trailing semicolons.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
564 return |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
565 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
566 profile_jid = client.jid |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
567 xmlstream = client.xmlstream |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
568 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
569 data = client.xep_0065_current_stream[sid] = {} |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
570 data["timer"] = reactor.callLater(TIMEOUT, self._timeOut, sid, profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
571 data["file_obj"] = file_obj |
398 | 572 data["from"] = profile_jid |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
573 data["to"] = to_jid |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
574 data["success_cb"] = successCb |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
575 data["failure_cb"] = failureCb |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
576 data["xmlstream"] = xmlstream |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
577 data["hash"] = calculateHash(profile_jid, to_jid, sid) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
578 self.hash_sid_map[data["hash"]] = (sid, profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
579 if size: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
580 data["size"] = size |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
581 self.host.registerProgressCB(sid, self.getProgress, profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
582 iq_elt = jabber_client.IQ(xmlstream,'set') |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
583 iq_elt["from"] = profile_jid.full() |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
584 iq_elt["to"] = to_jid.full() |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
585 query_elt = iq_elt.addElement('query', NS_BS) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
586 query_elt['mode'] = 'tcp' |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
587 query_elt['sid'] = sid |
398 | 588 #first streamhost: direct connection |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
589 streamhost = query_elt.addElement('streamhost') |
398 | 590 streamhost['host'] = self.host.memory.getParamA("IP", "File Transfer") |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
591 streamhost['port'] = self.host.memory.getParamA("Port", "File Transfer") |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
592 streamhost['jid'] = profile_jid.full() |
398 | 593 |
594 #second streamhost: mediated connection, using proxy | |
595 streamhost = query_elt.addElement('streamhost') | |
596 streamhost['host'] = self.host.memory.getParamA("Proxy host", "File Transfer", profile_key=profile) | |
597 streamhost['port'] = self.host.memory.getParamA("Proxy port", "File Transfer", profile_key=profile) | |
598 streamhost['jid'] = self.host.memory.getParamA("Proxy", "File Transfer", profile_key=profile) | |
599 | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
600 iq_elt.addCallback(self.iqResult, sid, profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
601 iq_elt.send() |
0 | 602 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
603 def iqResult(self, sid, profile, iq_elt): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
604 """Called when the result of open iq is received""" |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
605 if iq_elt["type"] == "error": |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
606 warning(_("Transfer failed")) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
607 return |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
608 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
609 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
610 raise ProfileNotInCacheError |
398 | 611 try: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
612 data = client.xep_0065_current_stream[sid] |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
613 file_obj = data["file_obj"] |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
614 timer = data["timer"] |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
615 except KeyError: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
616 error(_("Internal error, can't do transfer")) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
617 return |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
618 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
619 if timer.active(): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
620 timer.cancel() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
621 |
398 | 622 profile_jid, xmlstream = self.host.getJidNStream(profile) |
623 query_elt = iq_elt.firstChildElement() | |
624 streamhost_elts = filter(lambda elt: elt.name == 'streamhost-used', query_elt.elements()) | |
625 if not streamhost_elts: | |
626 warning(_("No streamhost found in stream query")) | |
627 return | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
628 |
398 | 629 streamhost_jid = streamhost_elts[0]['jid'] |
630 if streamhost_jid != profile_jid.full(): | |
631 debug(_("A proxy server is used")) | |
632 proxy_host = self.host.memory.getParamA("Proxy host", "File Transfer", profile_key=profile) | |
633 proxy_port = self.host.memory.getParamA("Proxy port", "File Transfer", profile_key=profile) | |
634 proxy_jid = self.host.memory.getParamA("Proxy", "File Transfer", profile_key=profile) | |
635 if proxy_jid != streamhost_jid: | |
636 warning(_("Proxy jid is not the same as in parameters, this should not happen")) | |
637 return | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
638 factory = Socks5ClientFactory(client.xep_0065_current_stream, sid, None, self.activateProxyStream, lambda sid, success, profile: self._killId(sid, success, profile=profile), True, profile) |
398 | 639 reactor.connectTCP(proxy_host, int(proxy_port), factory) |
640 else: | |
641 data["start_transfer_cb"](file_obj) #We now activate the stream | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
642 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
643 def activateProxyStream(self, sid, iq_id, start_transfer_cb, profile): |
398 | 644 debug(_("activating stream")) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
645 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
646 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
647 raise ProfileNotInCacheError |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
648 data = client.xep_0065_current_stream[sid] |
398 | 649 profile_jid, xmlstream = self.host.getJidNStream(profile) |
650 | |
651 iq_elt = client.IQ(xmlstream,'set') | |
652 iq_elt["from"] = profile_jid.full() | |
653 iq_elt["to"] = self.host.memory.getParamA("Proxy", "File Transfer", profile_key=profile) | |
654 query_elt = iq_elt.addElement('query', NS_BS) | |
655 query_elt['sid'] = sid | |
656 query_elt.addElement('activate', content=data['to'].full()) | |
657 iq_elt.addCallback(self.proxyResult, sid, start_transfer_cb, data['file_obj']) | |
658 iq_elt.send() | |
659 | |
660 def proxyResult(self, sid, start_transfer_cb, file_obj, iq_elt): | |
661 if iq_elt['type'] == 'error': | |
662 warning(_("Can't activate the proxy stream")) | |
663 return | |
664 else: | |
665 start_transfer_cb(file_obj) | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
666 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
667 def prepareToReceive(self, from_jid, sid, file_obj, size, success_cb, failure_cb, profile): |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
668 """Called when a bytestream is imminent |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
669 @param from_jid: jid of the sender |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
670 @param sid: Stream id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
671 @param file_obj: File object where data will be written |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
672 @param size: full size of the data, or None if unknown |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
673 @param success_cb: method to call when successfuly finished |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
674 @param failure_cb: method to call when something goes wrong |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
675 @param profile: %(doc_profile)s""" |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
676 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
677 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
678 raise ProfileNotInCacheError |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
679 data = client.xep_0065_current_stream[sid] = {} |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
680 data["from"] = from_jid |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
681 data["file_obj"] = file_obj |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
682 data["seq"] = -1 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
683 if size: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
684 data["size"] = size |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
685 self.host.registerProgressCB(sid, self.getProgress, profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
686 data["timer"] = reactor.callLater(TIMEOUT, self._timeOut, sid, profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
687 data["success_cb"] = success_cb |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
688 data["failure_cb"] = failure_cb |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
689 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
690 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
691 def streamQuery(self, iq_elt, profile): |
0 | 692 """Get file using byte stream""" |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
693 debug(_("BS stream query")) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
694 client = self.host.getClient(profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
695 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
696 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
697 raise ProfileNotInCacheError |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
698 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
699 xmlstream = client.xmlstream |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
700 |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
701 iq_elt.handled = True |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
702 query_elt = iq_elt.firstChildElement() |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
703 sid = query_elt.getAttribute("sid") |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
704 streamhost_elts = filter(lambda elt: elt.name == 'streamhost', query_elt.elements()) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
705 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
706 if not sid in client.xep_0065_current_stream: |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
707 warning(_("Ignoring unexpected BS transfer: %s" % sid)) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
708 self.sendNotAcceptableError(iq_elt['id'], iq_elt['from'], xmlstream) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
709 return |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
710 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
711 client.xep_0065_current_stream[sid]['timer'].cancel() |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
712 client.xep_0065_current_stream[sid]["to"] = jid.JID(iq_elt["to"]) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
713 client.xep_0065_current_stream[sid]["xmlstream"] = xmlstream |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
714 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
715 if not streamhost_elts: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
716 warning(_("No streamhost found in stream query %s" % sid)) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
717 self.sendBadRequestError(iq_elt['id'], iq_elt['from'], xmlstream) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
718 return |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
719 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
720 streamhost_elt = streamhost_elts[0] #TODO: manage several streamhost elements case |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
721 sh_host = streamhost_elt.getAttribute("host") |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
722 sh_port = streamhost_elt.getAttribute("port") |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
723 sh_jid = streamhost_elt.getAttribute("jid") |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
724 if not sh_host or not sh_port or not sh_jid: |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
725 warning(_("incomplete streamhost element")) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
726 self.sendBadRequestError(iq_elt['id'], iq_elt['from'], xmlstream) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
727 return |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
728 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
729 client.xep_0065_current_stream[sid]["streamhost"] = (sh_host, sh_port, sh_jid) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
730 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
731 info (_("Stream proposed: host=[%(host)s] port=[%(port)s]") % {'host':sh_host, 'port':sh_port}) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
732 factory = Socks5ClientFactory(client.xep_0065_current_stream, sid, iq_elt["id"], self.activateStream, lambda sid, success, profile: self._killId(sid, success, profile=profile), profile=profile) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
733 reactor.connectTCP(sh_host, int(sh_port), factory) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
734 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
735 def activateStream(self, sid, iq_id, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
736 client = self.host.getClient(profile) |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
737 if not client: |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
738 raise ProfileNotInCacheError |
69 | 739 debug(_("activating stream")) |
536
a31abb97310d
core, plugins: fixed bad namespace in stanza creation
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
740 result = domish.Element((None, 'iq')) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
741 data = client.xep_0065_current_stream[sid] |
0 | 742 result['type'] = 'result' |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
743 result['id'] = iq_id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
744 result['from'] = data["to"].full() |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
745 result['to'] = data["from"].full() |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
746 query = result.addElement('query', NS_BS) |
0 | 747 query['sid'] = sid |
748 streamhost = query.addElement('streamhost-used') | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
749 streamhost['jid'] = data["streamhost"][2] |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
750 data["xmlstream"].send(result) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
751 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
752 def sendNotAcceptableError(self, iq_id, to_jid, xmlstream): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
753 """Not acceptable error used when the stream is not expected or something is going wrong |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
754 @param iq_id: IQ id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
755 @param to_jid: addressee |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
756 @param xmlstream: XML stream to use to send the error""" |
536
a31abb97310d
core, plugins: fixed bad namespace in stanza creation
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
757 result = domish.Element((None, 'iq')) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
758 result['type'] = 'result' |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
759 result['id'] = iq_id |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
760 result['to'] = to_jid |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
761 error_el = result.addElement('error') |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
762 error_el['type'] = 'modify' |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
763 error_el.addElement(('urn:ietf:params:xml:ns:xmpp-stanzas','not-acceptable')) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
764 xmlstream.send(result) |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
765 |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
766 def sendBadRequestError(self, iq_id, to_jid, xmlstream): |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
767 """Not acceptable error used when the stream is not expected or something is going wrong |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
768 @param iq_id: IQ id |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
769 @param to_jid: addressee |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
770 @param xmlstream: XML stream to use to send the error""" |
536
a31abb97310d
core, plugins: fixed bad namespace in stanza creation
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
771 result = domish.Element((None, 'iq')) |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
772 result['type'] = 'result' |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
773 result['id'] = iq_id |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
774 result['to'] = to_jid |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
775 error_el = result.addElement('error') |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
776 error_el['type'] = 'cancel' |
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
777 error_el.addElement(('urn:ietf:params:xml:ns:xmpp-stanzas','bad-request')) |
64 | 778 xmlstream.send(result) |
0 | 779 |
64 | 780 class XEP_0065_handler(XMPPHandler): |
781 implements(iwokkel.IDisco) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
782 |
64 | 783 def __init__(self, plugin_parent): |
784 self.plugin_parent = plugin_parent | |
785 self.host = plugin_parent.host | |
398 | 786 |
787 def _proxyDataResult(self, iq_elt): | |
788 """Called with the informations about proxy according to XEP-0065 #4 | |
789 Params should be filled with these infos""" | |
790 if iq_elt["type"] == "error": | |
791 warning(_("Can't determine proxy informations")) | |
792 return | |
793 query_elt = iq_elt.firstChildElement() | |
794 if query_elt.name != "query": | |
795 warning(_("Bad answer received from proxy")) | |
796 return | |
797 streamhost_elts = filter(lambda elt: elt.name == 'streamhost', query_elt.elements()) | |
798 if not streamhost_elts: | |
799 warning(_("No streamhost found in stream query")) | |
800 return | |
801 if len(streamhost_elts) != 1: | |
802 warning(_("Multiple streamhost elements in proxy not managed, keeping only the first one")) | |
803 streamhost_elt = streamhost_elts[0] | |
804 proxy = self.host.memory.setParam("Proxy", streamhost_elt.getAttribute("jid",""), "File Transfer", self.parent.profile) | |
805 proxy = self.host.memory.setParam("Proxy host", streamhost_elt.getAttribute("host",""), "File Transfer", self.parent.profile) | |
806 proxy = self.host.memory.setParam("Proxy port", streamhost_elt.getAttribute("port",""), "File Transfer", self.parent.profile) | |
807 | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
808 |
64 | 809 def connectionInitialized(self): |
398 | 810 def after_init(ignore): |
811 proxy_ent = self.host.memory.getServerServiceEntity("proxy", "bytestreams", self.parent.profile) | |
812 if not proxy_ent: | |
813 debug(_("No proxy found on this server")) | |
814 return | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
815 iq_elt = jabber_client.IQ(self.parent.xmlstream,'get') |
398 | 816 iq_elt["to"] = proxy_ent.full() |
817 query_elt = iq_elt.addElement('query', NS_BS) | |
818 iq_elt.addCallback(self._proxyDataResult) | |
819 iq_elt.send() | |
820 | |
821 | |
394
8f3551ceee17
plugin XEP-0065: refactored and misc stuff fixed. Still not finished
Goffi <goffi@goffi.org>
parents:
291
diff
changeset
|
822 self.xmlstream.addObserver(BS_REQUEST, self.plugin_parent.streamQuery, profile = self.parent.profile) |
398 | 823 proxy = self.host.memory.getParamA("Proxy", "File Transfer", profile_key = self.parent.profile) |
824 if not proxy: | |
825 self.parent.client_initialized.addCallback(after_init) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
826 |
64 | 827 |
828 | |
829 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): | |
830 return [disco.DiscoFeature(NS_BS)] | |
831 | |
832 def getDiscoItems(self, requestor, target, nodeIdentifier=''): | |
833 return [] |