Skip to content

Commit

Permalink
Added ability to enable nat traversal and set rport if via address ha…
Browse files Browse the repository at this point in the history
…s .invalid domain (rfc 7118 support)
  • Loading branch information
braams authored and sobomax committed Oct 31, 2023
1 parent 287bc40 commit 5b5c34a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sippy/sip_transaction_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ func check1918(host string) bool {
return false
}

const invalidSuffix = ".invalid"

func check7118(host string) bool {
return strings.HasSuffix(host, invalidSuffix)
}

func (self *sipTransactionManager) rcache_put(checksum string, entry *sipTMRetransmitO) {
self.rcache_lock.Lock()
defer self.rcache_lock.Unlock()
Expand Down Expand Up @@ -334,7 +340,7 @@ func (self *sipTransactionManager) process_request(rtime *sippy_time.MonoTime, d
}
ahost, aport := via0.GetAddr(self.config)
rhost, rport := address.Host.String(), address.Port.String()
if self.nat_traversal && rport != aport && check1918(ahost) {
if self.nat_traversal && rport != aport && (check1918(ahost) || check7118(ahost)) {
req.nated = true
}
if ahost != rhost {
Expand Down Expand Up @@ -756,3 +762,7 @@ func (self *sipTransactionManager) rtid_put(key *sippy_header.RTID, value *sippy
defer self.rtid2tid_lock.Unlock()
self.rtid2tid[*key] = value
}

func (self *sipTransactionManager) SetNatTraversal(nat_traversal bool) {
self.nat_traversal = nat_traversal
}

0 comments on commit 5b5c34a

Please sign in to comment.