File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,34 @@ use warnings;
5
5
6
6
use IO::Socket::INET;
7
7
use Getopt::Long;
8
+ use Config::Tiny;
8
9
9
10
my $ip ;
10
11
my $port ;
12
+ my $conffile = ' /etc/rtpengine/rtpengine.conf' ;
13
+ my $listen ;
11
14
12
15
my $optret = GetOptions(
13
16
' help|h' => sub { showusage(); exit 0; },
14
17
' ip=s' => \$ip ,
15
18
' port=i' => \$port ,
19
+ ' config-file=s' => \$conffile ,
16
20
);
17
21
22
+ if (-f $conffile ) {
23
+ my $config = Config::Tiny-> read ($conffile );
24
+ $config or die " Failed to read config file: " . Config::Tiny-> errstr;
25
+
26
+ $listen = $config -> {rtpengine }{' listen-cli' }
27
+ if $config -> {rtpengine };
28
+ if ($listen =~ / ^\d +$ / ) {
29
+ $port //= $listen ;
30
+ }
31
+ else {
32
+ $ip //= $listen ;
33
+ }
34
+ }
35
+
18
36
if ($ip && $ip =~ s / :(\d +)$// ) {
19
37
$port = $1 ;
20
38
}
You can’t perform that action at this time.
0 commit comments