minbox 0.1.6 → 0.2.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/.rspec +0 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +55 -61
- data/LICENSE.txt +1 -1
- data/README.md +5 -9
- data/Rakefile +2 -8
- data/bin/console +3 -3
- data/bin/setup +6 -6
- data/bin/test +8 -0
- data/exe/minbox +1 -1
- data/lib/minbox/cli.rb +14 -14
- data/lib/minbox/client.rb +22 -22
- data/lib/minbox/inbox.rb +6 -8
- data/lib/minbox/publisher.rb +1 -14
- data/lib/minbox/server.rb +5 -5
- data/lib/minbox/version.rb +1 -1
- data/lib/minbox.rb +22 -12
- data/minbox.gemspec +29 -29
- data/tmp/.keep +0 -0
- metadata +52 -47
- data/.rubocop.yml +0 -91
- data/.ruby-version +0 -1
- data/.travis.yml +0 -7
- data/Dockerfile +0 -12
- data/bin/docker-build +0 -17
- data/bin/lint +0 -11
- data/lib/minbox/core.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d7e36521d1640041d736722e1bfd3ddc7c9f5277b53b12cacc970d80adb6b89
|
4
|
+
data.tar.gz: a179d2f4c61b165554d95235c5bea5aa2abdb6e9d3e425bb1511c66181c51e2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7448ba3e383fa799162a0824aa7b1db84ee6244a03eba46a91861b3f05dfb0a3b88f7f348d65c0dccdc494705690fb266209004baa66bca0d05a39e421302ea5
|
7
|
+
data.tar.gz: c918ff6787ff028dd23a221b075d77c3d4b5d71c34abfb7efea2a612f6e67038ca5757bde359d3b535e33920b1179fe1b4e8c841cf965a71a9f0116b9946ebd1
|
data/.rspec
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,87 +1,81 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
minbox (0.
|
4
|
+
minbox (0.2.0)
|
5
|
+
base64 (~> 0.3)
|
5
6
|
concurrent-ruby (~> 1.1)
|
6
7
|
hashie (~> 3.6)
|
7
8
|
listen (~> 3.1)
|
9
|
+
logger (~> 1.0)
|
8
10
|
mail (~> 2.7)
|
9
|
-
|
10
|
-
|
11
|
+
net-smtp (~> 0.1)
|
12
|
+
openssl (~> 3.0)
|
13
|
+
thor (~> 1.0)
|
11
14
|
|
12
15
|
GEM
|
13
16
|
remote: https://rubygems.org/
|
14
17
|
specs:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
ffi (1.10.0)
|
18
|
+
base64 (0.3.0)
|
19
|
+
concurrent-ruby (1.3.5)
|
20
|
+
date (3.4.1)
|
21
|
+
diff-lcs (1.6.2)
|
22
|
+
faker (3.5.2)
|
23
|
+
i18n (>= 1.8.11, < 2)
|
24
|
+
ffi (1.17.2-x86_64-linux-gnu)
|
25
|
+
fileutils (1.7.3)
|
24
26
|
hashie (3.6.0)
|
25
|
-
i18n (1.
|
27
|
+
i18n (1.14.7)
|
26
28
|
concurrent-ruby (~> 1.0)
|
27
|
-
|
28
|
-
|
29
|
-
rb-
|
30
|
-
|
31
|
-
|
32
|
-
mail (2.7.1)
|
29
|
+
listen (3.9.0)
|
30
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
31
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
32
|
+
logger (1.7.0)
|
33
|
+
mail (2.8.1)
|
33
34
|
mini_mime (>= 0.1.1)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
net-imap
|
36
|
+
net-pop
|
37
|
+
net-smtp
|
38
|
+
mini_mime (1.1.5)
|
39
|
+
net-imap (0.5.10)
|
40
|
+
date
|
41
|
+
net-protocol
|
42
|
+
net-pop (0.1.2)
|
43
|
+
net-protocol
|
44
|
+
net-protocol (0.2.2)
|
45
|
+
timeout
|
46
|
+
net-smtp (0.5.1)
|
47
|
+
net-protocol
|
48
|
+
openssl (3.3.0)
|
49
|
+
rake (13.3.0)
|
50
|
+
rb-fsevent (0.11.2)
|
51
|
+
rb-inotify (0.11.1)
|
43
52
|
ffi (~> 1.0)
|
44
|
-
|
45
|
-
|
46
|
-
rspec-
|
47
|
-
rspec-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
rspec-expectations (3.8.2)
|
53
|
+
rspec (3.13.1)
|
54
|
+
rspec-core (~> 3.13.0)
|
55
|
+
rspec-expectations (~> 3.13.0)
|
56
|
+
rspec-mocks (~> 3.13.0)
|
57
|
+
rspec-core (3.13.5)
|
58
|
+
rspec-support (~> 3.13.0)
|
59
|
+
rspec-expectations (3.13.5)
|
52
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
-
rspec-support (~> 3.
|
54
|
-
rspec-mocks (3.
|
61
|
+
rspec-support (~> 3.13.0)
|
62
|
+
rspec-mocks (3.13.5)
|
55
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
-
rspec-support (~> 3.
|
57
|
-
rspec-support (3.
|
58
|
-
|
59
|
-
|
60
|
-
parallel (~> 1.10)
|
61
|
-
parser (>= 2.5, != 2.5.1.1)
|
62
|
-
psych (>= 3.1.0)
|
63
|
-
rainbow (>= 2.2.2, < 4.0)
|
64
|
-
ruby-progressbar (~> 1.7)
|
65
|
-
unicode-display_width (>= 1.4.0, < 1.6)
|
66
|
-
rubocop-rspec (1.32.0)
|
67
|
-
rubocop (>= 0.60.0)
|
68
|
-
ruby-progressbar (1.10.0)
|
69
|
-
ruby_dep (1.5.0)
|
70
|
-
thor (0.20.3)
|
71
|
-
unicode-display_width (1.5.0)
|
64
|
+
rspec-support (~> 3.13.0)
|
65
|
+
rspec-support (3.13.6)
|
66
|
+
thor (1.4.0)
|
67
|
+
timeout (0.4.3)
|
72
68
|
|
73
69
|
PLATFORMS
|
74
|
-
|
70
|
+
x86_64-linux
|
75
71
|
|
76
72
|
DEPENDENCIES
|
77
73
|
bundler (~> 2.0)
|
78
|
-
|
79
|
-
|
74
|
+
faker (~> 3.0)
|
75
|
+
fileutils (~> 1.0)
|
80
76
|
minbox!
|
81
|
-
rake (~>
|
77
|
+
rake (~> 13.0)
|
82
78
|
rspec (~> 3.0)
|
83
|
-
rubocop (~> 0.52)
|
84
|
-
rubocop-rspec (~> 1.22)
|
85
79
|
|
86
80
|
BUNDLED WITH
|
87
|
-
2.
|
81
|
+
2.7.2
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,17 +4,13 @@ A minimal SMTP server written in ruby. `Minbox` offers a command line
|
|
4
4
|
interface and is useful for end-to-end test suites or as a standalone SMTP server
|
5
5
|
for development.
|
6
6
|
|
7
|
-
`Minbox` is capable of publishing email messages to `stdout`, the `file`
|
8
|
-
system
|
7
|
+
`Minbox` is capable of publishing email messages to `stdout`, or the `file`
|
8
|
+
system.
|
9
9
|
|
10
10
|
The `file` system publisher will write all emails to `./tmp` of the
|
11
11
|
directory where you run minbox from. Each file is named with the format
|
12
12
|
of `<timestamp>.eml`.
|
13
13
|
|
14
|
-
The `redis` publisher will publish all emails to a channel named
|
15
|
-
`minbox`. Use the `REDIS_URL` environment variable to control the redis
|
16
|
-
client configuration. See [this](https://github.com/redis/redis-rb/blob/df07a4c90413ed5dda7bc8fe928b00aaad5462fa/lib/redis/client.rb#L9) for more information.
|
17
|
-
|
18
14
|
## Installation
|
19
15
|
|
20
16
|
Add this line to your application's Gemfile:
|
@@ -52,10 +48,10 @@ D, [2019-03-12T17:08:19.679380 #36618] DEBUG -- : Server started!
|
|
52
48
|
|
53
49
|
You can use the `--output` option to configure the different types of
|
54
50
|
publishers to publish to. The following example will publish emails to
|
55
|
-
`stdout`, `file` system
|
51
|
+
`stdout`, and `file` system.
|
56
52
|
|
57
53
|
```bash
|
58
|
-
モ minbox server localhost 8080 --output=stdout file
|
54
|
+
モ minbox server localhost 8080 --output=stdout file
|
59
55
|
D, [2019-03-12T17:16:03.564426 #36907] DEBUG -- : Starting server on port 8080...
|
60
56
|
D, [2019-03-12T17:16:03.565964 #36907] DEBUG -- : Server started!
|
61
57
|
```
|
@@ -74,7 +70,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
74
70
|
|
75
71
|
## Contributing
|
76
72
|
|
77
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xlgmokha/minbox.
|
78
74
|
|
79
75
|
## License
|
80
76
|
|
data/Rakefile
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require 'rspec/core/rake_task'
|
6
|
-
require 'rubocop/rake_task'
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
7
5
|
|
8
6
|
RSpec::Core::RakeTask.new(:spec)
|
9
|
-
RuboCop::RakeTask.new(:rubocop)
|
10
|
-
Bundler::Audit::Task.new
|
11
|
-
|
12
|
-
task lint: [:rubocop, 'bundle:audit']
|
13
7
|
task default: :spec
|
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "minbox"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require 'minbox'
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require "irb"
|
15
15
|
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
data/bin/test
ADDED
data/exe/minbox
CHANGED
data/lib/minbox/cli.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "mail"
|
4
|
+
require "net/smtp"
|
5
|
+
require "openssl"
|
6
|
+
require "thor"
|
7
7
|
|
8
|
-
require
|
8
|
+
require "minbox"
|
9
9
|
|
10
10
|
module Minbox
|
11
11
|
module Cli
|
12
12
|
class Application < Thor
|
13
|
-
package_name
|
13
|
+
package_name "minbox"
|
14
14
|
|
15
|
-
method_option :from, type: :string, default:
|
16
|
-
method_option :to, type: :
|
15
|
+
method_option :from, type: :string, default: "me@example.org"
|
16
|
+
method_option :to, type: :array, default: ["them@example.org"]
|
17
17
|
method_option :subject, type: :string, default: "#{Time.now} This is a test message."
|
18
18
|
method_option :body, type: :string, default: "#{Time.now} This is a test message."
|
19
|
-
desc
|
20
|
-
def send(host =
|
19
|
+
desc "send <HOST> <PORT>", "Send mail to SMTP server"
|
20
|
+
def send(host = "localhost", port = 25)
|
21
21
|
Net::SMTP.start(host, port) do |smtp|
|
22
22
|
smtp.debug_output = Minbox.logger
|
23
23
|
smtp.send_message(create_mail(options).to_s, options[:from], options[:to])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
method_option :output, type: :array, default: [
|
27
|
+
method_option :output, type: :array, default: ["stdout"]
|
28
28
|
method_option :tls, type: :boolean, default: false
|
29
|
-
desc
|
30
|
-
def server(host =
|
29
|
+
desc "server <HOST> <PORT>", "SMTP server"
|
30
|
+
def server(host = "localhost", port = "25")
|
31
31
|
publisher = Publisher.from(options[:output])
|
32
32
|
server = Server.new(host: host, port: port, tls: options[:tls])
|
33
33
|
server.listen! do |mail|
|
@@ -35,7 +35,7 @@ module Minbox
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
desc
|
38
|
+
desc "version", "Display the current version"
|
39
39
|
def version
|
40
40
|
say Minbox::VERSION
|
41
41
|
end
|
data/lib/minbox/client.rb
CHANGED
@@ -3,62 +3,62 @@
|
|
3
3
|
module Minbox
|
4
4
|
class Ehlo
|
5
5
|
def run(client, line)
|
6
|
-
_ehlo, _client_domain = line.split(
|
6
|
+
_ehlo, _client_domain = line.split(" ")
|
7
7
|
client.write "250-#{client.server.host} offers a warm hug of welcome"
|
8
|
-
client.write
|
9
|
-
client.write
|
8
|
+
client.write "250-8BITMIME"
|
9
|
+
client.write "250-ENHANCEDSTATUSCODES"
|
10
10
|
# client.write "250 STARTTLS"
|
11
|
-
client.write
|
12
|
-
client.write
|
11
|
+
client.write "250-AUTH PLAIN LOGIN"
|
12
|
+
client.write "250 OK"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
class Helo
|
17
17
|
def run(client, line)
|
18
|
-
_ehlo,
|
19
|
-
client.write "250 #{
|
18
|
+
_ehlo, client_domain = line.split(" ")
|
19
|
+
client.write "250 Hello #{client_domain}, pleased to meet you"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
class Noop
|
24
24
|
def run(client, _line)
|
25
|
-
client.write
|
25
|
+
client.write "250 OK"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
class Quit
|
30
30
|
def run(client, _line)
|
31
|
-
client.write
|
31
|
+
client.write "221 Bye"
|
32
32
|
client.close
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
class Data
|
37
37
|
def run(client, _line)
|
38
|
-
client.write
|
38
|
+
client.write "354 End data with <CR><LF>.<CR><LF>"
|
39
39
|
body = []
|
40
40
|
line = client.read
|
41
41
|
until line.nil? || line.match(/^\.\r\n$/)
|
42
42
|
body << line
|
43
43
|
line = client.read
|
44
44
|
end
|
45
|
-
client.write
|
45
|
+
client.write "250 OK"
|
46
46
|
yield(Mail.new(body.join)) unless body.empty?
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
class StartTls
|
51
51
|
def run(client, _line)
|
52
|
-
client.write
|
52
|
+
client.write "220 Ready to start TLS"
|
53
53
|
client.secure_socket!
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
class AuthPlain
|
58
58
|
def run(client, line)
|
59
|
-
data = line.gsub(/AUTH PLAIN ?/i,
|
60
|
-
if data.strip ==
|
61
|
-
client.write
|
59
|
+
data = line.gsub(/AUTH PLAIN ?/i, "")
|
60
|
+
if data.strip == ""
|
61
|
+
client.write "334"
|
62
62
|
data = client.read
|
63
63
|
end
|
64
64
|
parts = Base64.decode64(data).split("\0")
|
@@ -70,12 +70,12 @@ module Minbox
|
|
70
70
|
|
71
71
|
class AuthLogin
|
72
72
|
def run(client, line)
|
73
|
-
username = line.gsub!(/AUTH LOGIN ?/i,
|
74
|
-
if username.strip ==
|
75
|
-
client.write
|
73
|
+
username = line.gsub!(/AUTH LOGIN ?/i, "")
|
74
|
+
if username.strip == ""
|
75
|
+
client.write "334 VXNlcm5hbWU6"
|
76
76
|
username = client.read
|
77
77
|
end
|
78
|
-
client.write
|
78
|
+
client.write "334 UGFzc3dvcmQ6"
|
79
79
|
password = Base64.decode64(client.read)
|
80
80
|
client.authenticate(username, password)
|
81
81
|
end
|
@@ -84,7 +84,7 @@ module Minbox
|
|
84
84
|
class Unsupported
|
85
85
|
def run(client, line)
|
86
86
|
client.logger.error(line)
|
87
|
-
client.write
|
87
|
+
client.write "502 Invalid/unsupported command"
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -152,9 +152,9 @@ module Minbox
|
|
152
152
|
|
153
153
|
def authenticate(username, password)
|
154
154
|
logger.debug("#{username}:#{password}")
|
155
|
-
return write
|
155
|
+
return write "535 Authenticated failed - protocol error" unless username && password
|
156
156
|
|
157
|
-
write
|
157
|
+
write "235 2.7.0 Authentication successful"
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
data/lib/minbox/inbox.rb
CHANGED
@@ -16,10 +16,8 @@ module Minbox
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def emails(count: 0)
|
19
|
-
wait_until { |x| x.count >= count } if count
|
20
|
-
with_lock
|
21
|
-
emails.values
|
22
|
-
end
|
19
|
+
wait_until { |x| x.count >= count } if count.positive?
|
20
|
+
with_lock(&:values)
|
23
21
|
end
|
24
22
|
|
25
23
|
def wait_until(seconds: 10, wait: 0.1)
|
@@ -33,8 +31,8 @@ module Minbox
|
|
33
31
|
nil
|
34
32
|
end
|
35
33
|
|
36
|
-
def wait_until!(
|
37
|
-
raise "timeout: expired
|
34
|
+
def wait_until!(seconds: 10, wait: 0.1, &block)
|
35
|
+
raise "timeout: expired" unless wait_until(seconds: seconds, wait: wait, &block)
|
38
36
|
end
|
39
37
|
|
40
38
|
def open(subject:)
|
@@ -52,14 +50,14 @@ module Minbox
|
|
52
50
|
end
|
53
51
|
|
54
52
|
def each
|
55
|
-
@emails.each do |
|
53
|
+
@emails.each do |_id, email|
|
56
54
|
yield email
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
private
|
61
59
|
|
62
|
-
def changed(
|
60
|
+
def changed(_modified, added, removed)
|
63
61
|
with_lock do |emails|
|
64
62
|
added.each do |file|
|
65
63
|
mail = Mail.read(file)
|
data/lib/minbox/publisher.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'redis'
|
4
|
-
|
5
3
|
module Minbox
|
6
4
|
class LogPublisher
|
7
5
|
def initialize(logger = Minbox.logger)
|
@@ -13,21 +11,11 @@ module Minbox
|
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
class RedisPublisher
|
17
|
-
def initialize(redis = Redis.new)
|
18
|
-
@redis = redis
|
19
|
-
end
|
20
|
-
|
21
|
-
def publish(mail)
|
22
|
-
@redis.publish('minbox', mail.to_s)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
14
|
class FilePublisher
|
27
15
|
attr_reader :dir
|
28
16
|
|
29
17
|
def initialize(dir = Dir.pwd)
|
30
|
-
@dir = File.join(dir,
|
18
|
+
@dir = File.join(dir, "tmp")
|
31
19
|
FileUtils.mkdir_p(@dir)
|
32
20
|
end
|
33
21
|
|
@@ -39,7 +27,6 @@ module Minbox
|
|
39
27
|
class Publisher
|
40
28
|
REGISTERED_PUBLISHERS = {
|
41
29
|
stdout: LogPublisher,
|
42
|
-
redis: RedisPublisher,
|
43
30
|
file: FilePublisher,
|
44
31
|
}.freeze
|
45
32
|
|
data/lib/minbox/server.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Minbox
|
4
4
|
class Server
|
5
|
-
SUBJECT =
|
5
|
+
SUBJECT = "/C=CA/ST=AB/L=Calgary/O=minbox/OU=development/CN=minbox"
|
6
6
|
attr_reader :host, :logger, :key, :server
|
7
7
|
|
8
|
-
def initialize(host:
|
8
|
+
def initialize(host: "localhost", port: 25, tls: false, logger: Minbox.logger, thread_pool: Concurrent::CachedThreadPool.new)
|
9
9
|
@host = host
|
10
10
|
@logger = logger
|
11
11
|
@tls = tls
|
@@ -21,7 +21,7 @@ module Minbox
|
|
21
21
|
|
22
22
|
def listen!(&block)
|
23
23
|
@server = upgrade(@server) if tls?
|
24
|
-
logger.debug(
|
24
|
+
logger.debug("Server started!")
|
25
25
|
|
26
26
|
loop do
|
27
27
|
handle(server.accept, &block)
|
@@ -78,8 +78,8 @@ module Minbox
|
|
78
78
|
extensions.subject_certificate =
|
79
79
|
extensions.issuer_certificate = certificate
|
80
80
|
[
|
81
|
-
[
|
82
|
-
[
|
81
|
+
["subjectKeyIdentifier", "hash", false],
|
82
|
+
["keyUsage", "keyEncipherment,digitalSignature", true],
|
83
83
|
].each do |x|
|
84
84
|
certificate.add_extension(extensions.create_extension(x[0], x[1], x[2]))
|
85
85
|
end
|
data/lib/minbox/version.rb
CHANGED
data/lib/minbox.rb
CHANGED
@@ -1,19 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
3
|
+
require "base64"
|
4
|
+
require "concurrent"
|
5
|
+
require "hashie"
|
6
|
+
require "listen"
|
7
|
+
require "logger"
|
8
|
+
require "socket"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require 'minbox/version'
|
10
|
+
require "minbox/client"
|
11
|
+
require "minbox/inbox"
|
12
|
+
require "minbox/publisher"
|
13
|
+
require "minbox/server"
|
14
|
+
require "minbox/version"
|
16
15
|
|
17
16
|
module Minbox
|
18
17
|
class Error < StandardError; end
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def logger
|
21
|
+
@logger ||= Logger.new(STDOUT)
|
22
|
+
end
|
23
|
+
|
24
|
+
def logger=(logger)
|
25
|
+
@logger = logger
|
26
|
+
end
|
27
|
+
end
|
19
28
|
end
|
29
|
+
|
data/minbox.gemspec
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "minbox/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "minbox"
|
9
9
|
spec.version = Minbox::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = ["mo khan"]
|
11
|
+
spec.email = ["mo@mokhan.ca"]
|
12
12
|
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
13
|
+
spec.summary = "A minimal smtp server."
|
14
|
+
spec.description = "A minimal smtp server."
|
15
|
+
spec.homepage = "https://www.mokhan.ca/"
|
16
|
+
spec.license = "MIT"
|
17
17
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
20
|
if spec.respond_to?(:metadata)
|
21
|
-
spec.metadata[
|
22
|
-
spec.metadata[
|
23
|
-
spec.metadata['changelog_uri'] = 'https://github.com/mokhan/minbox/blob/CHANGELOG.md'
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/xlgmokha/minbox"
|
24
23
|
else
|
25
|
-
raise
|
26
|
-
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
27
26
|
end
|
28
27
|
|
29
28
|
# Specify which files should be added to the gem when it is released.
|
@@ -31,21 +30,22 @@ Gem::Specification.new do |spec|
|
|
31
30
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
32
31
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
32
|
end
|
34
|
-
spec.bindir =
|
33
|
+
spec.bindir = "exe"
|
35
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = [
|
35
|
+
spec.require_paths = ["lib"]
|
37
36
|
|
38
|
-
spec.add_dependency
|
39
|
-
spec.add_dependency
|
40
|
-
spec.add_dependency
|
41
|
-
spec.add_dependency
|
42
|
-
spec.add_dependency
|
43
|
-
spec.add_dependency
|
44
|
-
spec.
|
45
|
-
spec.
|
46
|
-
spec.
|
47
|
-
spec.add_development_dependency
|
48
|
-
spec.add_development_dependency
|
49
|
-
spec.add_development_dependency
|
50
|
-
spec.add_development_dependency
|
37
|
+
spec.add_dependency "base64", "~> 0.3"
|
38
|
+
spec.add_dependency "concurrent-ruby", "~> 1.1"
|
39
|
+
spec.add_dependency "hashie", "~> 3.6"
|
40
|
+
spec.add_dependency "listen", "~> 3.1"
|
41
|
+
spec.add_dependency "logger", "~> 1.0"
|
42
|
+
spec.add_dependency "mail", "~> 2.7"
|
43
|
+
spec.add_dependency "net-smtp", "~> 0.1"
|
44
|
+
spec.add_dependency "openssl", "~> 3.0"
|
45
|
+
spec.add_dependency "thor", "~> 1.0"
|
46
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
47
|
+
spec.add_development_dependency "faker", "~> 3.0"
|
48
|
+
spec.add_development_dependency "fileutils", "~> 1.0"
|
49
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
50
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
51
51
|
end
|
data/tmp/.keep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo khan
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: base64
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0.3'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0.3'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: concurrent-ruby
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,145 +66,145 @@ dependencies:
|
|
53
66
|
- !ruby/object:Gem::Version
|
54
67
|
version: '3.1'
|
55
68
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
69
|
+
name: logger
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
58
71
|
requirements:
|
59
72
|
- - "~>"
|
60
73
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
74
|
+
version: '1.0'
|
62
75
|
type: :runtime
|
63
76
|
prerelease: false
|
64
77
|
version_requirements: !ruby/object:Gem::Requirement
|
65
78
|
requirements:
|
66
79
|
- - "~>"
|
67
80
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
81
|
+
version: '1.0'
|
69
82
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
83
|
+
name: mail
|
71
84
|
requirement: !ruby/object:Gem::Requirement
|
72
85
|
requirements:
|
73
86
|
- - "~>"
|
74
87
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
88
|
+
version: '2.7'
|
76
89
|
type: :runtime
|
77
90
|
prerelease: false
|
78
91
|
version_requirements: !ruby/object:Gem::Requirement
|
79
92
|
requirements:
|
80
93
|
- - "~>"
|
81
94
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
95
|
+
version: '2.7'
|
83
96
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
97
|
+
name: net-smtp
|
85
98
|
requirement: !ruby/object:Gem::Requirement
|
86
99
|
requirements:
|
87
100
|
- - "~>"
|
88
101
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
102
|
+
version: '0.1'
|
90
103
|
type: :runtime
|
91
104
|
prerelease: false
|
92
105
|
version_requirements: !ruby/object:Gem::Requirement
|
93
106
|
requirements:
|
94
107
|
- - "~>"
|
95
108
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
109
|
+
version: '0.1'
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
111
|
+
name: openssl
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
100
113
|
requirements:
|
101
114
|
- - "~>"
|
102
115
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
104
|
-
type: :
|
116
|
+
version: '3.0'
|
117
|
+
type: :runtime
|
105
118
|
prerelease: false
|
106
119
|
version_requirements: !ruby/object:Gem::Requirement
|
107
120
|
requirements:
|
108
121
|
- - "~>"
|
109
122
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
123
|
+
version: '3.0'
|
111
124
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
125
|
+
name: thor
|
113
126
|
requirement: !ruby/object:Gem::Requirement
|
114
127
|
requirements:
|
115
128
|
- - "~>"
|
116
129
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
118
|
-
type: :
|
130
|
+
version: '1.0'
|
131
|
+
type: :runtime
|
119
132
|
prerelease: false
|
120
133
|
version_requirements: !ruby/object:Gem::Requirement
|
121
134
|
requirements:
|
122
135
|
- - "~>"
|
123
136
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
137
|
+
version: '1.0'
|
125
138
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
139
|
+
name: bundler
|
127
140
|
requirement: !ruby/object:Gem::Requirement
|
128
141
|
requirements:
|
129
142
|
- - "~>"
|
130
143
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
144
|
+
version: '2.0'
|
132
145
|
type: :development
|
133
146
|
prerelease: false
|
134
147
|
version_requirements: !ruby/object:Gem::Requirement
|
135
148
|
requirements:
|
136
149
|
- - "~>"
|
137
150
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
151
|
+
version: '2.0'
|
139
152
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
153
|
+
name: faker
|
141
154
|
requirement: !ruby/object:Gem::Requirement
|
142
155
|
requirements:
|
143
156
|
- - "~>"
|
144
157
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
158
|
+
version: '3.0'
|
146
159
|
type: :development
|
147
160
|
prerelease: false
|
148
161
|
version_requirements: !ruby/object:Gem::Requirement
|
149
162
|
requirements:
|
150
163
|
- - "~>"
|
151
164
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
165
|
+
version: '3.0'
|
153
166
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
167
|
+
name: fileutils
|
155
168
|
requirement: !ruby/object:Gem::Requirement
|
156
169
|
requirements:
|
157
170
|
- - "~>"
|
158
171
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
172
|
+
version: '1.0'
|
160
173
|
type: :development
|
161
174
|
prerelease: false
|
162
175
|
version_requirements: !ruby/object:Gem::Requirement
|
163
176
|
requirements:
|
164
177
|
- - "~>"
|
165
178
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
179
|
+
version: '1.0'
|
167
180
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
181
|
+
name: rake
|
169
182
|
requirement: !ruby/object:Gem::Requirement
|
170
183
|
requirements:
|
171
184
|
- - "~>"
|
172
185
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0
|
186
|
+
version: '13.0'
|
174
187
|
type: :development
|
175
188
|
prerelease: false
|
176
189
|
version_requirements: !ruby/object:Gem::Requirement
|
177
190
|
requirements:
|
178
191
|
- - "~>"
|
179
192
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0
|
193
|
+
version: '13.0'
|
181
194
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
195
|
+
name: rspec
|
183
196
|
requirement: !ruby/object:Gem::Requirement
|
184
197
|
requirements:
|
185
198
|
- - "~>"
|
186
199
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
200
|
+
version: '3.0'
|
188
201
|
type: :development
|
189
202
|
prerelease: false
|
190
203
|
version_requirements: !ruby/object:Gem::Requirement
|
191
204
|
requirements:
|
192
205
|
- - "~>"
|
193
206
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
207
|
+
version: '3.0'
|
195
208
|
description: A minimal smtp server.
|
196
209
|
email:
|
197
210
|
- mo@mokhan.ca
|
@@ -202,37 +215,30 @@ extra_rdoc_files: []
|
|
202
215
|
files:
|
203
216
|
- ".gitignore"
|
204
217
|
- ".rspec"
|
205
|
-
- ".rubocop.yml"
|
206
|
-
- ".ruby-version"
|
207
|
-
- ".travis.yml"
|
208
|
-
- Dockerfile
|
209
218
|
- Gemfile
|
210
219
|
- Gemfile.lock
|
211
220
|
- LICENSE.txt
|
212
221
|
- README.md
|
213
222
|
- Rakefile
|
214
223
|
- bin/console
|
215
|
-
- bin/docker-build
|
216
|
-
- bin/lint
|
217
224
|
- bin/setup
|
225
|
+
- bin/test
|
218
226
|
- exe/minbox
|
219
227
|
- lib/minbox.rb
|
220
228
|
- lib/minbox/cli.rb
|
221
229
|
- lib/minbox/client.rb
|
222
|
-
- lib/minbox/core.rb
|
223
230
|
- lib/minbox/inbox.rb
|
224
231
|
- lib/minbox/publisher.rb
|
225
232
|
- lib/minbox/server.rb
|
226
233
|
- lib/minbox/version.rb
|
227
234
|
- minbox.gemspec
|
235
|
+
- tmp/.keep
|
228
236
|
homepage: https://www.mokhan.ca/
|
229
237
|
licenses:
|
230
238
|
- MIT
|
231
239
|
metadata:
|
232
240
|
homepage_uri: https://www.mokhan.ca/
|
233
|
-
source_code_uri: https://github.com/
|
234
|
-
changelog_uri: https://github.com/mokhan/minbox/blob/CHANGELOG.md
|
235
|
-
post_install_message:
|
241
|
+
source_code_uri: https://github.com/xlgmokha/minbox
|
236
242
|
rdoc_options: []
|
237
243
|
require_paths:
|
238
244
|
- lib
|
@@ -247,8 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
253
|
- !ruby/object:Gem::Version
|
248
254
|
version: '0'
|
249
255
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
251
|
-
signing_key:
|
256
|
+
rubygems_version: 3.7.2
|
252
257
|
specification_version: 4
|
253
258
|
summary: A minimal smtp server.
|
254
259
|
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop/cop/internal_affairs
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
Exclude:
|
7
|
-
- 'coverage/**/*'
|
8
|
-
- 'pkg/**/*'
|
9
|
-
- 'tmp/**/*'
|
10
|
-
- 'vendor/**/*'
|
11
|
-
TargetRubyVersion: 2.6
|
12
|
-
|
13
|
-
Layout/AlignParameters:
|
14
|
-
Enabled: true
|
15
|
-
EnforcedStyle: with_fixed_indentation
|
16
|
-
IndentationWidth: 2
|
17
|
-
|
18
|
-
Layout/ClassStructure:
|
19
|
-
Enabled: true
|
20
|
-
Categories:
|
21
|
-
module_inclusion:
|
22
|
-
- include
|
23
|
-
- prepend
|
24
|
-
- extend
|
25
|
-
ExpectedOrder:
|
26
|
-
- module_inclusion
|
27
|
-
- constants
|
28
|
-
- public_class_methods
|
29
|
-
- initializer
|
30
|
-
- instance_methods
|
31
|
-
- protected_methods
|
32
|
-
- private_methods
|
33
|
-
|
34
|
-
Layout/EndOfLine:
|
35
|
-
EnforcedStyle: lf
|
36
|
-
|
37
|
-
Layout/IndentArray:
|
38
|
-
EnforcedStyle: consistent
|
39
|
-
|
40
|
-
Layout/IndentHeredoc:
|
41
|
-
EnforcedStyle: active_support
|
42
|
-
|
43
|
-
Layout/MultilineMethodCallIndentation:
|
44
|
-
Enabled: true
|
45
|
-
EnforcedStyle: indented
|
46
|
-
|
47
|
-
Lint/AmbiguousBlockAssociation:
|
48
|
-
Exclude:
|
49
|
-
- 'spec/**/*.rb'
|
50
|
-
|
51
|
-
Lint/InterpolationCheck:
|
52
|
-
Exclude:
|
53
|
-
- 'spec/**/*.rb'
|
54
|
-
|
55
|
-
Metrics/BlockLength:
|
56
|
-
Exclude:
|
57
|
-
- '**/*.rake'
|
58
|
-
- '*.gemspec'
|
59
|
-
- 'Rakefile'
|
60
|
-
- 'spec/**/*.rb'
|
61
|
-
|
62
|
-
Metrics/ModuleLength:
|
63
|
-
Exclude:
|
64
|
-
- 'spec/**/*.rb'
|
65
|
-
|
66
|
-
Metrics/LineLength:
|
67
|
-
Exclude:
|
68
|
-
- 'spec/**/*.rb'
|
69
|
-
IgnoredPatterns:
|
70
|
-
- '^#*'
|
71
|
-
|
72
|
-
Style/Documentation:
|
73
|
-
Enabled: false
|
74
|
-
|
75
|
-
Style/EachWithObject:
|
76
|
-
Enabled: false
|
77
|
-
|
78
|
-
Style/StringLiterals:
|
79
|
-
EnforcedStyle: 'single_quotes'
|
80
|
-
|
81
|
-
Style/TrailingCommaInArrayLiteral:
|
82
|
-
Enabled: false
|
83
|
-
|
84
|
-
Style/TrailingCommaInHashLiteral:
|
85
|
-
Enabled: false
|
86
|
-
|
87
|
-
RSpec/NamedSubject:
|
88
|
-
Enabled: false
|
89
|
-
|
90
|
-
RSpec/NestedGroups:
|
91
|
-
Max: 4
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.6.1
|
data/.travis.yml
DELETED
data/Dockerfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
FROM ruby:2.6-alpine
|
2
|
-
ENV PACKAGES build-base tzdata
|
3
|
-
RUN apk update && \
|
4
|
-
apk upgrade && \
|
5
|
-
apk add $PACKAGES && \
|
6
|
-
rm -fr /var/cache/apk/* && \
|
7
|
-
apk del build-base
|
8
|
-
WORKDIR /opt/minbox
|
9
|
-
EXPOSE 25
|
10
|
-
VOLUME ["/opt/minbox/tmp"]
|
11
|
-
RUN gem install minbox
|
12
|
-
CMD ["minbox", "server", "localhost", "25", "--output=stdout file"]
|
data/bin/docker-build
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
rm -fr pkg/
|
4
|
-
mkdir -p pkg/
|
5
|
-
cp Dockerfile pkg/
|
6
|
-
docker pull ruby:2.6-alpine
|
7
|
-
docker image build \
|
8
|
-
--no-cache \
|
9
|
-
-t "mokhan/minbox:latest" \
|
10
|
-
-f pkg/Dockerfile pkg/
|
11
|
-
|
12
|
-
if [[ -z "${DOCKER_PUSH}" ]]; then
|
13
|
-
echo 'skip push'
|
14
|
-
else
|
15
|
-
echo 'pushing...'
|
16
|
-
docker push "mokhan/minbox:latest"
|
17
|
-
fi
|
data/bin/lint
DELETED