buschtelefon 0.4.0 → 0.4.1

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: 647eca794f57af404842ca0e5807e7c9ef57bcd8
4
- data.tar.gz: 05b6225fbcb926ad2e286dbe0904ea6b322af450
2
+ SHA256:
3
+ metadata.gz: 17ed2d463f57f40cab25df7895ce45fc1da041f9395d8e76f7f6af953e278c61
4
+ data.tar.gz: 2b4179b89ed1d20fa0553ea31b4a532df503af2cb5261297e0776d28e9e40fa6
5
5
  SHA512:
6
- metadata.gz: 6ff6c5e1dc9e2aa907f7ec47eef2b2246dbf1ced27ddd7050693527dbb4121d0966092cccebeb22410626ecb0f617198d31a0346b94a910dc61ceb5f48492e58
7
- data.tar.gz: 571f2b5304c578859118b149c73ed3b72a8710ab212d5a5ca318d7823364a1d2827db4e7b680129c12c346de70f4f028b2c773871821f336cf9b593aeb69e2d6
6
+ metadata.gz: 483bc25dc8409bf00a6e896fdd92246e07d28a90b88efc59d60e2ba906d2f53a4ce392f01794b8f990ec0ea92d0a6e05f8d7fcb845184bf7426e7b0e9fc29f3b
7
+ data.tar.gz: 1228512ba3adad9dfaa43e19984b356161d1e133e7e1fea01f80eb6040490f98785a7067067490f2a001d698e0ddfeddfa35eaf87b70d945aaac337a8ea863b1
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.10
1
+ 2.3.8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ * `NetTattler` can now be configured with a host it should bind to.
6
+
3
7
  ## 0.4.0
4
8
 
5
9
  * `NetTattler` now sends inquired payload back to requester
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in buschtelefon.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -38,8 +38,8 @@ You can setup your local tattling meshnet the following way:
38
38
  require 'buschtelefon'
39
39
  include Buschtelefon
40
40
 
41
- aunt_may = NetTattler.new
42
- aunt_ruth = NetTattler.new
41
+ aunt_may = NetTattler.new(host: '127.0.0.1')
42
+ aunt_ruth = NetTattler.new(host: '127.0.0.1')
43
43
  remote_aunt_ruth = RemoteTattler.new(host: '127.0.0.1', port: aunt_ruth.port)
44
44
 
45
45
  aunt_may.connect(remote_aunt_ruth)
@@ -53,6 +53,9 @@ puts aunt_may.knowledge
53
53
  puts aunt_ruth.knowledge
54
54
  ```
55
55
 
56
+ **Comfortability hint:** Be aware that `NetTattler` binds itself to `127.0.0.1` per default.
57
+ Use `NetTattler.new(host: '0.0.0.0')` to bind it on all interfaces.
58
+
56
59
  ## Development
57
60
 
58
61
  After checking out the repo, run `bin/setup` to install dependencies.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'cucumber/rake/task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "cucumber/rake/task"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  Cucumber::Rake::Task.new(:cucumber)
data/bin/check CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  set -e
4
4
 
5
+ if ruby -e "exit(1) unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')"; then
6
+ bundle exec standardrb --fix
7
+ fi
8
+
5
9
  bundle exec rspec
6
10
  bundle exec cucumber
7
-
data/bin/run CHANGED
@@ -36,8 +36,8 @@ tattlers[:E].connect(tattlers[:D])
36
36
  puts 'Feeding locals'
37
37
  tattlers[:A].feed(Gossip.new('Tezos'))
38
38
 
39
- simon = NetTattler.new
40
- josua = NetTattler.new
39
+ simon = NetTattler.new(host: '127.0.0.1')
40
+ josua = NetTattler.new(host: '127.0.0.1')
41
41
  remote_simon = josua.connect_remote(host: '127.0.0.1', port: simon.port)
42
42
 
43
43
  threads = [
data/buschtelefon.gemspec CHANGED
@@ -1,31 +1,35 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'buschtelefon/version'
3
+ require "buschtelefon/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'buschtelefon'
7
- spec.version = Buschtelefon::VERSION
8
- spec.authors = ['Josua Schmid']
9
- spec.email = ['josua.schmid@renuo.ch']
6
+ spec.name = "buschtelefon"
7
+ spec.version = Buschtelefon::VERSION
8
+ spec.authors = ["Josua Schmid"]
9
+ spec.email = ["josua.schmid@renuo.ch"]
10
10
 
11
- spec.summary = %q{Library for meshnet gossip}
12
- spec.description = %q{Buschtelefon can be used to share information between Ruby clients over a network}
13
- spec.homepage = 'https://github.com/schmijos/buschtelefon'
14
- spec.license = 'MIT'
11
+ spec.summary = "Library for meshnet gossip"
12
+ spec.description = "Buschtelefon can be used to share information between Ruby clients over a network"
13
+ spec.homepage = "https://github.com/schmijos/buschtelefon"
14
+ spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = 'exe'
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ['lib']
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
22
 
23
- spec.required_ruby_version = '>= 2.1.0'
23
+ spec.required_ruby_version = ">= 2.1.0"
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.16'
26
- spec.add_development_dependency 'cucumber', '~> 3.0'
27
- spec.add_development_dependency 'factory_bot', '~> 4.0'
28
- spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
30
- spec.add_development_dependency 'simplecov', '~> 0.16'
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "cucumber", "~> 3.0"
27
+ spec.add_development_dependency "factory_bot", "~> 4.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "simplecov", "~> 0.16"
31
+
32
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0")
33
+ spec.add_development_dependency "standard", "~> 0.1"
34
+ end
31
35
  end
data/lib/buschtelefon.rb CHANGED
@@ -1,9 +1,9 @@
1
- require_relative 'buschtelefon/version'
2
- require_relative 'buschtelefon/brain'
3
- require_relative 'buschtelefon/gossip'
4
- require_relative 'buschtelefon/net_tattler'
5
- require_relative 'buschtelefon/remote_tattler'
6
- require_relative 'buschtelefon/tattler'
1
+ require_relative "buschtelefon/version"
2
+ require_relative "buschtelefon/brain"
3
+ require_relative "buschtelefon/gossip"
4
+ require_relative "buschtelefon/net_tattler"
5
+ require_relative "buschtelefon/remote_tattler"
6
+ require_relative "buschtelefon/tattler"
7
7
 
8
8
  module Buschtelefon
9
9
  end
@@ -1,19 +1,20 @@
1
- require 'socket'
2
- require_relative 'tattler'
1
+ require "socket"
2
+ require_relative "tattler"
3
3
 
4
4
  module Buschtelefon
5
5
  class NetTattler < Tattler
6
- attr_accessor :port, :socket
6
+ attr_accessor :host, :port, :socket
7
7
 
8
- def initialize(port: 0)
8
+ def initialize(host: "127.0.0.1", port: 0)
9
9
  super()
10
10
  @socket = UDPSocket.new
11
- @socket.bind('127.0.0.1', port)
11
+ @socket.bind(host, port)
12
+ @host = @socket.local_address.ip_address
12
13
  @port = @socket.local_address.ip_port
13
14
  end
14
15
 
15
16
  def listen(&_callback)
16
- puts "Started UDP server on #{@port}..."
17
+ puts "Started UDP server on #{@host}:#{@port}..."
17
18
 
18
19
  Socket.udp_server_loop_on([@socket]) do |message, message_source|
19
20
  remote_tattler = find_or_build_remote_tattler(
@@ -22,7 +23,7 @@ module Buschtelefon
22
23
  )
23
24
 
24
25
  if message == "\x05"
25
- #puts "#{@port} got inquiry from #{remote_tattler}. Is connected to #{@connections.inspect}"
26
+ # puts "#{@port} got inquiry from #{remote_tattler}. Is connected to #{@connections.inspect}"
26
27
  handle_knowledge_inquiry(remote_tattler)
27
28
  else
28
29
  gossip = Gossip.new(message)
@@ -47,7 +48,7 @@ module Buschtelefon
47
48
  end
48
49
 
49
50
  def to_s
50
- "127.0.0.1:#{@port}"
51
+ "#{@host}:#{@port}"
51
52
  end
52
53
 
53
54
  private
@@ -62,7 +63,7 @@ module Buschtelefon
62
63
  end
63
64
 
64
65
  def find_or_build_remote_tattler(host:, port:)
65
- remote_connections.find { |t| t.host == host && t.port == port } || build_remote_tattler(host: host, port: port)
66
+ remote_connections.find { |t| t.host == host && t.port == port } || build_remote_tattler(host: host, port: port)
66
67
  end
67
68
 
68
69
  def build_remote_tattler(host:, port:)
@@ -70,4 +71,3 @@ module Buschtelefon
70
71
  end
71
72
  end
72
73
  end
73
-
@@ -1,4 +1,4 @@
1
- require 'socket'
1
+ require "socket"
2
2
 
3
3
  module Buschtelefon
4
4
  # No need to inheritance from Tattler because not all its features are available here (only #feed)
@@ -12,7 +12,7 @@ module Buschtelefon
12
12
  end
13
13
 
14
14
  def feed(gossip)
15
- #puts "#{@outbound_socket.local_address.ip_port} sending #{JSON.parse(gossip.message)['number']} to #{@port}"
15
+ # puts "#{@outbound_socket.local_address.ip_port} sending #{JSON.parse(gossip.message)['number']} to #{@port}"
16
16
  @outbound_socket.send(gossip.message, 0, @host, @port)
17
17
  end
18
18
 
@@ -1,3 +1,3 @@
1
1
  module Buschtelefon
2
- VERSION = '0.4.0'
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buschtelefon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josua Schmid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2019-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.16'
97
+ - !ruby/object:Gem::Dependency
98
+ name: standard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.1'
97
111
  description: Buschtelefon can be used to share information between Ruby clients over
98
112
  a network
99
113
  email:
@@ -142,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
156
  - !ruby/object:Gem::Version
143
157
  version: '0'
144
158
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.2.5
159
+ rubygems_version: 3.0.6
147
160
  signing_key:
148
161
  specification_version: 4
149
162
  summary: Library for meshnet gossip