cloudwebrtc / go-sip-ua

Go SIP UA library for client/b2bua
Apache License 2.0
205 stars 84 forks source link

Add "rport" in via to support NAT. #99

Open finntenzor opened 8 months ago

finntenzor commented 8 months ago

Problem: Can not connenct to SIP server when client behind a NAT network.

Request Log:

REGISTER sip:1000@172.27.0.8:7060 SIP/2.0

Via: SIP/2.0/UDP 192.168.1.187:50066;branch=z9hG4bK.iJM9FQ5m5ZRW0ZJZTAvNGlTyN9JPA6Nl
......

What's expected:

REGISTER sip:1000@172.27.0.8:7060 SIP/2.0

Via: SIP/2.0/UDP 192.168.1.187:50066;rport;branch=z9hG4bK.iJM9FQ5m5ZRW0ZJZTAvNGlTyN9JPA6Nl
......

Solution: Add an additional "rport" parameter in "Via" when request is prepared. (RFC3581) I submitted a PR draft at PR 98. This PR only checks the functionality, not the configuration, which may need to be added.

FireTiger23 commented 3 months ago

I also need this feature. Hope to support