plugin XEP-0065: refactored and misc stuff fixed. Still not finished
plugins XEP-0096: XEP-0065 (Socks5 stream method) managed
This commit is contained in:
parent
b8edbbab56
commit
1225131aec
1 changed files with 295 additions and 167 deletions
|
|
@ -86,38 +86,38 @@ class XEP_0095():
|
|||
#We don't know this profile, we send an error
|
||||
self.sendBadProfileError(iq_el['id'], iq_el['from'], profile)
|
||||
|
||||
def sendRejectedError(self, id, to_jid, reason = 'Offer Declined', profile='@NONE@'):
|
||||
def sendRejectedError(self, iq_id, to_jid, reason = 'Offer Declined', profile='@NONE@'):
|
||||
"""Helper method to send when the stream is rejected
|
||||
@param id: IQ id
|
||||
@param iq_id: IQ id
|
||||
@param to_jid: recipient
|
||||
@param reason: human readable reason (string)
|
||||
@param profile: %(doc_profile)s"""
|
||||
self.sendError(id, to_jid, 403, 'cancel', {'text':reason}, profile=profile)
|
||||
self.sendError(iq_id, to_jid, 403, 'cancel', {'text':reason}, profile=profile)
|
||||
|
||||
def sendBadProfileError(self, id, to_jid, profile):
|
||||
def sendBadProfileError(self, iq_id, to_jid, profile):
|
||||
"""Helper method to send when we don't know the SI profile
|
||||
@param id: IQ id
|
||||
@param iq_id: IQ id
|
||||
@param to_jid: recipient
|
||||
@param profile: %(doc_profile)s"""
|
||||
self.sendError(id, to_jid, 400, 'modify', profile=profile)
|
||||
self.sendError(iq_id, to_jid, 400, 'modify', profile=profile)
|
||||
|
||||
def sendBadRequestError(self, id, to_jid, profile):
|
||||
def sendBadRequestError(self, iq_id, to_jid, profile):
|
||||
"""Helper method to send when we don't know the SI profile
|
||||
@param id: IQ id
|
||||
@param iq_id: IQ id
|
||||
@param to_jid: recipient
|
||||
@param profile: %(doc_profile)s"""
|
||||
self.sendError(id, to_jid, 400, 'cancel', profile=profile)
|
||||
self.sendError(iq_id, to_jid, 400, 'cancel', profile=profile)
|
||||
|
||||
def sendFailedError(self, id, to_jid, profile):
|
||||
def sendFailedError(self, iq_id, to_jid, profile):
|
||||
"""Helper method to send when we transfer failed
|
||||
@param id: IQ id
|
||||
@param iq_id: IQ id
|
||||
@param to_jid: recipient
|
||||
@param profile: %(doc_profile)s"""
|
||||
self.sendError(id, to_jid, 500, 'cancel', {'custom':'failed'}, profile=profile) #as there is no error code for failed transfer, we use 500 (undefined-condition)
|
||||
self.sendError(iq_id, to_jid, 500, 'cancel', {'custom':'failed'}, profile=profile) #as there is no error code for failed transfer, we use 500 (undefined-condition)
|
||||
|
||||
def sendError(self, id, to_jid, err_code, err_type='cancel', data={}, profile='@NONE@'):
|
||||
def sendError(self, iq_id, to_jid, err_code, err_type='cancel', data={}, profile='@NONE@'):
|
||||
"""Send IQ error as a result
|
||||
@param id: IQ id
|
||||
@param iq_id: IQ id
|
||||
@param to_jid: recipient
|
||||
@param err_code: error err_code (see XEP-0095 #4.2)
|
||||
@param err_type: one of cancel, modify
|
||||
|
|
@ -128,7 +128,7 @@ class XEP_0095():
|
|||
assert(client)
|
||||
result = domish.Element(('', 'iq'))
|
||||
result['type'] = 'result'
|
||||
result['id'] = id
|
||||
result['id'] = iq_id
|
||||
result['to'] = to_jid
|
||||
error_el = result.addElement('error')
|
||||
error_el['err_code'] = str(err_code)
|
||||
|
|
@ -150,9 +150,9 @@ class XEP_0095():
|
|||
|
||||
client.xmlstream.send(result)
|
||||
|
||||
def acceptStream(self, id, to_jid, feature_elt, misc_elts=[], profile='@NONE@'):
|
||||
def acceptStream(self, iq_id, to_jid, feature_elt, misc_elts=[], profile='@NONE@'):
|
||||
"""Send the accept stream initiation answer
|
||||
@param id: stream initiation id
|
||||
@param iq_id: IQ id
|
||||
@param feature_elt: domish element 'feature' containing stream method to use
|
||||
@param misc_elts: list of domish element to add
|
||||
@param profile: %(doc_profile)s"""
|
||||
|
|
@ -161,7 +161,7 @@ class XEP_0095():
|
|||
info (_("sending stream initiation accept answer"))
|
||||
result = domish.Element(('', 'iq'))
|
||||
result['type'] = 'result'
|
||||
result['id'] = id
|
||||
result['id'] = iq_id
|
||||
result['to'] = to_jid
|
||||
si = result.addElement('si', NS_SI)
|
||||
si.addChild(feature_elt)
|
||||
|
|
|
|||
Loading…
Reference in a new issue