opensips-mi 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmZiZDk4M2Y0ZTUyZmE5ZTkxYjI4ZWJjMDM4ZGYzNDlmYjk1M2RmZg==
4
+ ZThhYmE0OGQxNWQ4ZTg2MGI0OWU3YTA2NmE1MjllZDJmYjU0YjIyYQ==
5
5
  data.tar.gz: !binary |-
6
- NTFhNTVjYWYzZGUyMmEyMDM2ZTk3OGJiYzUwY2EwMDU4ZTYzZDE2MQ==
6
+ MTQ4ZTAyYzViMWE2OGI3YmYzMTRhN2Y4Y2RhYWE3YWFmOTczMTc5Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTQ0YWQwNWUyZjQ3MTJhNDUxNmE3NDBiOTg3M2IyZDc0NzZiYTQ3ZDU1OTQx
10
- ODQ5OTJkNDQxZjE5OGFhZGJjYWI1MGFhYmFmYjU5NmVjYTIwZTg5ZGE5N2E0
11
- OWE0NTVmYTQ1ZjNkOGE0ODQ1N2MwNGM1NWZlZTVmMTI5OWFlZDU=
9
+ YWJmODcxMzQyNWM4MmEwNmYzOTkwYzg0MGI3NTJjY2JkZmE5MzZlYjA3OTNi
10
+ NmU1YWI0Yjg0NmNlZDI1MmM4NDRjODFhNTRjNTExZDRmYTA0NmEwYjc3YzRi
11
+ MjljMDJkOWJiZTJlZWI3MzMzYjY1ZTc3NDNlNTk5MjUzYmE2YjM=
12
12
  data.tar.gz: !binary |-
13
- ZWM5YjZjYTkzZDRlZGFlOWYzOWI1ODFjYTk2ZDQyNzhjOThlYjUzNzVhM2Q3
14
- YzRhNTUyZTQ2YzkzMTUzNjc1MjI0MDU3ZGJhMmI3NmM2NzUyMzEwYTYyOWMw
15
- NDk4MDUyMjU1ZTZhZmViYWVlYTdkMzA2N2M0M2RjMzQxYzAyNDA=
13
+ ZjUwNzE0ZTU2ODJjMTgwMTQ3NzgwZjgyODM5NjA3MWU4MjZjMjUyZGU4MjBk
14
+ ZmFlYjZkYmRkMjFkYTdhYmE4YWJmYzYzMzMyNGZhOTE1ZmMzYTllNDgzNzBl
15
+ YTc5MGY4MmIyZTlhNGVmNGU1NzhlZWE0M2VkYjI5ZDY2ZTkyNDg=
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Opensips::Mi
2
+ [![Build Status](https://travis-ci.org/staskobzar/opensips-mi.png?branch=master)](https://travis-ci.org/staskobzar/opensips-mi)
3
+ [![Code Climate](https://codeclimate.com/github/staskobzar/opensips-mi.png)](https://codeclimate.com/github/staskobzar/opensips-mi)
4
+ [![Gem Version](https://badge.fury.io/rb/opensips-mi.png)](http://badge.fury.io/rb/opensips-mi)
2
5
 
3
6
  OpenSIPs management interface library.
4
7
  This library supports following management interfaces OpenSIPs modules:
@@ -87,10 +87,8 @@ module Opensips
87
87
  headers = hf.map{|name,val| name.eql?("nl") ? "" : "#{name}: #{val}"}.join "\r\n"
88
88
  headers << "\r\n"
89
89
 
90
- # hack for xmlrpc which fails if headers are quoted
91
- headers = set_header(headers)
92
- #params = [method, ruri, next_hop, socket, "\"#{headers}\""]
93
- params = [method, ruri, next_hop, socket, headers]
90
+ # set_header is a hack for xmlrpc which fails if headers are quoted
91
+ params = [method, ruri, next_hop, socket, set_header(headers)]
94
92
  params << body unless body.nil?
95
93
  # send it and return Response
96
94
  command 't_uac_dlg', params
@@ -160,7 +158,20 @@ module Opensips
160
158
  uac_dlg "NOTIFY", uri, hf.merge(mbody)
161
159
  end
162
160
 
163
- def set_header(header);"\"#{header}\"";end
161
+ private
162
+ def set_header(header);"\"#{header}\"";end
163
+
164
+ def host_valid? params
165
+ raise ArgumentError,
166
+ 'Missing socket host' if params[:host].nil?
167
+ raise ArgumentError,
168
+ 'Missing socket port' if params[:port].nil?
169
+ Socket.getaddrinfo(params[:host], nil) rescue
170
+ raise SocketError, "Invalid host #{params[:host]}"
171
+ raise SocketError,
172
+ "Invalid port #{params[:port]}" unless (1..(2**16-1)).include?(params[:port])
173
+ true
174
+ end
164
175
 
165
176
  end
166
177
  end
@@ -11,14 +11,7 @@ module Opensips
11
11
  end
12
12
 
13
13
  def initialize(params)
14
- raise ArgumentError,
15
- 'Missing socket host' if params[:host].nil?
16
- raise ArgumentError,
17
- 'Missing socket port' if params[:port].nil?
18
- Socket.getaddrinfo(params[:host], nil) rescue
19
- raise SocketError, "Invalid host #{params[:host]}"
20
- raise SocketError,
21
- "Invalid port #{params[:port]}" unless (1..(2**16-1)).include?(params[:port])
14
+ host_valid? params
22
15
  @sock = UDPSocket.new
23
16
  @sock.connect params[:host], params[:port]
24
17
  end
@@ -10,14 +10,7 @@ module Opensips
10
10
  end
11
11
 
12
12
  def initialize(params)
13
- raise ArgumentError,
14
- 'Missing socket host' if params[:host].nil?
15
- raise ArgumentError,
16
- 'Missing socket port' if params[:port].nil?
17
- Socket.getaddrinfo(params[:host], nil) rescue
18
- raise SocketError, "Invalid host #{params[:host]}"
19
- raise SocketError,
20
- "Invalid port #{params[:port]}" unless (1..(2**16-1)).include?(params[:port])
13
+ host_valid? params
21
14
  uri = "http://#{params[:host]}:#{params[:port]}/#{RPCSEG}"
22
15
  @client = XMLRPC::Client.new_from_uri(uri, nil, 3)
23
16
  rescue => e
@@ -29,10 +22,10 @@ module Opensips
29
22
  response = ["200 OK"]
30
23
  response += @client.call(cmd, *params).split(?\n)
31
24
  response << ""
32
- Opensips::MI::Response.new response
33
25
  rescue => e
34
26
  response = ["600 " << e.message]
35
- Opensips::MI::Response.new response
27
+ ensure
28
+ return Opensips::MI::Response.new response
36
29
  end
37
30
 
38
31
  def set_header(header);header;end
@@ -1,5 +1,5 @@
1
1
  module Opensips
2
2
  module MI
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stas Kobzar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-16 00:00:00.000000000 Z
11
+ date: 2013-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.0.3
117
+ rubygems_version: 2.0.2
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: OpenSIPs management interface