Skip to content

Commit 1b45846

Browse files
committed
make 'fifo' default comm type
add defaults for fifo in module and in opensips-mi script.
1 parent 9ef6927 commit 1b45846

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

opensips/mi/connector.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ class OpenSIPSMIException(Exception):
2626
pass
2727

2828
class OpenSIPSMI():
29-
def __init__(self, conn: str, **kwargs):
29+
def __init__(self, conn="fifo", **kwargs):
3030
if conn == "fifo":
31+
if "fifo_file" not in kwargs:
32+
kwargs["fifo_file"] = "/var/run/opensips/opensips_fifo"
33+
if "fifo_file_fallback" not in kwargs:
34+
kwargs["fifo_file_fallback"] = "/tmp/opensips_fifo"
35+
if "fifo_reply_dir" not in kwargs:
36+
kwargs["fifo_reply_dir"] = "/tmp"
3137
self.conn = FIFO(**kwargs)
3238
elif conn == "datagram":
3339
self.conn = Datagram(**kwargs)

scripts/opensips-mi

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ communication = parser.add_argument_group('communication')
2727

2828
communication.add_argument('-t', '--type',
2929
type=str,
30-
help='OpenSIPS MI Communication Type',
31-
default='http')
30+
help='OpenSIPS MI Communication Type')
3231
communication.add_argument('-i', '--ip',
3332
type=str,
3433
help='OpenSIPS MI IP Address',
@@ -37,6 +36,15 @@ communication.add_argument('-p', '--port',
3736
type=int,
3837
help='OpenSIPS MI Port',
3938
default=8888)
39+
communication.add_argument('-f', '--file',
40+
type=str,
41+
help='OpenSIPS MI FIFO File')
42+
communication.add_argument('-fb', '--fallback',
43+
type=str,
44+
help='OpenSIPS MI Fallback FIFO File')
45+
communication.add_argument('-fd', '--dir',
46+
type=str,
47+
help='OpenSIPS MI FIFO Reply Directory')
4048

4149
group = parser.add_mutually_exclusive_group(required=True)
4250

@@ -83,6 +91,16 @@ else:
8391
except json.JSONDecodeError as e:
8492
print('Invalid JSON: ', e)
8593
exit(1)
94+
95+
if not args.type or args.type == 'fifo':
96+
fifo_args = {}
97+
if args.file:
98+
fifo_args['file'] = args.file
99+
if args.fallback:
100+
fifo_args['fallback'] = args.fallback
101+
if args.dir:
102+
fifo_args['dir'] = args.dir
103+
mi = OpenSIPSMI('fifo', **fifo_args)
86104

87105
if args.type == 'http':
88106
mi = OpenSIPSMI('http', url='http://{}:{}/mi'.format(args.ip, args.port))

0 commit comments

Comments
 (0)