rswim 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1acfab8998ff5ebd1919f16fd0e27c2f708224aedb004376ccbe2f5818bb6648
4
- data.tar.gz: 5c85faa591b08d74d38b2fb091ee56b1e836af3e863005e51cbd55e35df2f255
3
+ metadata.gz: d0488c9886f92df9a49c83521f881fdfc691ca2acfdf11deaef591a040a5e082
4
+ data.tar.gz: 16930933f6e7fd5ee4f464d9693d437a7a493e37015b79049ad3c4b2647ccf60
5
5
  SHA512:
6
- metadata.gz: a7c312893d1e1363675ad17ab97d7ad87dd016ab39ef4debb208016e970fdf9d8f1813fcfbe7f1c39ad8c0933765cf7b94fda82405dd732daa6bd9b3de2bba6e
7
- data.tar.gz: 858683dc2c970daaefb085e467249a62b37a1e88e6ad556d5a944112bd51e463cda530168ee0a4abda0d35b175a3aceb031e4b4346dea44f1205c900b43647d4
6
+ metadata.gz: 16e61b48d55d0f56d0803f2a86a48859c7896ad2fdc187fe474771a945549f60bac2b90793277f853ad510a5a22a6c3c92b1f341a8a905390196591786edebd0
7
+ data.tar.gz: 037e6ca91473d74c597107f2d711fceea3523beac4fab0060da984995d96bcee684f571bf578ea0934eb661792e28cb4ed735a07c32035c635f55e221a2a2cb7
data/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # 1.0.0 Complete implementation for UDP plus simple, human readable serialisation of messages
2
2
  # 2.0.0 Piggyback custom state on the liveness propagation mechanism using `RSwim::Node#append_custom_state`
3
3
  # 2.1.0 Use non-blocking I/O by means of `Fiber.shedule` with the scheduler provided by the Async gem
4
- # 2.2.0 Encrypted messages between peers. Run UDP Sender in fiber instead of thread to make whole node single threaded.
4
+ # 2.2.0 Encrypted messages between peers. Run UDP Sender in fiber instead of thread to make whole node single threaded.
5
+ # 2.3.0 Runs on current Ruby. `require 'rswim'` failed outright on Ruby 3.4 and later, because base64 and logger left the standard library and were never declared as dependencies. `RSwim::VERSION` was unreachable once the gem was loaded, since the loader expected version.rb to define `RSwim::Version`. Requires Ruby 3.3 or newer and async 2.x. The published gem no longer carries the development scripts, the Rakefile or the Guardfile.
data/lib/rswim/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSwim
4
- VERSION = '2.2.0'
4
+ VERSION = '2.3.0'
5
5
  end
data/lib/rswim.rb CHANGED
@@ -7,11 +7,7 @@ require 'async'
7
7
  require 'openssl'
8
8
  require 'base64'
9
9
 
10
- cipher = OpenSSL::Cipher::AES256.new :CBC
11
- cipher.encrypt
12
- iv = cipher.random_iv
13
- cipher.key = key = Digest::SHA256.digest 'SecretPassword'
14
- cipher_text = cipher.update('This is a secret message') + cipher.final
10
+ require_relative 'rswim/version'
15
11
 
16
12
  class MyInflector < Zeitwerk::Inflector
17
13
  def camelize(basename, _abspath)
@@ -26,6 +22,9 @@ end
26
22
 
27
23
  loader = Zeitwerk::Loader.for_gem
28
24
  loader.inflector = MyInflector.new
25
+ # version.rb defines RSwim::VERSION, not the RSwim::Version the loader would
26
+ # infer from the filename, so it is required above and left out of the loader.
27
+ loader.ignore("#{__dir__}/rswim/version.rb")
29
28
  loader.setup
30
29
 
31
30
  module RSwim
metadata CHANGED
@@ -1,15 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rswim
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Madsen
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: logger
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.6'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.6'
13
40
  - !ruby/object:Gem::Dependency
14
41
  name: zeitwerk
15
42
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +71,14 @@ dependencies:
44
71
  requirements:
45
72
  - - "~>"
46
73
  - !ruby/object:Gem::Version
47
- version: '1.30'
74
+ version: '2.0'
48
75
  type: :runtime
49
76
  prerelease: false
50
77
  version_requirements: !ruby/object:Gem::Requirement
51
78
  requirements:
52
79
  - - "~>"
53
80
  - !ruby/object:Gem::Version
54
- version: '1.30'
81
+ version: '2.0'
55
82
  - !ruby/object:Gem::Dependency
56
83
  name: bundler
57
84
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +99,14 @@ dependencies:
72
99
  requirements:
73
100
  - - "~>"
74
101
  - !ruby/object:Gem::Version
75
- version: '12.0'
102
+ version: '13.0'
76
103
  type: :development
77
104
  prerelease: false
78
105
  version_requirements: !ruby/object:Gem::Requirement
79
106
  requirements:
80
107
  - - "~>"
81
108
  - !ruby/object:Gem::Version
82
- version: '12.0'
109
+ version: '13.0'
83
110
  - !ruby/object:Gem::Dependency
84
111
  name: rspec
85
112
  requirement: !ruby/object:Gem::Requirement
@@ -145,21 +172,9 @@ executables: []
145
172
  extensions: []
146
173
  extra_rdoc_files: []
147
174
  files:
148
- - ".gitignore"
149
- - ".rspec"
150
- - ".travis.yml"
151
175
  - CHANGELOG.md
152
- - Gemfile
153
- - Gemfile.lock
154
- - Guardfile
155
176
  - LICENSE.txt
156
177
  - README.md
157
- - Rakefile
158
- - bin/async_loop
159
- - bin/console
160
- - bin/encrypt
161
- - bin/run_node
162
- - bin/setup
163
178
  - lib/rswim.rb
164
179
  - lib/rswim/agent.rb
165
180
  - lib/rswim/directory.rb
@@ -198,9 +213,6 @@ files:
198
213
  - lib/rswim/status_report.rb
199
214
  - lib/rswim/update_entry.rb
200
215
  - lib/rswim/version.rb
201
- - log/.keep
202
- - rswim.gemspec
203
- - tmp/.keep
204
216
  homepage: https://github.com/beatmadsen/rswim
205
217
  licenses:
206
218
  - MIT
@@ -208,7 +220,9 @@ metadata:
208
220
  homepage_uri: https://github.com/beatmadsen/rswim
209
221
  source_code_uri: https://github.com/beatmadsen/rswim
210
222
  changelog_uri: https://github.com/beatmadsen/rswim/blob/master/CHANGELOG.md
211
- post_install_message:
223
+ bug_tracker_uri: https://github.com/beatmadsen/rswim/issues
224
+ documentation_uri: https://github.com/beatmadsen/rswim#readme
225
+ rubygems_mfa_required: 'true'
212
226
  rdoc_options: []
213
227
  require_paths:
214
228
  - lib
@@ -216,15 +230,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
230
  requirements:
217
231
  - - ">="
218
232
  - !ruby/object:Gem::Version
219
- version: 3.0.0
233
+ version: '3.3'
220
234
  required_rubygems_version: !ruby/object:Gem::Requirement
221
235
  requirements:
222
236
  - - ">="
223
237
  - !ruby/object:Gem::Version
224
238
  version: '0'
225
239
  requirements: []
226
- rubygems_version: 3.3.3
227
- signing_key:
240
+ rubygems_version: 4.0.9
228
241
  specification_version: 4
229
242
  summary: Ruby implementation of the SWIM gossip protocol
230
243
  test_files: []
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
-
9
- # Ignore all logfiles and tempfiles.
10
- /log/*
11
- /tmp/*
12
- !/log/.keep
13
- !/tmp/.keep
14
-
15
- # rspec failure tracking
16
- .rspec_status
17
- .byebug_history
18
- .ruby-version
19
- .DS_Store
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format Fuubar
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in rswim.gemspec
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,91 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- rswim (2.2.0)
5
- async (~> 1.30)
6
- slop (~> 4.9)
7
- zeitwerk (~> 2.2)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- async (1.30.1)
13
- console (~> 1.10)
14
- nio4r (~> 2.3)
15
- timers (~> 4.1)
16
- byebug (11.1.3)
17
- coderay (1.1.3)
18
- console (1.14.0)
19
- fiber-local
20
- diff-lcs (1.5.0)
21
- ffi (1.15.5)
22
- fiber-local (1.0.0)
23
- formatador (1.1.0)
24
- fuubar (2.5.1)
25
- rspec-core (~> 3.0)
26
- ruby-progressbar (~> 1.4)
27
- guard (2.18.0)
28
- formatador (>= 0.2.4)
29
- listen (>= 2.7, < 4.0)
30
- lumberjack (>= 1.0.12, < 2.0)
31
- nenv (~> 0.1)
32
- notiffany (~> 0.0)
33
- pry (>= 0.13.0)
34
- shellany (~> 0.0)
35
- thor (>= 0.18.1)
36
- guard-compat (1.2.1)
37
- guard-rspec (4.7.3)
38
- guard (~> 2.1)
39
- guard-compat (~> 1.1)
40
- rspec (>= 2.99.0, < 4.0)
41
- listen (3.7.1)
42
- rb-fsevent (~> 0.10, >= 0.10.3)
43
- rb-inotify (~> 0.9, >= 0.9.10)
44
- lumberjack (1.2.8)
45
- method_source (1.0.0)
46
- nenv (0.3.0)
47
- nio4r (2.5.8)
48
- notiffany (0.1.3)
49
- nenv (~> 0.1)
50
- shellany (~> 0.0)
51
- pry (0.14.1)
52
- coderay (~> 1.1)
53
- method_source (~> 1.0)
54
- rake (12.3.3)
55
- rb-fsevent (0.11.1)
56
- rb-inotify (0.10.1)
57
- ffi (~> 1.0)
58
- rspec (3.11.0)
59
- rspec-core (~> 3.11.0)
60
- rspec-expectations (~> 3.11.0)
61
- rspec-mocks (~> 3.11.0)
62
- rspec-core (3.11.0)
63
- rspec-support (~> 3.11.0)
64
- rspec-expectations (3.11.0)
65
- diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.11.0)
67
- rspec-mocks (3.11.0)
68
- diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.11.0)
70
- rspec-support (3.11.0)
71
- ruby-progressbar (1.11.0)
72
- shellany (0.0.1)
73
- slop (4.9.1)
74
- thor (1.2.1)
75
- timers (4.3.3)
76
- zeitwerk (2.5.4)
77
-
78
- PLATFORMS
79
- ruby
80
-
81
- DEPENDENCIES
82
- bundler (>= 2.2.10)
83
- byebug
84
- fuubar (~> 2.5)
85
- guard-rspec (~> 4.7)
86
- rake (~> 12.0)
87
- rspec (~> 3.0)
88
- rswim!
89
-
90
- BUNDLED WITH
91
- 2.2.22
data/Guardfile DELETED
@@ -1,42 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- ## Uncomment and set this to only include directories you want to watch
5
- # directories %w(app lib config test spec features) \
6
- # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
-
8
- ## Note: if you are using the `directories` clause above and you are not
9
- ## watching the project directory ('.'), then you will want to move
10
- ## the Guardfile to a watched dir and symlink it back, e.g.
11
- #
12
- # $ mkdir config
13
- # $ mv Guardfile config/
14
- # $ ln -s config/Guardfile .
15
- #
16
- # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
-
18
- # Note: The cmd option is now required due to the increasing number of ways
19
- # rspec may be run, below are examples of the most common uses.
20
- # * bundler: 'bundle exec rspec'
21
- # * bundler binstubs: 'bin/rspec'
22
- # * spring: 'bin/rspec' (This will use spring if running and you have
23
- # installed the spring binstubs per the docs)
24
- # * zeus: 'zeus rspec' (requires the server to be started separately)
25
- # * 'just' rspec: 'rspec'
26
-
27
- guard :rspec, cmd: "bundle exec rspec" do
28
- require "guard/rspec/dsl"
29
- dsl = Guard::RSpec::Dsl.new(self)
30
-
31
- # Feel free to open issues for suggestions and improvements
32
-
33
- # RSpec files
34
- rspec = dsl.rspec
35
- watch(rspec.spec_helper) { rspec.spec_dir }
36
- watch(rspec.spec_support) { rspec.spec_dir }
37
- watch(rspec.spec_files)
38
-
39
- # Ruby files
40
- ruby = dsl.ruby
41
- dsl.watch_spec_files_for(ruby.lib_files)
42
- end
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/async_loop DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby --jit
2
- require 'bundler/setup'
3
- require 'async'
4
- require 'rswim'
5
-
6
- PORT = 4545
7
-
8
- @stuff = []
9
-
10
- def read
11
- if @stuff.empty?
12
- sleep 2
13
- end
14
- Array.new(@stuff.size) { @stuff.pop }
15
- end
16
-
17
- puts "Ready\n"
18
- begin
19
- # Run node (blocking)
20
- Async do
21
- Fiber.schedule do
22
- in_s = UDPSocket.new
23
- my_host = "localhost" # Socket.ip_address_list.find(&:ipv4_private?).ip_address
24
-
25
- in_s.bind(my_host, PORT)
26
- loop do
27
- text, sender = in_s.recvfrom(10_000)
28
- puts "received #{text} from network"
29
- @stuff << text
30
- end
31
- end
32
- loop { puts "Read: #{read }" }
33
- end
34
- rescue Interrupt
35
- puts "\nShutting down gracefully"
36
- end
37
- puts "\nDone"
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "rswim"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/encrypt DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby --jit
2
-
3
- require 'openssl'
4
- require 'console'
5
-
6
- cipher = OpenSSL::Cipher::AES256.new :CBC
7
- cipher.encrypt
8
- iv = cipher.random_iv
9
- cipher.key = key = Digest::SHA256.digest 'SecretPassword'
10
- cipher_text = cipher.update('This is a secret message') + cipher.final
11
-
12
- Console.logger.info cipher_text, 'got this after encrypting'
13
-
14
- begin
15
- decipher = OpenSSL::Cipher::AES256.new :CBC
16
- decipher.decrypt
17
- decipher.iv = iv # previously saved
18
- decipher.key = Digest::SHA256.digest 'mismatch'
19
- plain_text = decipher.update(cipher_text) + decipher.final
20
-
21
- Console.logger.info plain_text, 'got this after decrypting'
22
- rescue OpenSSL::Cipher::CipherError => e
23
- Console.logger.error('Error while decrypting')
24
- Console.logger.failure(decipher, e)
25
- end
data/bin/run_node DELETED
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env ruby --jit
2
- require 'bundler/setup'
3
- require 'slop'
4
- require 'rswim'
5
-
6
- PORT = 4545
7
-
8
- opts = Slop.parse do |o|
9
- o.array '-s', '--seeds', 'a comma separated list of seed nodes'
10
- o.bool '-d', '--debug', 'turn on debug logging'
11
- o.bool '-e', '--encrypted', 'use encrypted mode'
12
- o.string '--secret', 'shared secret for encrypted mode', default: 'santa 2000'
13
- o.on '--help' do
14
- puts o
15
- exit
16
- end
17
- o.on '-v', '--version' do
18
- puts RSwim::VERSION
19
- exit
20
- end
21
- end
22
-
23
- puts "Ruby version: #{RUBY_VERSION}"
24
-
25
- RSwim::Logger.level = ::Logger::DEBUG if opts.debug?
26
-
27
- if opts.encrypted?
28
- RSwim.encrypted = true
29
- RSwim.shared_secret = opts[:secret]
30
- end
31
-
32
- seed_hosts = opts[:seeds]
33
- abort 'EOF' if seed_hosts.nil?
34
-
35
- if seed_hosts.empty?
36
- puts 'Operating with no seed nodes'
37
- else
38
- seed_hosts.each { |h| puts "Seed node: #{h}" }
39
- end
40
-
41
- puts 'Starting node'
42
-
43
- # Instantiate node, setting my_host to nil to auto detect host IP.
44
- node = RSwim::Node.udp(nil, seed_hosts, PORT, 3_500, 1_000)
45
-
46
- # Subscribe to updates
47
- node.subscribe do |host, status, custom_state|
48
- puts "Update: #{host} entered liveness state #{status} with custom state #{custom_state}"
49
- end
50
-
51
- Thread.new do
52
- uptime = 0
53
- loop do
54
- sleep(5)
55
- uptime += 5
56
- node.append_custom_state(:uptime_seconds, uptime)
57
- end
58
- end.abort_on_exception = true
59
-
60
- puts "Ready\n"
61
- begin
62
- # Run node (blocking)
63
- node.start
64
- rescue Interrupt
65
- puts "\nShutting down gracefully"
66
- end
67
- puts "\nDone"
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/log/.keep DELETED
File without changes
data/rswim.gemspec DELETED
@@ -1,41 +0,0 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "rswim/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "rswim"
7
- spec.version = RSwim::VERSION
8
- spec.authors = ["Erik Madsen"]
9
- spec.email = ["beatmadsen@gmail.com"]
10
-
11
- spec.summary = %q{Ruby implementation of the SWIM gossip protocol}
12
- spec.description = %q{RSwim is a Ruby implementation of the SWIM gossip protocol, a mechanism for discovering new peers and getting updates about liveness of existing peers in a network.}
13
- spec.homepage = "https://github.com/beatmadsen/rswim"
14
- spec.license = "MIT"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/beatmadsen/rswim"
18
- spec.metadata["changelog_uri"] = "https://github.com/beatmadsen/rswim/blob/master/CHANGELOG.md"
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
- end
25
- spec.bindir = "exe"
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
28
-
29
- spec.required_ruby_version = '>= 3.0.0'
30
-
31
- spec.add_dependency 'zeitwerk', '~> 2.2'
32
- spec.add_dependency 'slop', '~> 4.9'
33
- spec.add_dependency 'async', '~> 1.30'
34
-
35
- spec.add_development_dependency "bundler", ">= 2.2.10"
36
- spec.add_development_dependency "rake", "~> 12.0"
37
- spec.add_development_dependency "rspec", "~> 3.0"
38
- spec.add_development_dependency 'guard-rspec', '~> 4.7'
39
- spec.add_development_dependency 'fuubar', '~> 2.5'
40
- spec.add_development_dependency 'byebug'
41
- end
data/tmp/.keep DELETED
File without changes