Eyepea / aiosip

SIP support for AsyncIO (DEPRECATED)
Apache License 2.0
82 stars 40 forks source link

Contact/SIP URI overhaul #107

Open vodik opened 6 years ago

vodik commented 6 years ago

Hey, so my team, specifically my coworker @dtkerr, has put together a yarl-like like library for SIP URIs: ursine

I'd like to integrate it into aiosip as it will solve a lot of problems:

to_details=Contact.from_header(f"<sip:{user}@{host}:{port};transport={transport}")
from_details=...
contact_details=...
contact_addr = (msg.contact_details['uri']['host'],
                msg.contact_details['uri']['port'])

peer = await app.connect(contact_addr, aiosip.UDP,
                         local_addr=("0.0.0.0", 5060))

Not to mention this ignores transport - which can be mixed. I've just been assuming this whole time I'll be using UDP only because its easiest and I'll revisit other transports later. I do have a need to support sips:... eventually.

What I'd really like to see:

to_uri=URI.build(scheme="sip", user=user, host=host, port=port)
from_uri=...
contact_uri=...

This can also help with #63 and we can create the URI with to_uri.with_user(None)

And I think we should support making connections with SIP uris directly:

peer = await app.connect(msg.contact_uri, local_addr=("0.0.0.0", 5060))

Its a small library with no other external dependencies, which we've done separately intentionally so we can use it in a few other projects that do SIP stuff but don't use aiosip, but I'm open to merging it as well.

ovv commented 6 years ago

Big thumbs up for that :+1:

Changing contact / uri handling was always on my mind as it was quite complicated. That looks like it will solve quite a few problems so I'm all for it

ludovic-gasc commented 6 years ago

Ok for me also.