votifier-ruby 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/votifier.rb +10 -0
- data/lib/votifier/handler.rb +27 -0
- data/lib/votifier/listener.rb +8 -0
- data/lib/votifier/server.rb +19 -0
- data/lib/votifier/version.rb +6 -0
- data/lib/votifier/vote.rb +14 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f9bb99cc5b35346803caea52745376caccb105eb
|
4
|
+
data.tar.gz: f68525dcf93a9b5202159f776323b132f9f23f6b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 496f99496dc1c982875acf0db4964600adfdabc1e67e465dd107fdea3f82d7dc9487570a931f8dcf675ffee28e7aa80d45efc3c80a986df8518d83d752d23623
|
7
|
+
data.tar.gz: 4881372ecd641022229f1534f096f70bcfd6a99266d6a174fa7e7a02e41559ba158fce726576875726389c230eab955d720f300fd1355e1704b3752eb8d041f6
|
data/lib/votifier.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Votifier
|
2
|
+
class ConnectionHandler
|
3
|
+
|
4
|
+
def initialize(session, key)
|
5
|
+
@session = session
|
6
|
+
@key = key
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
# Send the latest compatible plugin version to the list
|
11
|
+
@session.puts "VOTIFIER #{Votifier::PLUGIN_VERSION}\n"
|
12
|
+
|
13
|
+
# Read and decrypt the 256 byte vote block
|
14
|
+
block = @session.read 256
|
15
|
+
result = @key.private_decrypt(block).split("\n")
|
16
|
+
|
17
|
+
# Perform opcode check
|
18
|
+
if result[0] != "VOTE"
|
19
|
+
raise ArgumentError, "Incorrect block opcode"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create the vote
|
23
|
+
Vote.new(result[1], result[2], result[3], result[4])
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Votifier
|
2
|
+
class VoteServer
|
3
|
+
|
4
|
+
attr_reader :server
|
5
|
+
attr_accessor :listener
|
6
|
+
|
7
|
+
def initialize(host, port, key, listener)
|
8
|
+
@listener = listener
|
9
|
+
@server = TCPServer.new(host, port)
|
10
|
+
loop do
|
11
|
+
Thread.start(@server.accept) do |session|
|
12
|
+
vote = ConnectionHandler.new(session, key).run
|
13
|
+
listener.vote_received vote
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: votifier-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kailan Blanks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Implementation of the Votifier protocol in Ruby
|
14
|
+
email: kailan@komputerking.net
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/votifier.rb
|
20
|
+
- lib/votifier/handler.rb
|
21
|
+
- lib/votifier/listener.rb
|
22
|
+
- lib/votifier/server.rb
|
23
|
+
- lib/votifier/version.rb
|
24
|
+
- lib/votifier/vote.rb
|
25
|
+
homepage: https://github.com/kblanks/votifier-ruby
|
26
|
+
licenses: []
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.4.6
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Implementation of the Votifier protocol
|
48
|
+
test_files: []
|