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 +5 -5
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +5 -2
- data/Rakefile +3 -3
- data/bin/check +4 -1
- data/bin/run +2 -2
- data/buschtelefon.gemspec +25 -21
- data/lib/buschtelefon.rb +6 -6
- data/lib/buschtelefon/net_tattler.rb +10 -10
- data/lib/buschtelefon/remote_tattler.rb +2 -2
- data/lib/buschtelefon/version.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 17ed2d463f57f40cab25df7895ce45fc1da041f9395d8e76f7f6af953e278c61
|
4
|
+
data.tar.gz: 2b4179b89ed1d20fa0553ea31b4a532df503af2cb5261297e0776d28e9e40fa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 483bc25dc8409bf00a6e896fdd92246e07d28a90b88efc59d60e2ba906d2f53a4ce392f01794b8f990ec0ea92d0a6e05f8d7fcb845184bf7426e7b0e9fc29f3b
|
7
|
+
data.tar.gz: 1228512ba3adad9dfaa43e19984b356161d1e133e7e1fea01f80eb6040490f98785a7067067490f2a001d698e0ddfeddfa35eaf87b70d945aaac337a8ea863b1
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.8
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
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
data/bin/check
CHANGED
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(
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require "buschtelefon/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
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
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
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
|
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
|
20
|
-
spec.executables
|
21
|
-
spec.require_paths = [
|
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 =
|
23
|
+
spec.required_ruby_version = ">= 2.1.0"
|
24
24
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
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
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
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
|
2
|
-
require_relative
|
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(
|
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
|
-
"
|
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
|
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
|
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
|
|
data/lib/buschtelefon/version.rb
CHANGED
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.
|
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-
|
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
|
-
|
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
|