Skip to content

Commit

Permalink
Store protocol as well as address with setSource() method.
Browse files Browse the repository at this point in the history
Add getTSource() method to retrieve it and keep getSource()
as it is for backward compatibility.
  • Loading branch information
sobomax committed Jul 23, 2024
1 parent 5f42ada commit 0814429
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
9 changes: 6 additions & 3 deletions sippy/SipMsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from sippy.ESipHeaderCSV import ESipHeaderCSV
from sippy.ESipHeaderIgnore import ESipHeaderIgnore
from sippy.Exceptions.SipParseError import SipParseError
from sippy.Network_server import Remote_address

class SipMsg(object):
headers = None
Expand Down Expand Up @@ -241,11 +242,13 @@ def getTarget(self):
def setTarget(self, address):
self.target = address

def getSource(self):
def getSource(self, ver=1):
if ver == 1:
return self.source
return self.source

def setSource(self, address):
self.source = address
def setSource(self, ra:Remote_address):
self.source = (ra.address, ra.transport)

def getTId(self, wCSM = False, wBRN = False, wTTG = False):
headers_dict = dict([(x.name, x) for x in self.headers if x.name in ('cseq', 'call-id', 'from')])
Expand Down
4 changes: 2 additions & 2 deletions sippy/SipTransactionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def handleIncoming(self, data_in, ra:Remote_address, server, rtime):
if not cbody.asterisk:
curl = cbody.getUrl()
curl.host = ra.received
resp.setSource(ra.address)
resp.setSource(ra)
self.incomingResponse(resp, t, checksum)
else:
try:
Expand Down Expand Up @@ -363,7 +363,7 @@ def get_contact():
if not cbody.asterisk:
curl = cbody.getUrl()
curl.host = ra.received
req.setSource(ra.address)
req.setSource(ra)
try:
self.incomingRequest(req, checksum, tids, server)
except RtpProxyError as ex:
Expand Down
15 changes: 6 additions & 9 deletions sippy/b2bua_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class CallController(object):
proxied = False
challenge = None

def __init__(self, remote_ip, source, vtrans, global_config, pass_headers):
def __init__(self, remote_ip, source, trans, global_config, pass_headers):
self.id = CallController.id
CallController.id += 1
if vtrans == 'WSS': self.rtpps_cls = Rtp_proxy_session_webrtc
if trans == 'wss': self.rtpps_cls = Rtp_proxy_session_webrtc
self.global_config = global_config
self.uaA = UA(self.global_config, event_cb = self.recvEvent, conn_cbs = (self.aConn,), disc_cbs = (self.aDisc,), \
fail_cbs = (self.aDisc,), dead_cbs = (self.aDead,))
Expand Down Expand Up @@ -433,17 +433,14 @@ def recvRequest(self, req, sip_t):
via = req.getHFBody('via', 1)
else:
via = req.getHFBody('via', 0)
source = req.getSource()
if not via.transport == 'WSS':
remote_ip = via.getTAddr()[0]
else:
remote_ip = source[0]
source, transport = req.getSource(ver=2)
remote_ip = via.getTAddr()[0] if transport != 'wss' else source[0]

# First check if request comes from IP that
# we want to accept our traffic from
aips = self.global_config.getdefault('_accept_ips', None)
if aips is not None:
req_source = source[0] if via.transport != 'WSS' else 'WSS'
req_source = source[0] if transport != 'wss' else 'WSS'
if not req_source in aips:
resp = req.genResponse(403, 'Forbidden')
return (resp, None, None)
Expand All @@ -469,7 +466,7 @@ def recvRequest(self, req, sip_t):
hfs = req.getHFs(header)
if len(hfs) > 0:
pass_headers.extend(hfs)
cc = CallController(remote_ip, source, via.transport, self.global_config, pass_headers)
cc = CallController(remote_ip, source, transport, self.global_config, pass_headers)
cc.challenge = challenge
rval = cc.uaA.recvRequest(req, sip_t)
self.ccmap.append(cc)
Expand Down

0 comments on commit 0814429

Please sign in to comment.