[SIP Beyond VoIP] Address through SylkServer
Saúl Ibarra Corretgé
saul at ag-projects.com
Wed Aug 29 13:33:31 CEST 2012
Hi,
On Aug 29, 2012, at 10:21 AM, Hadzhiev, Tihomir wrote:
> Yep,
>
> Tried this, but the validator is still complaining that this is Invalid SIP URI:
>
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 766, in runUntilCurrent
> f(*a, **kw)
> File "/usr/local/lib/python2.7/dist-packages/sylk/applications/__init__.py", line 137, in handle_notification
> handler(notification)
> File "/usr/local/lib/python2.7/dist-packages/sylk/applications/__init__.py", line 196, in _NH_SIPIncomingRequestGotRequest
> app.incoming_sip_message(request, notification.data)
> File "/usr/local/lib/python2.7/dist-packages/sylk/applications/xmppgateway/__init__.py", line 172, in incoming_sip_message
> recipient = Identity(FrozenURI.parse(to_uri))
> File "/usr/local/lib/python2.7/dist-packages/sylk/applications/xmppgateway/datatypes.py", line 62, in parse
> raise ValueError('invalid SIP uri: %s' % value)
> ValueError: invalid SIP uri: sip:-739277318 at chat.facebook.com@facebook.testing.com
>
> Checked with trace on the communication and I see that the client is sending it correctly where address part is:
>
> -739277318%40chat.facebook.com
>
> And Host part is:
>
> facebook.testing.com
>
> So ideal would be to tackle the URI syntax check on the Sylk so the whole first part before the actual @facebook.testing.com is interpreted as normal string .
>
Hum, looks like it is percent decoded at some point. Lets try this:
Modify sylk/applications/xmppgateway/__init__.py line 166
replace:
to_uri = str(to_header.uri)
with:
to_uri = to_header.uri
And in sylk/applications/xmppgateway/datatypes.py line 45
replace:
user = unicode(value.user)
with:
user = urllib.quote(unicode(value.user))
Also add this at the top of the file:
import urllib
Cheers,
> Cheers,
> Tiho
>
> -----Original Message-----
> From: Saúl Ibarra Corretgé [mailto:saul at ag-projects.com]
> Sent: Wednesday, August 29, 2012 9:43 AM
> To: Hadzhiev, Tihomir
> Cc: sipbeyondvoip at lists.ag-projects.com
> Subject: Re: [SIP Beyond VoIP] Address through SylkServer
>
> Hi,
>
> On Aug 28, 2012, at 4:56 PM, Hadzhiev, Tihomir wrote:
>
>> Hi Saul,
>>
>> Thanks for the tip, but I can't really understand ( not trying to play fool of course :) ) your suggestions.
>>
>> The expected string towards the XMPP server would be:
>>
>> -739277318\40chat.facebook.com at facebook.testing.com
>>
>> And If I use the @ sign instead of the \40 Sylk will catch the URL @chat.facebook.com, without the rest ( @facebook.testing.com ).
>>
>> And I could get the following sentence:
>>
>> You need to percent encode the URI so that it looks like a correct SIP URI
>>
>> I tried to percent the "\" only as the 40 is needed as a string, as well as the "\".
>>
>> So could you please suggest if that's possible at all how the full URI would look like ? a real example would really suffice :)
>
> All those numbers confused me, this is just JID escaping as per XEP-0106. You need to replace the '@' sign with a '\40', but in order to add the '\' character to a Python string you need to escape it, so you'll need to replace '@' with '\\40'.
>
> Now, the resulting URI is not a valid SIP URI, so I suggest you do the following:
>
> - Percent-encode the URI on the SIP side, that is: sip:-739277318%40chat.facebook.com at facebook.testing.com
> - Fix the URI to be a valid escaped JID:
> s = "-739277318%40chat.facebook.com at facebook.testing.com"
> valid_jid = s.replace('%40', '\\40')
>
>
> Regards,
>
> --
> Saúl Ibarra Corretgé
> AG Projects
>
>
>
>
>
> This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you for understanding.
>
>
--
Saúl Ibarra Corretgé
AG Projects
More information about the SIPBeyondVoIP
mailing list