buschtelefon 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +8 -6
- data/README.md +14 -6
- data/bin/check +5 -1
- data/bin/run +3 -4
- data/buschtelefon.gemspec +1 -1
- data/lib/buschtelefon/net_tattler.rb +15 -5
- data/lib/buschtelefon/tattler.rb +10 -2
- data/lib/buschtelefon/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 324cfeafd9c295fdd335f6b60da096845eddb1fd
|
4
|
+
data.tar.gz: 234ef8b0e84fd3d39880f4d63141887c69445a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd93c3f0f4805b0b849fbdab2f9527d086380694d05eb8e953bbdef4a0b817414c5782cc5e35a51f6fb0519c0b83973e6a49129af0b31f299479c8e5f79afe1a
|
7
|
+
data.tar.gz: 990c757b4760830488ad70a8cef7eccc9c85375e708989b4d7ac7e6752073d8bda066e43d28b4d9e5aac14cc275a31cacd01176cd7edaa410b25e953f3a309b6
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.10
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Buschtelefon
|
2
2
|
|
3
|
+
[![Travis Build Status](https://travis-ci.org/renuo/buschtelefon.svg?branch=master)](https://travis-ci.org/renuo/buschtelefon)
|
4
|
+
|
3
5
|
With *buschtelefon* you can setup a gossiping meshnet.
|
4
6
|
All of it should behave just like human beings tattling at a
|
5
7
|
coffee party.
|
@@ -13,7 +15,8 @@ implemented (yet).
|
|
13
15
|
|
14
16
|
## Installation
|
15
17
|
|
16
|
-
|
18
|
+
You can use this gem with Ruby versions starting from 2.1.
|
19
|
+
Add the following line to your application's Gemfile:
|
17
20
|
|
18
21
|
```ruby
|
19
22
|
gem 'buschtelefon'
|
@@ -29,16 +32,21 @@ Or install it yourself as:
|
|
29
32
|
|
30
33
|
## Usage
|
31
34
|
|
32
|
-
You can setup your tattling meshnet the following way:
|
35
|
+
You can setup your local tattling meshnet the following way:
|
33
36
|
|
34
37
|
```ruby
|
35
38
|
include Buschtelefon
|
36
39
|
|
37
|
-
aunt_may = NetTattler.new
|
38
|
-
aunt_ruth =
|
39
|
-
|
40
|
+
aunt_may = NetTattler.new
|
41
|
+
aunt_ruth = NetTattler.new
|
42
|
+
remote_aunt_ruth = RemoteTattler.new(host: 'localhost', port: aunt_ruth.port)
|
43
|
+
|
44
|
+
aunt_may.connect(remote_aunt_ruth)
|
45
|
+
|
46
|
+
Thread.new { aunt_may.listen }
|
47
|
+
Thread.new { aunt_ruth.listen }
|
40
48
|
|
41
|
-
aunt_may.feed(Gossip.new('
|
49
|
+
aunt_may.feed(Gossip.new('Did you hear about the cool company "Renuo"?'))
|
42
50
|
```
|
43
51
|
|
44
52
|
## Development
|
data/bin/check
CHANGED
data/bin/run
CHANGED
@@ -36,9 +36,9 @@ tattlers[:E].connect(tattlers[:D])
|
|
36
36
|
puts 'Feeding locals'
|
37
37
|
tattlers[:A].feed(Gossip.new('Tezos'))
|
38
38
|
|
39
|
-
josua = NetTattler.new
|
40
|
-
simon = NetTattler.new
|
41
|
-
remote_simon = RemoteTattler.new(host: 'localhost', port:
|
39
|
+
josua = NetTattler.new
|
40
|
+
simon = NetTattler.new
|
41
|
+
remote_simon = RemoteTattler.new(host: 'localhost', port: simon.port)
|
42
42
|
|
43
43
|
josua.connect(remote_simon)
|
44
44
|
|
@@ -46,4 +46,3 @@ Thread.new { josua.listen }
|
|
46
46
|
Thread.new { simon.listen }
|
47
47
|
|
48
48
|
remote_simon.feed(Gossip.new('Antshare'))
|
49
|
-
puts 'gach'
|
data/buschtelefon.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ['josua.schmid@renuo.ch']
|
10
10
|
|
11
11
|
spec.summary = %q{Library for meshnet gossip}
|
12
|
-
spec.description = %q{Buschtelefon can be used to share information
|
12
|
+
spec.description = %q{Buschtelefon can be used to share information between Ruby clients over a network}
|
13
13
|
spec.homepage = 'https://github.com/schmijos/buschtelefon'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -3,18 +3,24 @@ require_relative 'tattler'
|
|
3
3
|
|
4
4
|
module Buschtelefon
|
5
5
|
class NetTattler < Tattler
|
6
|
-
|
6
|
+
attr_accessor :port
|
7
|
+
|
8
|
+
def initialize(port: nil)
|
7
9
|
super()
|
8
|
-
@port = port
|
10
|
+
@port = port || rand(1025..65365) # TODO: use port 0
|
9
11
|
end
|
10
12
|
|
11
|
-
def listen(&
|
13
|
+
def listen(&_callback)
|
12
14
|
puts "Started UDP server on #{@port}..."
|
13
15
|
|
14
16
|
Socket.udp_server_loop(@port) do |message, message_source|
|
15
|
-
yield(message)
|
16
|
-
handle_incoming_message(message)
|
17
17
|
puts "Got \"#{message}\" from #{message_source}"
|
18
|
+
if message == "\x05"
|
19
|
+
handle_knowledge_inquiry(message_source)
|
20
|
+
else
|
21
|
+
handle_incoming_message(message)
|
22
|
+
yield(message) if block_given?
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
@@ -23,6 +29,10 @@ module Buschtelefon
|
|
23
29
|
def handle_incoming_message(message)
|
24
30
|
feed(Gossip.new(message))
|
25
31
|
end
|
32
|
+
|
33
|
+
def handle_knowledge_inquiry(message_source)
|
34
|
+
transfer_knowledge(RemoteTattler.new(message_source.local_address))
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
28
38
|
|
data/lib/buschtelefon/tattler.rb
CHANGED
@@ -7,9 +7,12 @@ module Buschtelefon
|
|
7
7
|
@brain = Brain.new
|
8
8
|
end
|
9
9
|
|
10
|
+
def knowledge
|
11
|
+
@brain.to_a
|
12
|
+
end
|
13
|
+
|
10
14
|
def connect(tattler)
|
11
|
-
@connections << tattler
|
12
|
-
@connections.uniq!
|
15
|
+
@connections << tattler unless @connections.include?(tattler)
|
13
16
|
end
|
14
17
|
|
15
18
|
def feed(gossip)
|
@@ -19,5 +22,10 @@ module Buschtelefon
|
|
19
22
|
|
20
23
|
@connections.each { |tattler| tattler.feed(gossip) }
|
21
24
|
end
|
25
|
+
|
26
|
+
def transfer_knowledge(tattler)
|
27
|
+
connect(tattler)
|
28
|
+
knowledge.each { |gossip| tattler.feed(gossip) }
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
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
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josua Schmid
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,8 +94,8 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.16'
|
97
|
-
description: Buschtelefon can be used to share information
|
98
|
-
|
97
|
+
description: Buschtelefon can be used to share information between Ruby clients over
|
98
|
+
a network
|
99
99
|
email:
|
100
100
|
- josua.schmid@renuo.ch
|
101
101
|
executables: []
|