meshchat 0.6.11 → 0.7.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 +4 -4
- data/lib/meshchat/cli.rb +9 -1
- data/lib/meshchat/command/base.rb +1 -0
- data/lib/meshchat/command/bind.rb +7 -4
- data/lib/meshchat/command/send_disconnect.rb +15 -0
- data/lib/meshchat/config/settings.rb +7 -7
- data/lib/meshchat/message.rb +3 -3
- data/lib/meshchat/message/base.rb +4 -0
- data/lib/meshchat/message/{disconnection.rb → disconnect.rb} +1 -1
- data/lib/meshchat/message/node_list.rb +7 -4
- data/lib/meshchat/models/entry.rb +2 -2
- data/lib/meshchat/net/client.rb +9 -0
- data/lib/meshchat/net/listener/request.rb +1 -1
- data/lib/meshchat/net/listener/request_processor.rb +5 -0
- data/lib/meshchat/net/listener/server.rb +1 -0
- data/lib/meshchat/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a669862d8119b09c7bfbf437c476aba8974bb349
|
4
|
+
data.tar.gz: 13d7944d37b968bc43c6fc57332b1e0296a62e36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb9df8e25b985e6d92b7e9fd70f053e770960ec29994dd104de7ba02fd84d0b97e93c4ad0c16d37510d8d5f09aa4fe5c7cb810f81c057dd367b8e11255e85619
|
7
|
+
data.tar.gz: 914be292200fe5b1309702fb36d5cca2e9eb3990b7895d5d498524ad565ae7ddbae1ab12ce1f4a072bbeeadbdd6d61223e55599c028d89c87e4ff13c98a4c8e7
|
data/lib/meshchat/cli.rb
CHANGED
@@ -11,6 +11,7 @@ require 'meshchat/command/whisper'
|
|
11
11
|
require 'meshchat/command/exit'
|
12
12
|
require 'meshchat/command/listen'
|
13
13
|
require 'meshchat/command/stop_listening'
|
14
|
+
require 'meshchat/command/send_disconnect'
|
14
15
|
require 'meshchat/command/help'
|
15
16
|
require 'meshchat/command/bind'
|
16
17
|
require 'meshchat/command/online'
|
@@ -43,7 +44,8 @@ module MeshChat
|
|
43
44
|
MeshChat::Command::Base::ONLINE => MeshChat::Command::Online,
|
44
45
|
MeshChat::Command::Base::OFFLINE => MeshChat::Command::Offline,
|
45
46
|
MeshChat::Command::Base::HELP => MeshChat::Command::Help,
|
46
|
-
MeshChat::Command::Base::BIND => MeshChat::Command::Bind
|
47
|
+
MeshChat::Command::Base::BIND => MeshChat::Command::Bind,
|
48
|
+
MeshChat::Command::Base::SEND_DISCONNECT => MeshChat::Command::SendDisconnect
|
47
49
|
}
|
48
50
|
|
49
51
|
|
@@ -168,8 +170,14 @@ module MeshChat
|
|
168
170
|
# close_server
|
169
171
|
Display.info 'saving config...'
|
170
172
|
Settings.save
|
173
|
+
Display.info 'notifying of disconnection...'
|
174
|
+
send_disconnect
|
171
175
|
Display.alert "\n\nGoodbye. \n\nThank you for using #{MeshChat.name}"
|
172
176
|
exit
|
173
177
|
end
|
178
|
+
|
179
|
+
def send_disconnect
|
180
|
+
MeshChat::Command::SendDisconnect.new('/senddisconnect')
|
181
|
+
end
|
174
182
|
end
|
175
183
|
end
|
@@ -25,15 +25,18 @@ module MeshChat
|
|
25
25
|
Display.alert 'Invalid selection'
|
26
26
|
handle # repeat
|
27
27
|
end
|
28
|
-
|
29
|
-
|
30
28
|
end
|
31
29
|
|
32
30
|
def ip_addresses
|
33
31
|
local = Socket.getifaddrs.map { |i| i.addr.ip_address if i.addr.ipv4? }.compact
|
34
32
|
# get public
|
35
|
-
|
36
|
-
|
33
|
+
begin
|
34
|
+
remote_ip = open('http://whatismyip.akamai.com').read
|
35
|
+
local << remote_ip
|
36
|
+
rescue => e
|
37
|
+
Display.fatal e.message
|
38
|
+
Display.alert 'public ip lookup failed'
|
39
|
+
end
|
37
40
|
local
|
38
41
|
end
|
39
42
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MeshChat
|
2
|
+
class Command
|
3
|
+
class SendDisconnect < Command::Base
|
4
|
+
def self.description
|
5
|
+
'sends a disconnect message to all users'
|
6
|
+
end
|
7
|
+
|
8
|
+
def handle
|
9
|
+
Node.all.each do |n|
|
10
|
+
Net::Client.send(node: n, message: Message::Disconnect.new)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -8,7 +8,7 @@ module MeshChat
|
|
8
8
|
'port' => '2008',
|
9
9
|
'ip' => 'localhost',
|
10
10
|
'uid' => '1',
|
11
|
-
'
|
11
|
+
'publickey' => 'replace this'
|
12
12
|
}
|
13
13
|
|
14
14
|
class << self
|
@@ -33,7 +33,7 @@ module MeshChat
|
|
33
33
|
'alias' => self['alias'],
|
34
34
|
'location' => location,
|
35
35
|
'uid' => self['uid'],
|
36
|
-
'
|
36
|
+
'publickey' => public_key
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
@@ -54,11 +54,11 @@ module MeshChat
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def public_key
|
57
|
-
self['
|
57
|
+
self['publickey']
|
58
58
|
end
|
59
59
|
|
60
60
|
def private_key
|
61
|
-
self['
|
61
|
+
self['privatkey']
|
62
62
|
end
|
63
63
|
|
64
64
|
# generates 32 bytes
|
@@ -69,14 +69,14 @@ module MeshChat
|
|
69
69
|
|
70
70
|
def generate_keys
|
71
71
|
@key_pair = OpenSSL::PKey::RSA.new(2048)
|
72
|
-
self['
|
73
|
-
self['
|
72
|
+
self['publickey'] = @key_pair.public_key.to_pem
|
73
|
+
self['privatekey'] = @key_pair.to_pem
|
74
74
|
Display.success 'new keys generated'
|
75
75
|
end
|
76
76
|
|
77
77
|
def key_pair
|
78
78
|
if !@key_pair && keys_exist?
|
79
|
-
@key_pair = OpenSSL::PKey::RSA.new(self['
|
79
|
+
@key_pair = OpenSSL::PKey::RSA.new(self['privatekey'] + self['publickey'])
|
80
80
|
end
|
81
81
|
@key_pair
|
82
82
|
end
|
data/lib/meshchat/message.rb
CHANGED
@@ -2,7 +2,7 @@ require 'meshchat/message/base'
|
|
2
2
|
require 'meshchat/message/chat'
|
3
3
|
require 'meshchat/message/ping'
|
4
4
|
require 'meshchat/message/ping_reply'
|
5
|
-
require 'meshchat/message/
|
5
|
+
require 'meshchat/message/disconnect'
|
6
6
|
require 'meshchat/message/whisper'
|
7
7
|
require 'meshchat/message/relay'
|
8
8
|
require 'meshchat/message/node_list'
|
@@ -16,7 +16,7 @@ module MeshChat
|
|
16
16
|
PING_REPLY = 'pingreply'
|
17
17
|
WHISPER = 'whisper'
|
18
18
|
RELAY = 'relay'
|
19
|
-
|
19
|
+
DISCONNECT = 'disconnect'
|
20
20
|
|
21
21
|
NODE_LIST = 'nodelist'
|
22
22
|
NODE_LIST_HASH = 'nodelisthash'
|
@@ -25,7 +25,7 @@ module MeshChat
|
|
25
25
|
TYPES = {
|
26
26
|
CHAT => Chat,
|
27
27
|
WHISPER => Whisper,
|
28
|
-
|
28
|
+
DISCONNECT => Disconnect,
|
29
29
|
PING => Ping,
|
30
30
|
PING_REPLY => PingReply,
|
31
31
|
NODE_LIST => NodeList,
|
@@ -16,12 +16,12 @@ module MeshChat
|
|
16
16
|
received_list = message
|
17
17
|
we_only_have, they_only_have = Node.diff(received_list)
|
18
18
|
|
19
|
+
Display.debug('node_list#respond: me: ' + we_only_have.to_s)
|
20
|
+
Display.debug('node_list#respond: they: ' + they_only_have.to_s)
|
21
|
+
|
19
22
|
if they_only_have.present?
|
20
23
|
they_only_have.each do |n|
|
21
|
-
|
22
|
-
unless n['uid'] == Settings['uid']
|
23
|
-
Node.from_json(n).save!
|
24
|
-
end
|
24
|
+
Node.from_json(n).save!
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -30,6 +30,7 @@ module MeshChat
|
|
30
30
|
|
31
31
|
node = Node.find_by_location(location)
|
32
32
|
if we_only_have.present?
|
33
|
+
Display.debug 'we have nodes that they do not'
|
33
34
|
|
34
35
|
# give the sender our list
|
35
36
|
MeshChat::Net::Client.send(
|
@@ -47,6 +48,8 @@ module MeshChat
|
|
47
48
|
)
|
48
49
|
end
|
49
50
|
else
|
51
|
+
Display.debug 'node lists are in sync'
|
52
|
+
|
50
53
|
# lists are in sync, confirm with hash
|
51
54
|
MeshChat::Net::Client.send(
|
52
55
|
node: node,
|
@@ -46,7 +46,7 @@ module MeshChat
|
|
46
46
|
alias_name: json['alias'],
|
47
47
|
location: json['location'],
|
48
48
|
uid: json['uid'],
|
49
|
-
public_key: json['
|
49
|
+
public_key: json['publickey']
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
@@ -92,7 +92,7 @@ module MeshChat
|
|
92
92
|
'alias' => alias_name,
|
93
93
|
'location' => location,
|
94
94
|
'uid' => uid,
|
95
|
-
'
|
95
|
+
'publickey' => public_key
|
96
96
|
}
|
97
97
|
end
|
98
98
|
|
data/lib/meshchat/net/client.rb
CHANGED
@@ -13,10 +13,19 @@ module MeshChat
|
|
13
13
|
# verify node is valid
|
14
14
|
node = self.node_for(location: location, uid: uid, node: node)
|
15
15
|
|
16
|
+
if Settings['uid'] == node.uid
|
17
|
+
Display.debug 'avoiding sending to self'
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
16
21
|
Thread.new(node, message) do |node, message|
|
17
22
|
begin
|
18
23
|
payload = Client.payload_for(node, message)
|
19
24
|
|
25
|
+
Display.debug('SENDING: ' + message.type)
|
26
|
+
Display.debug('SENDING: ' + message.sender.to_s)
|
27
|
+
Display.debug('SENDING: ' + message.message.to_s)
|
28
|
+
|
20
29
|
# TODO: this is horrible, come up with something better / abstract it
|
21
30
|
begin
|
22
31
|
Curl::Easy.http_post(node.location, payload.to_json) do |c|
|
@@ -23,7 +23,7 @@ module MeshChat
|
|
23
23
|
def try_decrypt(input)
|
24
24
|
begin
|
25
25
|
decoded = Base64.decode64(input)
|
26
|
-
input = Cipher.decrypt(decoded, Settings[:
|
26
|
+
input = Cipher.decrypt(decoded, Settings[:privatekey])
|
27
27
|
rescue => e
|
28
28
|
Display.debug e.message
|
29
29
|
Display.debug e.backtrace.join("\n")
|
@@ -9,6 +9,11 @@ module MeshChat
|
|
9
9
|
request = Request.new(raw)
|
10
10
|
message = request.message
|
11
11
|
|
12
|
+
# TODO: wrap in debug if check
|
13
|
+
Display.debug('RECEIVING: ' + message.type)
|
14
|
+
Display.debug('RECEIVING: ' + message.sender.to_s)
|
15
|
+
Display.debug('RECEIVING: ' + message.message.to_s)
|
16
|
+
|
12
17
|
# handle the message
|
13
18
|
Display.present_message message
|
14
19
|
|
data/lib/meshchat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meshchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- lib/meshchat/command/online.rb
|
205
205
|
- lib/meshchat/command/ping.rb
|
206
206
|
- lib/meshchat/command/ping_all.rb
|
207
|
+
- lib/meshchat/command/send_disconnect.rb
|
207
208
|
- lib/meshchat/command/server.rb
|
208
209
|
- lib/meshchat/command/share.rb
|
209
210
|
- lib/meshchat/command/stop_listening.rb
|
@@ -221,7 +222,7 @@ files:
|
|
221
222
|
- lib/meshchat/message.rb
|
222
223
|
- lib/meshchat/message/base.rb
|
223
224
|
- lib/meshchat/message/chat.rb
|
224
|
-
- lib/meshchat/message/
|
225
|
+
- lib/meshchat/message/disconnect.rb
|
225
226
|
- lib/meshchat/message/node_list.rb
|
226
227
|
- lib/meshchat/message/node_list_diff.rb
|
227
228
|
- lib/meshchat/message/node_list_hash.rb
|
@@ -261,5 +262,5 @@ rubyforge_project:
|
|
261
262
|
rubygems_version: 2.4.8
|
262
263
|
signing_key:
|
263
264
|
specification_version: 4
|
264
|
-
summary: MeshChat-0.
|
265
|
+
summary: MeshChat-0.7.0
|
265
266
|
test_files: []
|