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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 135298241a7da04c8011bdc51fd903c62b04dbfb05de49cce7610544fee9f274
4
- data.tar.gz: 25a7bede110b7b35b121baddb04c2da6588d6fb8de3d9914cc84f6fd79041ef2
3
+ metadata.gz: 0fc7093889a67efa9694b4fbd1617044d7fab88d876e7aba8ba20b5385ba67f5
4
+ data.tar.gz: a03613f39146e109c1de1949b48802fdcf84b2a73ae41247858dcab5429b38b6
5
5
  SHA512:
6
- metadata.gz: 273474a444d49d471180eb7051cd57dc34e1c8c21146429cb649fab1134c5b4c6f604c0762a3a97005c4f340c7c4d379e95a0e89935d7511a1f5c1654c7edbc6
7
- data.tar.gz: 7aca0cdf36610f3f4db77864d215ec9b214acaebfcac25345e2f8042997614f62e44f47e8914f06717f0d1cb9186e62df391524a2ae5bcef7246f7c3adb278c4
6
+ metadata.gz: 955848e500a74ebe27065494ad83353ae04c8c0710f824242d02195b3dfdffefb0a2a8d984b73dd7b4bb578bcf26dcf7f799e79d31e54d10598657fb70ffdc3f
7
+ data.tar.gz: b24b7f8e3f27c9b9bc4f544bd0f60c63da346cbd759a61e2be5628907d671782e564fa013ba930465f3ebb23b27313c8fb55588d4e10920c05f494c856a4aa28
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.8
3
+ - 2.6.3
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,7 +1,7 @@
1
1
  require 'ostruct'
2
2
  require 'fcntl'
3
3
  require 'securerandom'
4
- require 'socket'
4
+ require 'socketry'
5
5
  require 'xmlrpc/client'
6
6
 
7
7
  require "opensips/mi/version"
@@ -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 = UDPSocket.new
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
- Timeout::timeout(tout, nil, "Timeout send request to datagram MI") {
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
@@ -1,5 +1,5 @@
1
1
  module Opensips
2
2
  module MI
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
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", "~>2.2.5"
23
- spec.add_development_dependency "rake", "~>13.0.3"
24
- spec.add_development_dependency "rspec", "~>3.10.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
25
26
  end
@@ -78,11 +78,11 @@ describe Transport do
78
78
  expect(mi.tout).to be(15)
79
79
  end
80
80
 
81
- it "must foo" do
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
- mi.uptime
85
- }.to raise_error Timeout::Error
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.10
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-01-13 00:00:00.000000000 Z
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: bundler
28
+ name: socketry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.5
34
- type: :development
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: 2.2.5
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: 13.0.3
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: 13.0.3
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: 3.10.0
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: 3.10.0
82
+ version: '0'
69
83
  description: Ruby module for interacting with OpenSIPs management interface
70
84
  email:
71
85
  - staskobzar@gmail.com