tarbit 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fdb81b5d9d98958d081c9fb3fdc25ec216bd0b9b8d1ceb1284eb3e898482d9a
4
- data.tar.gz: 5ca27088bb0c658716d09edb4236227f2ef298654eb9c166b86ec4261ffb8462
3
+ metadata.gz: 94cb32b706a9f0bfd2a036dbc831aa6702b4a9795d212faa9b0c55ae9038e43c
4
+ data.tar.gz: 4da4a50fea4bca2a4e90bf5397cc5c302380f8623222223361c2b227401ddd43
5
5
  SHA512:
6
- metadata.gz: b47d842599e19cedeb839f73ae732d85bd9059cba24dae157651ca8dd4ca802154849086b2d62b37c8a726091b95481fca1828d71fd825dc0df021a753ae2509
7
- data.tar.gz: 02632a2259b571ced4bccf13c6d051ea83e3e9381252a1d2025ccfc1301e818bf92ec3f7a7b1693737bcb14147e6f11381a3bf092678be13a4cfe3907ea27a0a
6
+ metadata.gz: 17847c8874fe99434b8c9b1e47aaac142f506c2f2c97b5e24c9870052bdbc89751197d6e8a12f2b953a6a2a6ff35bf2032f9117a7503c69ca3919254f118c289
7
+ data.tar.gz: c8219d0ad15c5ece548d626a6049daf64d6aab085e2eb2a0780c2047c9794c4d83f8cfd8c7e5099f3795f29545da4f5c46d08839d20c9b5305b55e1730fe83ad
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .idea/
2
2
  .DS_Store
3
3
  data/*.png
4
+ *.gem
data/bin/tarbit CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'commander/import'
4
4
  require 'tarbit'
5
+ require 'fileutils'
5
6
 
6
7
  # :name is optional, otherwise uses the basename of this executable
7
8
  program :name, 'Tarbit - SSH Tarpit using Ruby'
@@ -14,10 +15,12 @@ command :serve do |c|
14
15
  c.option '--debug', nil, 'Runs the apollo server in debug mode'
15
16
  c.option '--suffix STRING', String, 'Adds a suffix to bar'
16
17
  c.action do |args, options|
18
+
19
+ FileUtils.mkdir_p File.expand_path ('~/.tarbit/stats/')
17
20
  puts "Starting tarbit ssh tarpit"
18
21
 
19
22
  server = Tarbit::Server.new
20
- statistic = Tarbit::Statistic.new(server, 10)
23
+ statistic = Tarbit::Statistic.new(server, 600)
21
24
 
22
25
  Async do |task|
23
26
  statistic.watch
data/lib/tarbit/server.rb CHANGED
@@ -30,17 +30,22 @@ module Tarbit
30
30
  stream = Async::IO::Stream.new(peer)
31
31
  Async.logger.info "New connection: #{stream}"
32
32
 
33
+ id = SecureRandom.uuid
34
+
33
35
  @connections << {
34
36
  created_at: Date.new,
35
- id: SecureRandom.uuid
37
+ id: id
36
38
  }
37
39
 
38
40
  while true do
39
41
  task.sleep 1
42
+ if stream.eof?
43
+ raise Async::TimeoutError.new
44
+ end
40
45
  stream.write "#{rand(10)}\r\n"
41
46
  end
42
47
  rescue Async::TimeoutError => e
43
- @connections.delete stream
48
+ @connections = @connections.reject { |stats| stats.fetch(:id) == id }
44
49
  Async.logger.info "Connection closed: #{stream}"
45
50
  end
46
51
  end
@@ -22,6 +22,7 @@ module Tarbit
22
22
  private
23
23
 
24
24
  def write_line_chart
25
+ return if @server.connections.size == 0 and @history.size == 0
25
26
 
26
27
  # Add point in time
27
28
  @history << {
@@ -38,7 +39,7 @@ module Tarbit
38
39
 
39
40
  g.data :Bots, @history.map {|point_in_time| point_in_time.fetch(:connections).size }
40
41
 
41
- g.write('data/exciting.png')
42
+ g.write(File.expand_path ('~/.tarbit/stats/line_chart.png'))
42
43
  end
43
44
 
44
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tarbit
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niklas Hanft