ssdp 1.1.4 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/lib/ssdp/consumer.rb +10 -3
- data/lib/ssdp/producer.rb +3 -3
- data/lib/ssdp.rb +3 -2
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b2e2dc8c0115e7fd095824e0a57188bc9c5950c85bb3f0f320d2684fbc8f80e1
|
4
|
+
data.tar.gz: c2d580c2f3a7ec13b5e5dc34807f3195e674b887c5126f2c264a17838fd17765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2346f24f510042a62d02f9e42ea9e4ebbb732deee17066e5963eb0a3490d5868e28a1eb9ada0ce95a3e14cb7f46f75d17d2fd438d03ae0477664825e06f6a221
|
7
|
+
data.tar.gz: 30ee2476c03ee7657588dc67629579955f70f0c458c6adccc873ec5863ae43d3403df21e0252d8d88c7b352054b34f4d5ec187740e8a0710e77f7b82ada3b681
|
data/LICENSE
CHANGED
data/lib/ssdp/consumer.rb
CHANGED
@@ -5,7 +5,7 @@ module SSDP
|
|
5
5
|
class Consumer
|
6
6
|
def initialize(options={})
|
7
7
|
@options = SSDP::DEFAULTS.merge options
|
8
|
-
@search_socket = SSDP.create_broadcaster
|
8
|
+
@search_socket = SSDP.create_broadcaster @options
|
9
9
|
@watch = {
|
10
10
|
:socket => nil,
|
11
11
|
:thread => nil,
|
@@ -48,9 +48,15 @@ module SSDP
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def compose_search(options)
|
51
|
+
if(options[:timeout].to_i > 1)
|
52
|
+
max_delay = options[:timeout].to_i - 1
|
53
|
+
else
|
54
|
+
max_delay = 1
|
55
|
+
end
|
51
56
|
query = "M-SEARCH * HTTP/1.1\n" \
|
52
|
-
"
|
53
|
-
"
|
57
|
+
"HOST: #{options[:broadcast]}:#{options[:port]}\n" \
|
58
|
+
"MAN: \"ssdp:discover\"\n" \
|
59
|
+
"MX: #{max_delay}\n"
|
54
60
|
query += "ST: #{options[:service]}\n" if options[:service]
|
55
61
|
options[:params].each { |key, val| query += "#{key}: #{val}\n" } if options[:params]
|
56
62
|
query + "\n"
|
@@ -96,6 +102,7 @@ module SSDP
|
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
105
|
+
result = nil unless found
|
99
106
|
if options[:synchronous]
|
100
107
|
result
|
101
108
|
else
|
data/lib/ssdp/producer.rb
CHANGED
@@ -85,7 +85,7 @@ module SSDP
|
|
85
85
|
|
86
86
|
def send_notification(type, params)
|
87
87
|
notify_body = "NOTIFY * HTTP/1.1\r\n" \
|
88
|
-
"
|
88
|
+
"HOST: #{@options[:broadcast]}:#{@options[:port]}\r\n" \
|
89
89
|
"NTS: ssdp:alive\r\n" \
|
90
90
|
"NT: #{type}\r\n" \
|
91
91
|
"USN: uuid:#{@uuid}\r\n" +
|
@@ -97,7 +97,7 @@ module SSDP
|
|
97
97
|
|
98
98
|
def send_bye_bye(type, params)
|
99
99
|
bye_bye_body = "NOTIFY * HTTP/1.1\r\n" \
|
100
|
-
"
|
100
|
+
"HOST: #{@options[:broadcast]}:#{@options[:port]}\r\n" \
|
101
101
|
"NTS: ssdp:byebye\r\n" \
|
102
102
|
"NT: #{type}\r\n" \
|
103
103
|
"USN: uuid:#{@uuid}\r\n" +
|
@@ -114,7 +114,7 @@ module SSDP
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def send_broadcast_packet(body)
|
117
|
-
broadcaster = SSDP.create_broadcaster
|
117
|
+
broadcaster = SSDP.create_broadcaster @options
|
118
118
|
broadcaster.send body, 0, @options[:broadcast], @options[:port]
|
119
119
|
broadcaster.close
|
120
120
|
end
|
data/lib/ssdp.rb
CHANGED
@@ -56,10 +56,11 @@ module SSDP
|
|
56
56
|
end
|
57
57
|
module_function :create_listener
|
58
58
|
|
59
|
-
def create_broadcaster
|
59
|
+
def create_broadcaster(options)
|
60
60
|
broadcaster = UDPSocket.new
|
61
61
|
broadcaster.setsockopt Socket::SOL_SOCKET, Socket::SO_BROADCAST, true
|
62
|
-
broadcaster.setsockopt
|
62
|
+
broadcaster.setsockopt Socket::IPPROTO_IP, Socket::IP_MULTICAST_TTL, 1
|
63
|
+
broadcaster.setsockopt Socket::IPPROTO_IP, Socket::IP_MULTICAST_IF, IPAddr.new(options[:bind]).hton
|
63
64
|
broadcaster
|
64
65
|
end
|
65
66
|
module_function :create_broadcaster
|
metadata
CHANGED
@@ -1,47 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssdp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Darcy Aumiller
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: SSDP client/server library. Server notify/part/respond; client search/listen.
|
14
|
-
email:
|
14
|
+
email: darcy.aumiller@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- LICENSE
|
19
20
|
- lib/ssdp.rb
|
20
|
-
- lib/ssdp/producer.rb
|
21
21
|
- lib/ssdp/consumer.rb
|
22
|
-
-
|
22
|
+
- lib/ssdp/producer.rb
|
23
23
|
homepage: https://github.com/daumiller/ssdp
|
24
24
|
licenses:
|
25
|
-
- BSD
|
25
|
+
- BSD-2-Clause
|
26
26
|
metadata: {}
|
27
|
-
post_install_message:
|
27
|
+
post_install_message:
|
28
28
|
rdoc_options: []
|
29
29
|
require_paths:
|
30
30
|
- lib
|
31
31
|
required_ruby_version: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 1.9.0
|
36
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
|
-
|
43
|
-
|
44
|
-
signing_key:
|
42
|
+
rubygems_version: 3.3.7
|
43
|
+
signing_key:
|
45
44
|
specification_version: 4
|
46
45
|
summary: SSDP client/server library.
|
47
46
|
test_files: []
|