meshchat 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +1 -0
  3. data/README.md +7 -0
  4. data/lib/meshchat.rb +73 -0
  5. data/lib/meshchat/cli.rb +164 -0
  6. data/lib/meshchat/cli/command.rb +63 -0
  7. data/lib/meshchat/cli/config.rb +30 -0
  8. data/lib/meshchat/cli/exit.rb +9 -0
  9. data/lib/meshchat/cli/identity.rb +9 -0
  10. data/lib/meshchat/cli/import.rb +37 -0
  11. data/lib/meshchat/cli/init.rb +34 -0
  12. data/lib/meshchat/cli/input.rb +60 -0
  13. data/lib/meshchat/cli/irb.rb +18 -0
  14. data/lib/meshchat/cli/listen.rb +9 -0
  15. data/lib/meshchat/cli/ping.rb +61 -0
  16. data/lib/meshchat/cli/ping_all.rb +11 -0
  17. data/lib/meshchat/cli/server.rb +16 -0
  18. data/lib/meshchat/cli/share.rb +9 -0
  19. data/lib/meshchat/cli/stop_listening.rb +9 -0
  20. data/lib/meshchat/cli/whisper.rb +34 -0
  21. data/lib/meshchat/cli/who.rb +9 -0
  22. data/lib/meshchat/config/hash_file.rb +75 -0
  23. data/lib/meshchat/config/settings.rb +112 -0
  24. data/lib/meshchat/database.rb +30 -0
  25. data/lib/meshchat/display.rb +32 -0
  26. data/lib/meshchat/display/base.rb +53 -0
  27. data/lib/meshchat/display/manager.rb +51 -0
  28. data/lib/meshchat/encryption.rb +27 -0
  29. data/lib/meshchat/encryption/aes_rsa.rb +65 -0
  30. data/lib/meshchat/encryption/passthrough.rb +17 -0
  31. data/lib/meshchat/instance.rb +34 -0
  32. data/lib/meshchat/message.rb +38 -0
  33. data/lib/meshchat/message/base.rb +93 -0
  34. data/lib/meshchat/message/chat.rb +14 -0
  35. data/lib/meshchat/message/disconnection.rb +13 -0
  36. data/lib/meshchat/message/node_list.rb +41 -0
  37. data/lib/meshchat/message/node_list_diff.rb +15 -0
  38. data/lib/meshchat/message/node_list_hash.rb +29 -0
  39. data/lib/meshchat/message/ping.rb +32 -0
  40. data/lib/meshchat/message/ping_reply.rb +9 -0
  41. data/lib/meshchat/message/relay.rb +43 -0
  42. data/lib/meshchat/message/whisper.rb +36 -0
  43. data/lib/meshchat/models/entry.rb +104 -0
  44. data/lib/meshchat/net/client.rb +60 -0
  45. data/lib/meshchat/net/listener/request.rb +48 -0
  46. data/lib/meshchat/net/listener/request_processor.rb +45 -0
  47. data/lib/meshchat/net/listener/server.rb +61 -0
  48. data/lib/meshchat/net/request.rb +29 -0
  49. data/lib/meshchat/notifier/base.rb +50 -0
  50. data/lib/meshchat/version.rb +3 -0
  51. metadata +288 -0
@@ -0,0 +1,61 @@
1
+ require 'sinatra/base'
2
+
3
+ module MeshChat
4
+ module Net
5
+ module Listener
6
+ class Server < Sinatra::Base
7
+ configure :development do
8
+ # only shows resulting status
9
+ disable :logging
10
+ # enable :logging
11
+ set :bind, '0.0.0.0' #['10.10.2.29','127.0.0.1', 'localhost']
12
+ set :show_exceptions, :after_handler
13
+ set :threaded, true
14
+ end
15
+ # TODO: do we want to return an error if
16
+ # we can't decrypt?
17
+
18
+ get '/' do
19
+ process_request
20
+ end
21
+
22
+ post '/' do
23
+ process_request
24
+ end
25
+
26
+ def process_request
27
+ Display.debug request.env
28
+
29
+ begin
30
+ # form params should override
31
+ # raw body
32
+ raw =
33
+ if msg = params[:message]
34
+ msg
35
+ else
36
+ request_body = request.body.read
37
+ json_body = JSON.parse(request_body)
38
+ json_body['message']
39
+ end
40
+
41
+ # decode, etc
42
+ RequestProcessor.process(raw)
43
+
44
+ # hopefully everything went ok
45
+ ok
46
+ rescue => e
47
+ Display.error e.message
48
+ Display.error e.backtrace.join("\n")
49
+ body e.message
50
+ status 500
51
+ end
52
+ end
53
+
54
+ def ok
55
+ status 200
56
+ body 'OK'
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,29 @@
1
+ module MeshChat
2
+ module Net
3
+ # TODO: Write abstraction of destination node and message
4
+ # TODO: maybe this can have the logic to determine when to relay?
5
+ class Request
6
+ attr_accessor :_node, :_message, :_payload
7
+
8
+ def initialize(node, message)
9
+ self._node = node
10
+ self._message = message
11
+ end
12
+
13
+ def payload
14
+ unless _payload
15
+ self._payload = _message.render
16
+
17
+ if _node.public_key
18
+ self._payload = Cipher.encrypt(_payload, _node.public_key)
19
+ end
20
+
21
+ self._payload = Base64.encode64(_payload)
22
+ end
23
+
24
+ _payload
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,50 @@
1
+ module MeshChat
2
+ module Notifier
3
+ # This is the default notification implementation
4
+ # - Uses Libnotify
5
+ #
6
+ #
7
+ # Only use one notification and update continuously, so that
8
+ # the notification area / tray doesn't become flooded by this app
9
+ #
10
+ # To write your own notifier, just override the show method in a
11
+ # subclass of this class
12
+ class Base
13
+
14
+ # Notifier::Base is a singleton
15
+ # Not all Notifiers need to be singletons,
16
+ # but it doesn't really make sense to have more than one
17
+ class << self
18
+ delegate :show, to: :instance
19
+
20
+ def instance
21
+ @instance ||= new
22
+ end
23
+ end
24
+
25
+ def show(*args)
26
+ libnotify_message.update(*args) do |notify|
27
+ yield(notify) if block_given?
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def libnotify_message()
34
+ @message ||= Libnotify.new do |notify|
35
+ notify.summary = MeshChat::NAME
36
+ notify.body = ""
37
+ notify.timeout = 1.5 # 1.5 (s), 1000 (ms), "2", nil, false
38
+ notify.urgency = :normal # :low, :normal, :critical
39
+ notify.append = false # default true - append onto existing notification
40
+ notify.transient = false # default false - keep the notifications around after display
41
+ # TODO: this will vary on each system - maybe package icons
42
+ # with the gem
43
+ notify.icon_path = "/usr/share/icons/gnome/scalable/emblems/emblem-default.svg"
44
+ end
45
+
46
+ @message
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module MeshChat
2
+ VERSION = '0.5.0'
3
+ end
metadata ADDED
@@ -0,0 +1,288 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: meshchat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - L. Preston Sego III
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqlite3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thin
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: curb
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: colorize
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: curses
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: libnotify
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: awesome_print
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-byebug
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: codeclimate-test-reporter
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: MeshChat core implementation written in ruby.
210
+ email: LPSego3+dev@gmail.com
211
+ executables: []
212
+ extensions: []
213
+ extra_rdoc_files: []
214
+ files:
215
+ - CHANGELOG.md
216
+ - README.md
217
+ - lib/meshchat.rb
218
+ - lib/meshchat/cli.rb
219
+ - lib/meshchat/cli/command.rb
220
+ - lib/meshchat/cli/config.rb
221
+ - lib/meshchat/cli/exit.rb
222
+ - lib/meshchat/cli/identity.rb
223
+ - lib/meshchat/cli/import.rb
224
+ - lib/meshchat/cli/init.rb
225
+ - lib/meshchat/cli/input.rb
226
+ - lib/meshchat/cli/irb.rb
227
+ - lib/meshchat/cli/listen.rb
228
+ - lib/meshchat/cli/ping.rb
229
+ - lib/meshchat/cli/ping_all.rb
230
+ - lib/meshchat/cli/server.rb
231
+ - lib/meshchat/cli/share.rb
232
+ - lib/meshchat/cli/stop_listening.rb
233
+ - lib/meshchat/cli/whisper.rb
234
+ - lib/meshchat/cli/who.rb
235
+ - lib/meshchat/config/hash_file.rb
236
+ - lib/meshchat/config/settings.rb
237
+ - lib/meshchat/database.rb
238
+ - lib/meshchat/display.rb
239
+ - lib/meshchat/display/base.rb
240
+ - lib/meshchat/display/manager.rb
241
+ - lib/meshchat/encryption.rb
242
+ - lib/meshchat/encryption/aes_rsa.rb
243
+ - lib/meshchat/encryption/passthrough.rb
244
+ - lib/meshchat/instance.rb
245
+ - lib/meshchat/message.rb
246
+ - lib/meshchat/message/base.rb
247
+ - lib/meshchat/message/chat.rb
248
+ - lib/meshchat/message/disconnection.rb
249
+ - lib/meshchat/message/node_list.rb
250
+ - lib/meshchat/message/node_list_diff.rb
251
+ - lib/meshchat/message/node_list_hash.rb
252
+ - lib/meshchat/message/ping.rb
253
+ - lib/meshchat/message/ping_reply.rb
254
+ - lib/meshchat/message/relay.rb
255
+ - lib/meshchat/message/whisper.rb
256
+ - lib/meshchat/models/entry.rb
257
+ - lib/meshchat/net/client.rb
258
+ - lib/meshchat/net/listener/request.rb
259
+ - lib/meshchat/net/listener/request_processor.rb
260
+ - lib/meshchat/net/listener/server.rb
261
+ - lib/meshchat/net/request.rb
262
+ - lib/meshchat/notifier/base.rb
263
+ - lib/meshchat/version.rb
264
+ homepage: https://github.com/NullVoxPopuli/meshchat
265
+ licenses:
266
+ - MIT
267
+ metadata: {}
268
+ post_install_message:
269
+ rdoc_options: []
270
+ require_paths:
271
+ - lib
272
+ required_ruby_version: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: '2.0'
277
+ required_rubygems_version: !ruby/object:Gem::Requirement
278
+ requirements:
279
+ - - ">="
280
+ - !ruby/object:Gem::Version
281
+ version: '0'
282
+ requirements: []
283
+ rubyforge_project:
284
+ rubygems_version: 2.4.7
285
+ signing_key:
286
+ specification_version: 4
287
+ summary: MeshChat-0.5.0
288
+ test_files: []