easy_upnp 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +7 -0
- data/lib/easy_upnp/ssdp_searcher.rb +6 -25
- data/lib/easy_upnp/upnp_device.rb +10 -5
- data/lib/easy_upnp/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 017b7021b1d9c35fab09ff9f670a660c96758443
|
4
|
+
data.tar.gz: 793f938414da9e550a12b94aa90a05ba0de81480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71e31a046b94b3e99cb6f79d87da6f2ee92fd06f209960ae67d0cb7457864bac839dfda9312ce8205b5fb4d8ac57d6c81f6673643343c6f84f044ff15b4e45ac
|
7
|
+
data.tar.gz: 689804ce65c657638e8098403d7ea33571b0b6ca69bfc2cc16f63488fcc9d74b3639eb03d0da63facf86a1fc11bdfbf8f05871123e81ce048091f970a4ae561b
|
data/Rakefile
ADDED
@@ -10,8 +10,6 @@ module EasyUpnp
|
|
10
10
|
MULTICAST_PORT = 1900
|
11
11
|
|
12
12
|
DEFAULT_OPTIONS = {
|
13
|
-
:bind_addr => '0.0.0.0',
|
14
|
-
|
15
13
|
# Number of seconds to wait for responses
|
16
14
|
:timeout => 2,
|
17
15
|
|
@@ -35,13 +33,12 @@ module EasyUpnp
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def search urn
|
38
|
-
|
39
|
-
send_socket = build_send_socket
|
36
|
+
socket = build_socket
|
40
37
|
packet = construct_msearch_packet(urn)
|
41
38
|
|
42
39
|
# Send M-SEARCH packet over UDP socket
|
43
40
|
option(:repeat_queries).times do
|
44
|
-
|
41
|
+
socket.send packet, 0, MULTICAST_ADDR, MULTICAST_PORT
|
45
42
|
end
|
46
43
|
|
47
44
|
raw_messages = []
|
@@ -50,14 +47,13 @@ module EasyUpnp
|
|
50
47
|
begin
|
51
48
|
Timeout::timeout(option :timeout) do
|
52
49
|
loop do
|
53
|
-
raw_messages.push(
|
50
|
+
raw_messages.push(socket.recv(4196))
|
54
51
|
end
|
55
52
|
end
|
56
53
|
rescue Timeout::Error
|
57
54
|
# This is expected
|
58
55
|
ensure
|
59
|
-
|
60
|
-
listen_socket.close
|
56
|
+
socket.close
|
61
57
|
end
|
62
58
|
|
63
59
|
# Parse messages (extract HTTP headers)
|
@@ -101,22 +97,7 @@ ST: #{urn}\r
|
|
101
97
|
|
102
98
|
private
|
103
99
|
|
104
|
-
def
|
105
|
-
socket = UDPSocket.new
|
106
|
-
socket.do_not_reverse_lookup = true
|
107
|
-
|
108
|
-
membership = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new(option :bind_addr).hton
|
109
|
-
|
110
|
-
socket.setsockopt(:IPPROTO_IP, :IP_ADD_MEMBERSHIP, membership)
|
111
|
-
socket.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, true)
|
112
|
-
socket.setsockopt(:IPPROTO_IP, :IP_TTL, 1)
|
113
|
-
|
114
|
-
socket.bind(option(:bind_addr), MULTICAST_PORT)
|
115
|
-
|
116
|
-
socket
|
117
|
-
end
|
118
|
-
|
119
|
-
def build_send_socket
|
100
|
+
def build_socket
|
120
101
|
socket = UDPSocket.open
|
121
102
|
socket.do_not_reverse_lookup = true
|
122
103
|
|
@@ -126,4 +107,4 @@ ST: #{urn}\r
|
|
126
107
|
socket
|
127
108
|
end
|
128
109
|
end
|
129
|
-
|
110
|
+
end
|
@@ -27,12 +27,17 @@ module EasyUpnp
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Download one of the definitions to get the name of this device
|
30
|
-
|
30
|
+
if @service_definitions.any?
|
31
|
+
service_location = @service_definitions.first[:location]
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
xml = Nokogiri::XML(open(service_location))
|
34
|
+
xml.remove_namespaces!
|
35
|
+
@name = xml.xpath('//device/friendlyName').text
|
36
|
+
@host = URI.parse(service_location).host
|
37
|
+
else
|
38
|
+
@name = 'UNKNOWN'
|
39
|
+
@host = 'UNKNOWN'
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
38
43
|
def all_services
|
data/lib/easy_upnp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_upnp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Mullins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- Gemfile
|
91
91
|
- LICENSE
|
92
92
|
- README.md
|
93
|
+
- Rakefile
|
93
94
|
- easy_upnp.gemspec
|
94
95
|
- lib/easy_upnp/device_control_point.rb
|
95
96
|
- lib/easy_upnp/ssdp_searcher.rb
|