opensips-mi 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +3 -0
- data/lib/opensips/mi.rb +1 -1
- data/lib/opensips/mi/transport/datagram.rb +10 -11
- data/lib/opensips/mi/version.rb +1 -1
- data/opensips-mi.gemspec +4 -3
- data/spec/transport_spec.rb +4 -4
- metadata +28 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc7093889a67efa9694b4fbd1617044d7fab88d876e7aba8ba20b5385ba67f5
|
4
|
+
data.tar.gz: a03613f39146e109c1de1949b48802fdcf84b2a73ae41247858dcab5429b38b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 955848e500a74ebe27065494ad83353ae04c8c0710f824242d02195b3dfdffefb0a2a8d984b73dd7b4bb578bcf26dcf7f799e79d31e54d10598657fb70ffdc3f
|
7
|
+
data.tar.gz: b24b7f8e3f27c9b9bc4f544bd0f60c63da346cbd759a61e2be5628907d671782e564fa013ba930465f3ebb23b27313c8fb55588d4e10920c05f494c856a4aa28
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,9 @@ This library supports following management interfaces OpenSIPs modules:
|
|
11
11
|
* mi_datagram
|
12
12
|
* mi_xmlrpc
|
13
13
|
|
14
|
+
## Disclamer
|
15
|
+
This is old version and works only with olde openisips versions (older then v3)
|
16
|
+
|
14
17
|
## Installation
|
15
18
|
|
16
19
|
Add this line to your application's Gemfile:
|
data/lib/opensips/mi.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'timeout'
|
2
|
-
|
3
1
|
module Opensips
|
4
2
|
module MI
|
5
3
|
module Transport
|
@@ -15,8 +13,7 @@ module Opensips
|
|
15
13
|
|
16
14
|
def initialize(params)
|
17
15
|
host_valid? params
|
18
|
-
@sock =
|
19
|
-
@sock.connect params[:host], params[:port]
|
16
|
+
@sock = Socketry::UDP::Socket.connect(params[:host], params[:port])
|
20
17
|
@timeout = params[:timeout].to_i
|
21
18
|
end
|
22
19
|
|
@@ -25,13 +22,7 @@ module Opensips
|
|
25
22
|
params.each do |c|
|
26
23
|
request << "#{c}\n"
|
27
24
|
end
|
28
|
-
|
29
|
-
@sock.send request, 0
|
30
|
-
}
|
31
|
-
# will raise Errno::ECONNREFUSED if failed to connect
|
32
|
-
Timeout::timeout(tout,nil,"Timeout receive respond from datagram MI") {
|
33
|
-
response, = @sock.recvfrom RECVMAXLEN
|
34
|
-
}
|
25
|
+
response = send(request)
|
35
26
|
Opensips::MI::Response.new response.split(?\n)
|
36
27
|
end
|
37
28
|
|
@@ -39,6 +30,14 @@ module Opensips
|
|
39
30
|
@timeout > 0 ? @timeout : TIMEOUT
|
40
31
|
end
|
41
32
|
|
33
|
+
private
|
34
|
+
def send(request)
|
35
|
+
@sock.send request
|
36
|
+
response = @sock.recvfrom RECVMAXLEN, timeout: tout
|
37
|
+
response.message
|
38
|
+
rescue => e
|
39
|
+
"500 #{e}"
|
40
|
+
end
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
data/lib/opensips/mi/version.rb
CHANGED
data/opensips-mi.gemspec
CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "xmlrpc", "~> 0.3"
|
21
|
+
spec.add_dependency "socketry", "~> 0.5"
|
21
22
|
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
25
26
|
end
|
data/spec/transport_spec.rb
CHANGED
@@ -78,11 +78,11 @@ describe Transport do
|
|
78
78
|
expect(mi.tout).to be(15)
|
79
79
|
end
|
80
80
|
|
81
|
-
it "must
|
81
|
+
it "must return socket error" do
|
82
82
|
mi=Opensips::MI.connect :datagram, {:host => "10.0.0.1", :port => 8088, :timeout => 1}
|
83
|
-
expect
|
84
|
-
|
85
|
-
|
83
|
+
expect(mi.uptime.code).to be(500)
|
84
|
+
expect(mi.uptime.success).to be_falsey
|
85
|
+
expect(mi.uptime.message).to eq("recvfrom timed out after 1 seconds")
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opensips-mi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas Kobzar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xmlrpc
|
@@ -25,47 +25,61 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: socketry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
33
|
+
version: '0.5'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: '0'
|
69
83
|
description: Ruby module for interacting with OpenSIPs management interface
|
70
84
|
email:
|
71
85
|
- staskobzar@gmail.com
|