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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9b537aea2b9857010e1ced84947e190ed89241fd
4
- data.tar.gz: 96e3911f9c1869fe28250708e2e84aff582478a1
2
+ SHA256:
3
+ metadata.gz: b2e2dc8c0115e7fd095824e0a57188bc9c5950c85bb3f0f320d2684fbc8f80e1
4
+ data.tar.gz: c2d580c2f3a7ec13b5e5dc34807f3195e674b887c5126f2c264a17838fd17765
5
5
  SHA512:
6
- metadata.gz: 7432a41ef51815d212485a42cfdf016a0ec1e51c5de16e2242ab9e89bc3f12d53d10370489f63694231abe56f380a4939a47e7399b6a61028be6c8ee6b015e73
7
- data.tar.gz: 380bf66161e631ee93547e0e1875bb1e12754ef3deecf25c9df9a38c01baf2093635a7b31ae4ae90c5c66c41e622036c280bc25ae90a0037226482cf3689dfde
6
+ metadata.gz: 2346f24f510042a62d02f9e42ea9e4ebbb732deee17066e5963eb0a3490d5868e28a1eb9ada0ce95a3e14cb7f46f75d17d2fd438d03ae0477664825e06f6a221
7
+ data.tar.gz: 30ee2476c03ee7657588dc67629579955f70f0c458c6adccc873ec5863ae43d3403df21e0252d8d88c7b352054b34f4d5ec187740e8a0710e77f7b82ada3b681
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2015, Dillon Aumiller
1
+ Copyright © 2022, Darcy Aumiller
2
2
  All rights reserved.
3
3
 
4
4
  BSD 2-Clause License
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
- "Host: #{options[:broadcast]}:#{options[:port]}\n" \
53
- "Man: \"ssdp:discover\"\n"
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
- "Host: #{@options[:broadcast]}:#{@options[:port]}\r\n" \
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
- "Host: #{@options[:broadcast]}:#{@options[:port]}\r\n" \
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 :IPPROTO_IP, :IP_MULTICAST_TTL, 1
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.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Dillon Aumiller
8
- autorequire:
7
+ - Darcy Aumiller
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-09 00:00:00.000000000 Z
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: dillonaumiller@gmail.com
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
- - LICENSE
22
+ - lib/ssdp/producer.rb
23
23
  homepage: https://github.com/daumiller/ssdp
24
24
  licenses:
25
- - BSD 2-Clause
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
- rubyforge_project:
43
- rubygems_version: 2.0.14
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: []