paraxial 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a6510720489f0277f96eef42e60e10e7f3958ab6a3763aa3941c022c497a314
4
- data.tar.gz: 497e56a5048f7b6cbb5d2238e5d9059a66cec676dde27d9474faaaee6a5d0fb6
3
+ metadata.gz: be68560342effbc4099f126d85e25acf0400e0b27dc636f4173192a9a634d3da
4
+ data.tar.gz: 489450bae67581a1738754843a8ce3b6128ad098aa88228d1823bf41ce0ebada
5
5
  SHA512:
6
- metadata.gz: 64182cfa8039d867bbc5e113e5f421a3e1141e833790222c52ae6191099289fbd056cef3163442c949db576d1de76402c8d5196fd05da46169e34f64de77ab71
7
- data.tar.gz: 7fbc2ed7db3b3afb3d43a935e667d4ffc26464034c7070f8d15ba28db03c9ee5fb1fc327d56005ecefd615a39845cc8fe5f5e5aa92975186b3c9f3b615c1410b
6
+ metadata.gz: edd5307bcc69fcff116b2873d5571b035808f76bf508447403da5a1064d7faea2d230ceb12f0e6318469815b18d23254a6b4adf914b6c0bca009ac807f35d8fd
7
+ data.tar.gz: f473320f53f772245dad48f68edeb47271ebe22e921b73b6cfe74506b6e5ccc8925ebf6621f2a4a46f0b6f9c2282c9580f498572f85dc6214fe21359d59dcc52
@@ -5,6 +5,7 @@ module Paraxial
5
5
  @bans = { 'v4' => Patricia.new, 'v6' => Patricia.new(:AF_INET6) }
6
6
  @buffer = Queue.new
7
7
  @mutex = Mutex.new
8
+ @headers = { 'Content-Type': 'application/json' }
8
9
 
9
10
  if Paraxial::Helpers.get_api_key
10
11
  @thread = Thread.new do
@@ -44,11 +45,8 @@ module Paraxial
44
45
  puts "[Paraxial] HTTP ingest not supported on free tier"
45
46
  else
46
47
  Thread.new do
47
- uri = URI.parse(Paraxial::Helpers.get_ingest_url) # Replace with your endpoint
48
- headers = { 'Content-Type': 'application/json' }
49
- resp = Net::HTTP.post(uri, body.to_json, headers)
50
- puts "ingest_url resp.code: #{resp.code}"
51
- puts resp.body
48
+ uri = URI.parse(Paraxial::Helpers.get_ingest_url)
49
+ Net::HTTP.post(uri, body.to_json, @headers)
52
50
  end
53
51
  end
54
52
  end
@@ -56,11 +54,10 @@ module Paraxial
56
54
 
57
55
  def self.get_abr
58
56
  uri = URI.parse(Paraxial::Helpers.get_abr_url)
59
- headers = { 'Content-Type': 'application/json' }
60
57
 
61
58
  body = { api_key: Paraxial::Helpers.get_api_key }
62
59
  begin
63
- r = Net::HTTP.post(uri, body.to_json, headers)
60
+ r = Net::HTTP.post(uri, body.to_json, @headers)
64
61
  if r.code == '200'
65
62
  put_abr(JSON.parse(r.body))
66
63
  else
@@ -132,7 +129,53 @@ module Paraxial
132
129
  end
133
130
  end
134
131
 
132
+ def self.ban_ip_msg(ip, length, msg)
133
+ local_ban(ip)
134
+
135
+ uri = URI.parse(Paraxial::Helpers.get_ruby_ban_url)
136
+ body =
137
+ {
138
+ bad_ip: ip,
139
+ ban_length: length,
140
+ msg: msg,
141
+ api_key: Paraxial::Helpers.get_api_key
142
+ }
143
+ r = Net::HTTP.post(uri, body.to_json, @headers)
144
+ if r.code == '200'
145
+ :ok
146
+ else
147
+ :error
148
+ end
149
+ end
150
+
151
+ def self.honeypot_ban(ip, length)
152
+ local_ban(ip)
153
+
154
+ uri = URI.parse(Paraxial::Helpers.get_honeypot_url)
155
+
156
+ body = { api_key: Paraxial::Helpers.get_api_key, bad_ip: ip, ban_length: length }
157
+ r = Net::HTTP.post(uri, body.to_json, @headers)
158
+ if r.code == '200'
159
+ :ok
160
+ else
161
+ :error
162
+ end
163
+ end
164
+
135
165
  def self.ban_ip(ip)
166
+ local_ban(ip)
167
+ uri = URI.parse(Paraxial::Helpers.get_ban_url)
168
+
169
+ body = { api_key: Paraxial::Helpers.get_api_key, ip_address: ip }
170
+ r = Net::HTTP.post(uri, body.to_json, @headers)
171
+ if r.code == '200'
172
+ :ok
173
+ else
174
+ :error
175
+ end
176
+ end
177
+
178
+ def self.local_ban(ip)
136
179
  if ip.include?('.')
137
180
  # IPv4
138
181
  current_t = @bans['v4']
@@ -144,17 +187,6 @@ module Paraxial
144
187
  current_t.add(ip)
145
188
  @bans['v6'] = current_t
146
189
  end
147
-
148
- uri = URI.parse(Paraxial::Helpers.get_ban_url)
149
- headers = { 'Content-Type': 'application/json' }
150
-
151
- body = { api_key: Paraxial::Helpers.get_api_key, ip_address: ip }
152
- r = Net::HTTP.post(uri, body.to_json, headers)
153
- if r.code == '200'
154
- :ok
155
- else
156
- :error
157
- end
158
190
  end
159
191
 
160
192
  def self.allow_ip?(ip)
@@ -24,6 +24,14 @@ module Paraxial
24
24
  get_paraxial_url + '/api/ingest'
25
25
  end
26
26
 
27
+ def self.get_honeypot_url
28
+ get_paraxial_url + '/api/honeypot_ban_x'
29
+ end
30
+
31
+ def self.get_ruby_ban_url
32
+ get_paraxial_url + '/api/ruby_ban_x'
33
+ end
34
+
27
35
  def self.get_api_key
28
36
  @paraxial_api_key ||= ENV['PARAXIAL_API_KEY']
29
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paraxial
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
data/lib/paraxial.rb CHANGED
@@ -59,7 +59,6 @@ module Paraxial
59
59
  cloud_ip: request.env['paraxial.cloud_ip'],
60
60
  host: request.host
61
61
  }
62
- puts req_hash
63
62
  Paraxial::Checker.req_to_buff(req_hash)
64
63
  end
65
64
 
@@ -127,6 +126,18 @@ module Paraxial
127
126
  Paraxial::Checker.ban_ip(ip)
128
127
  end
129
128
 
129
+ def self.ban_ip_msg(ip, length, msg)
130
+ return if Paraxial::Helpers.get_api_key.nil?
131
+
132
+ Paraxial::Checker.ban_ip_msg(ip, length, msg)
133
+ end
134
+
135
+ def self.honeypot_ban(ip, length = :week)
136
+ return if Paraxial::Helpers.get_api_key.nil?
137
+
138
+ Paraxial::Checker.honeypot_ban(ip, length)
139
+ end
140
+
130
141
  def self.allow_ip?(ip)
131
142
  return if Paraxial::Helpers.get_api_key.nil?
132
143
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paraxial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lubas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-21 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec