jibril 0.0.1
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 +7 -0
- data/.gitignore +11 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +10 -0
- data/bin/jibril-client.rb +34 -0
- data/bin/jibril-server.rb +119 -0
- data/jibril.gemspec +39 -0
- data/lib/jibril.rb +4 -0
- data/lib/jibril/config.rb +23 -0
- data/lib/jibril/version.rb +5 -0
- metadata +110 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1695dccb759b28e176fe0473eed5583d4d6d7774742579ce58b17f23a074c58e
|
|
4
|
+
data.tar.gz: ac1b0685aa0d5b845fb27168547528dca06544858975b56562076d5cdfdd4bd5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9d27d5521e6ba3bd3398d5120b7c378c59684e68fcb554e9503bbdb1bfb98b96b37dad7c1b63dcf61010550dede204dcd4c755dd24486da04e53e1a486f4fbcc
|
|
7
|
+
data.tar.gz: 4dfc93f3319a5da70c2dac9dd1b99cf2d50c04a684bb4173a9517f7c1d2a21b89a4b0e69c635261d2186723f482eacc3cc7ff56ebc6de6f2dfd5ec4ccf0b458c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Wolf
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Jibril
|
|
2
|
+
|
|
3
|
+
Simple chef-inspired configuration management tool. While chef is awesome,
|
|
4
|
+
it has crazy high requirements (mainly memory-wise) for managing like
|
|
5
|
+
8 devices I have.
|
|
6
|
+
|
|
7
|
+
Ansible would be great IF all my devices were reachable, however some are
|
|
8
|
+
behind NATs.
|
|
9
|
+
|
|
10
|
+
Jibril tries to solve both issue. It's designed to be light on the server
|
|
11
|
+
(raspberry pi is enough), with one server (so NATs are not an issue)
|
|
12
|
+
and ruby DSL for the configuration scripts (so like chef, I don't like the
|
|
13
|
+
way ansible uses yaml for this).
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
$ gem install jibril
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
raise NotImplementedError
|
|
5
|
+
|
|
6
|
+
__END__
|
|
7
|
+
require 'logger'
|
|
8
|
+
require 'socket'
|
|
9
|
+
require 'openssl'
|
|
10
|
+
|
|
11
|
+
require 'pry'
|
|
12
|
+
|
|
13
|
+
require_relative '../lib/jibril'
|
|
14
|
+
|
|
15
|
+
$l = Logger.new(STDOUT)
|
|
16
|
+
|
|
17
|
+
socket = TCPSocket.new('127.0.0.1', Jibril::PORT)
|
|
18
|
+
|
|
19
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
|
20
|
+
ctx.key = OpenSSL::PKey::RSA.new(File.open('test/certs/client1.key'))
|
|
21
|
+
ctx.cert = OpenSSL::X509::Certificate.new(File.open('test/certs/client1.crt'))
|
|
22
|
+
|
|
23
|
+
$l.debug { "Client cert: #{OpenSSL::Digest::MD5.new(ctx.cert.to_der).to_s}" }
|
|
24
|
+
|
|
25
|
+
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)
|
|
26
|
+
ssl_socket.sync_close = true
|
|
27
|
+
|
|
28
|
+
ssl_socket.connect
|
|
29
|
+
|
|
30
|
+
pp OpenSSL::Digest::SHA1.new(ssl_socket.peer_cert.to_der).to_s
|
|
31
|
+
|
|
32
|
+
ssl_socket.write 'test'
|
|
33
|
+
|
|
34
|
+
ssl_socket.close
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
raise NotImplementedError
|
|
5
|
+
|
|
6
|
+
__END__
|
|
7
|
+
require 'logger'
|
|
8
|
+
require 'jibril'
|
|
9
|
+
|
|
10
|
+
begin
|
|
11
|
+
$l = Logger.new(STDOUT)
|
|
12
|
+
conf = Jibril::Config.new(
|
|
13
|
+
rescue => e
|
|
14
|
+
pp e
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
__END__
|
|
18
|
+
sockets = Socket.tcp_server_sockets('0.0.0.0', Jibril::PORT)
|
|
19
|
+
sockets.each do |socket|
|
|
20
|
+
$l.info { "Ready to accept: #{socket.local_address.inspect_sockaddr}" }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def handle_accept socket
|
|
24
|
+
$l.info { "Handle accept" }
|
|
25
|
+
|
|
26
|
+
begin
|
|
27
|
+
con,_ = socket.accept_nonblock
|
|
28
|
+
rescue IO::WaitReadable
|
|
29
|
+
$l.warn { 'Failed to accept!' }
|
|
30
|
+
return
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
cert_store = OpenSSL::X509::Store.new
|
|
34
|
+
cert_store.set_default_paths
|
|
35
|
+
cert_store.verify_callback = lambda do |preverify_ok, store_ctx|
|
|
36
|
+
puts "Store callback, #{store_ctx}"
|
|
37
|
+
true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
|
41
|
+
ctx.key = OpenSSL::PKey::RSA.new(File.open('test/certs/server.key'))
|
|
42
|
+
ctx.cert = OpenSSL::X509::Certificate.new(File.open('test/certs/server.crt'))
|
|
43
|
+
ctx.min_version = :TLS1_2
|
|
44
|
+
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
|
|
45
|
+
ctx.cert_store = cert_store
|
|
46
|
+
ctx.verify_callback = lambda do |preverify_ok, store_ctx|
|
|
47
|
+
puts "CTX callback, #{store_ctx}"
|
|
48
|
+
true
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
$l.debug { "Server cert: #{OpenSSL::Digest::MD5.new(ctx.cert.to_der).to_s}" }
|
|
52
|
+
|
|
53
|
+
ssl_socket = OpenSSL::SSL::SSLSocket.new(con, ctx)
|
|
54
|
+
ssl_socket.sync_close = true
|
|
55
|
+
|
|
56
|
+
begin
|
|
57
|
+
#ssl_socket.accept_nonblock
|
|
58
|
+
ssl_socket.accept
|
|
59
|
+
rescue IO::WaitReadable
|
|
60
|
+
IO.select([con])
|
|
61
|
+
retry
|
|
62
|
+
rescue IO::WaitWritable
|
|
63
|
+
IO.select([con])
|
|
64
|
+
retry
|
|
65
|
+
rescue => e
|
|
66
|
+
$l.warn { "Unexpected exception: #{e}" }
|
|
67
|
+
raise
|
|
68
|
+
end
|
|
69
|
+
$l.info { "Accepted" }
|
|
70
|
+
|
|
71
|
+
pp ssl_socket.peer_cert
|
|
72
|
+
|
|
73
|
+
begin
|
|
74
|
+
pp ssl_socket.read_nonblock(1024)
|
|
75
|
+
rescue IO::WaitReadable
|
|
76
|
+
IO.select([con])
|
|
77
|
+
retry
|
|
78
|
+
rescue IO::WaitWritable
|
|
79
|
+
IO.select([con])
|
|
80
|
+
retry
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
ssl_socket.close
|
|
84
|
+
|
|
85
|
+
$l.info { 'SSL close' }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
while true
|
|
89
|
+
read, _, _ = IO.select(sockets)
|
|
90
|
+
|
|
91
|
+
if !read.empty?
|
|
92
|
+
$l.info { "Read ready on server socket" }
|
|
93
|
+
read.each { |socket| handle_accept(socket) }
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
__END__
|
|
98
|
+
module Jibril
|
|
99
|
+
class Server
|
|
100
|
+
def initialize(host = '0.0.0.0', port = 9876)
|
|
101
|
+
@threads = []
|
|
102
|
+
@host = host
|
|
103
|
+
@port = port
|
|
104
|
+
|
|
105
|
+
@servers = Socket.tcp_server_sockets(@host, @port)
|
|
106
|
+
@servers.each do |s|
|
|
107
|
+
$l.info { "Ready to accept: #{s.local_address.inspect_sockaddr}" }
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
def start!
|
|
111
|
+
Socket.accept_loop(@servers) do |con|
|
|
112
|
+
$l.info { "Connection from: #{con.remote_address.inspect_sockaddr}" }
|
|
113
|
+
con.close
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
Jibril::Server.new.start!
|
data/jibril.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "jibril/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "jibril"
|
|
9
|
+
spec.version = Jibril::VERSION
|
|
10
|
+
spec.authors = ["Wolf"]
|
|
11
|
+
spec.email = ["wolf@wolfsden.cz"]
|
|
12
|
+
|
|
13
|
+
spec.summary = %q{Simple configuration management tool.}
|
|
14
|
+
spec.description = <<~EOF
|
|
15
|
+
Simple chef-inspired configuration management tool. While chef is awesome,
|
|
16
|
+
it has crazy high requirements (mainly memory-wise) for managing like
|
|
17
|
+
8 devices I have.
|
|
18
|
+
|
|
19
|
+
Ansible would be great IF all my devices were reachable, however some are
|
|
20
|
+
behind NATs.
|
|
21
|
+
|
|
22
|
+
Jibril tries to solve both issue. It's designed to be light on the server
|
|
23
|
+
(raspberry pi is enough), with one server (so NATs are not an issue)
|
|
24
|
+
and ruby DSL for the configuration scripts (so like chef, I don't like the
|
|
25
|
+
way ansible uses yaml for this).
|
|
26
|
+
EOF
|
|
27
|
+
spec.homepage = "https://github.com/graywolf/jibril"
|
|
28
|
+
spec.license = "MIT"
|
|
29
|
+
|
|
30
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
31
|
+
f.match(%r{^(test|spec|features)/})
|
|
32
|
+
end
|
|
33
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
34
|
+
spec.require_paths = ["lib"]
|
|
35
|
+
|
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
39
|
+
end
|
data/lib/jibril.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
module Jibril
|
|
6
|
+
class Config
|
|
7
|
+
def initialize(conf_file)
|
|
8
|
+
@conf = YAML.load_file(conf_file)
|
|
9
|
+
end
|
|
10
|
+
def bind
|
|
11
|
+
@conf[:bind]
|
|
12
|
+
end
|
|
13
|
+
def port
|
|
14
|
+
@conf[:port]
|
|
15
|
+
end
|
|
16
|
+
def key
|
|
17
|
+
@conf[:key]
|
|
18
|
+
end
|
|
19
|
+
def crt
|
|
20
|
+
@conf[:crt]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jibril
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Wolf
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-01-27 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
description: |
|
|
56
|
+
Simple chef-inspired configuration management tool. While chef is awesome,
|
|
57
|
+
it has crazy high requirements (mainly memory-wise) for managing like
|
|
58
|
+
8 devices I have.
|
|
59
|
+
|
|
60
|
+
Ansible would be great IF all my devices were reachable, however some are
|
|
61
|
+
behind NATs.
|
|
62
|
+
|
|
63
|
+
Jibril tries to solve both issue. It's designed to be light on the server
|
|
64
|
+
(raspberry pi is enough), with one server (so NATs are not an issue)
|
|
65
|
+
and ruby DSL for the configuration scripts (so like chef, I don't like the
|
|
66
|
+
way ansible uses yaml for this).
|
|
67
|
+
email:
|
|
68
|
+
- wolf@wolfsden.cz
|
|
69
|
+
executables:
|
|
70
|
+
- jibril-client.rb
|
|
71
|
+
- jibril-server.rb
|
|
72
|
+
extensions: []
|
|
73
|
+
extra_rdoc_files: []
|
|
74
|
+
files:
|
|
75
|
+
- ".gitignore"
|
|
76
|
+
- Gemfile
|
|
77
|
+
- LICENSE.txt
|
|
78
|
+
- README.md
|
|
79
|
+
- Rakefile
|
|
80
|
+
- bin/jibril-client.rb
|
|
81
|
+
- bin/jibril-server.rb
|
|
82
|
+
- jibril.gemspec
|
|
83
|
+
- lib/jibril.rb
|
|
84
|
+
- lib/jibril/config.rb
|
|
85
|
+
- lib/jibril/version.rb
|
|
86
|
+
homepage: https://github.com/graywolf/jibril
|
|
87
|
+
licenses:
|
|
88
|
+
- MIT
|
|
89
|
+
metadata: {}
|
|
90
|
+
post_install_message:
|
|
91
|
+
rdoc_options: []
|
|
92
|
+
require_paths:
|
|
93
|
+
- lib
|
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
requirements: []
|
|
105
|
+
rubyforge_project:
|
|
106
|
+
rubygems_version: 2.7.3
|
|
107
|
+
signing_key:
|
|
108
|
+
specification_version: 4
|
|
109
|
+
summary: Simple configuration management tool.
|
|
110
|
+
test_files: []
|