-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable hrtb_*, Float param support #19
Open
jevonearth
wants to merge
12
commits into
sippy:master
Choose a base branch
from
jevonearth:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d0cea35
Remove `if __main__`, users should use
e2c090a
Print friendly error message when log file can't
758d654
Add `hrtb_ival` and `hrtb_ret_ival` as cli options
7c1db26
Test to cover hrtb_* param injection into
663e9db
Cosmetic clean ups, and deprecation fixes.
5d88f9c
Float support added to MyConfigParser
ae6ee11
Move try/except up to b2bua_radius.py
cb2426c
Correct indentation to stay consistent with existing code base.
342c2d2
Add tests to cover ValueErrors for sip_port and others.
3dd962d
Revert "Print friendly error message when log file can't"
0e4fa4b
Indent run on lines by 2 spaces only. Don't use two
0bbc6f2
Remove blank line as per code review feedback.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ def __init__(self, global_config, *address, **kwargs): | |
if kwargs.has_key('no_version_check'): | ||
no_version_check = kwargs['no_version_check'] | ||
del kwargs['no_version_check'] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the whole patch (Rtp_proxy_client.py). |
||
if len(address) == 0 and kwargs.has_key('spath'): | ||
a = kwargs['spath'] | ||
del kwargs['spath'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -750,14 +750,26 @@ def main_func(): | |
global_config.write(open(writeconf, 'w')) | ||
|
||
if not global_config['foreground']: | ||
daemonize(logfile = global_config['logfile']) | ||
try: | ||
daemonize(logfile = global_config['logfile']) | ||
except IOError as e: | ||
print("IOError: {}".format(e)) | ||
sys.exit(e.errno) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra blank line. |
||
global_config['_sip_logger'] = SipLogger('b2bua') | ||
|
||
if len(rtp_proxy_clients) > 0: | ||
global_config['_rtp_proxy_clients'] = [] | ||
for address in rtp_proxy_clients: | ||
global_config['_rtp_proxy_clients'].append(Rtp_proxy_client(global_config, spath = address)) | ||
client = Rtp_proxy_client(global_config, spath = address) | ||
|
||
if 'hrtb_ival' in global_config: | ||
client.hrtb_ival = global_config['hrtb_ival'] | ||
|
||
if 'hrtb_retr_ival' in global_config: | ||
client.hrtb_retr_ival = global_config['hrtb_retr_ival'] | ||
|
||
global_config['_rtp_proxy_clients'].append(client) | ||
|
||
if global_config['auth_enable'] or global_config['acct_enable']: | ||
global_config['_radius_client'] = RadiusAuthorisation(global_config) | ||
|
@@ -788,7 +800,3 @@ def main_func(): | |
|
||
reactor.suggestThreadPoolSize(50) | ||
reactor.run(installSignalHandlers = True) | ||
|
||
|
||
if __name__ == '__main__': | ||
main_func() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import unittest | ||
from sippy.MyConfigParser import MyConfigParser | ||
|
||
|
||
class TestMyConfigParser(unittest.TestCase): | ||
def TestParamHandling(self): | ||
m = MyConfigParser() | ||
m['_foo'] = 'bar' | ||
m['b2bua_socket'] = 'bar1' | ||
m['acct_enable'] = True | ||
m['auth_enable'] = 'False' | ||
|
||
self.assertTrue(m.has_key('_foo')) | ||
self.assertEqual(m['_foo'], 'bar') | ||
self.assertEqual(m['b2bua_socket'], 'bar1') | ||
self.assertEqual(m.get('_foo'), 'bar') | ||
self.assertEqual(m.get('b2bua_socket'), 'bar1') | ||
self.assertEqual(m.get('general', 'b2bua_socket'), 'bar1') | ||
self.assertTrue(m.get('acct_enable')) | ||
self.assertFalse(m.get('auth_enable')) | ||
|
||
m.check_and_set('keepalive_ans', '15') | ||
self.assertEqual(m['keepalive_ans'], 15) | ||
self.assertIsInstance(m.get('keepalive_ans'), int) | ||
|
||
m.check_and_set('pass_header', 'a') | ||
m.check_and_set('pass_header', 'b') | ||
|
||
self.assertEqual(m['pass_headers'], 'a,b') | ||
self.assertEqual(m['_pass_headers'][0], 'a') | ||
self.assertEqual(m['_pass_headers'][1], 'b') | ||
|
||
m.check_and_set('accept_ips', '1.2.3.4, 5.6.7.8') | ||
self.assertEqual(m['_accept_ips'][0], '1.2.3.4') | ||
self.assertEqual(m['_accept_ips'][1], '5.6.7.8') | ||
|
||
self.assertEqual(m.check_and_set('hrtb_ival', "1"), None) | ||
self.assertEqual(m['hrtb_ival'], 1) | ||
self.assertEqual(m.get('hrtb_ival'), 1) | ||
# Test that get method returns correct type | ||
self.assertIsInstance(m.get('hrtb_ival'), float) | ||
# Test that access by index returns correct type | ||
self.assertIsInstance(m['hrtb_ival'], float) | ||
|
||
with self.assertRaises(KeyError): | ||
m.check_and_set('non_existant_key', "1") | ||
|
||
def TestSipPortValidation(self): | ||
m = MyConfigParser() | ||
with self.assertRaises(ValueError): | ||
m.check_and_set('sip_port', "-1") | ||
with self.assertRaises(ValueError): | ||
m.check_and_set('sip_port', "0") | ||
with self.assertRaises(ValueError): | ||
m.check_and_set('sip_port', "65536") | ||
self.assertEquals(m.check_and_set('sip_port', "1"), None) | ||
self.assertEquals(m.check_and_set('sip_port', "65535"), None) | ||
|
||
def TestMaxCreditTime(self): | ||
m = MyConfigParser() | ||
with self.assertRaises(ValueError): | ||
m.check_and_set('max_credit_time', "-1") | ||
|
||
def TestMaxKeepAlive(self): | ||
m = MyConfigParser() | ||
with self.assertRaises(ValueError): | ||
m.check_and_set('keepalive_ans', "-1") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line.