blocklistshow 1.3 → 1.4

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: d12abe9119afea6df652e56becb1cd8589a7cc877c6d02906924c9a4c1fc55de
4
- data.tar.gz: 04ccb9bd6eb05003552941e5e7f97ee69962e88600549ef1b4f61f763776bcd5
3
+ metadata.gz: 34b39ec980acfb4429c4db89284e00377f0b87d6fc55b0809bc510b77c6ec0c6
4
+ data.tar.gz: 60867006da7dc29205e0cfae0b8dd2211bac5246f45aad9dac35d1bb16863a4d
5
5
  SHA512:
6
- metadata.gz: 3e00f66b08006f8027d4dfca7a5cec2b20246426e5b4f4d0774eff69dcc049cc2f58555a1a6903bfe9710badbe97d87ea2ec912109040a5c42ccc80fef715914
7
- data.tar.gz: a789c14563f452b07f127c4eef4e8b95c1cfde14936a6b9671a734bd102bece3c879c1357315acae4848fba6d425256268e194c11136bc5c5c28f9c158152219
6
+ metadata.gz: f12d7b7c0f3f8b7163af7cb6dab53f0e6b24c01b694fe9650a67479693eb2c78f2179fd18bb6745545b6c8a1bf2a53116fa6eb5e92b60f4c1986f92deef5865a
7
+ data.tar.gz: 47ae8bddda24ffd0238d45d83a5515a67289f8689aa7a7c677705310151f5bef03cfaf75332a622b345809b1d277f29ab7ef155b9cd894c682affa99d099418d
data/.rubocop.yml CHANGED
@@ -24,7 +24,8 @@ Layout/SpaceInsideReferenceBrackets:
24
24
  Exclude:
25
25
  - 'blocklistshow.gemspec'
26
26
 
27
- Metrics/LineLength:
27
+ #Metrics/LineLength:
28
+ Layout/LineLength:
28
29
  Exclude:
29
30
  - 'blocklistshow.gemspec'
30
31
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.4 (2026-03-29)
2
+ - Gem release
3
+ - Support database format 2025
4
+
1
5
  ## 1.3 (2024-12-01)
2
6
 
3
7
  - Gem release
data/Makefile ADDED
@@ -0,0 +1,10 @@
1
+
2
+ cop:
3
+ rubocop
4
+
5
+ auto::
6
+ rubocop --auto-gen-config
7
+
8
+ gem::
9
+ gem build blocklistshow.gemspec
10
+
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+
2
+ Diagnostic tools for blocklistd
3
+
data/bin/blocklist.rb CHANGED
@@ -27,7 +27,7 @@ DNS_CACHE_FILES = [
27
27
  BLOCKLISTCTL_FILES = [
28
28
  `which blocklistctl`.delete( "\n" ),
29
29
  `which blacklistctl`.delete( "\n" )
30
- ]
30
+ ].freeze
31
31
 
32
32
  CC_CACHE_FILE = find_files( CC_CACHE_FILES )
33
33
  DNS_CACHE_FILE = find_files( DNS_CACHE_FILES )
@@ -164,12 +164,28 @@ until ARGV.empty?
164
164
  end
165
165
  end
166
166
 
167
+ #
168
+ # Format 2024:
169
+ # blocklistctl dump
170
+ # address/ma:port id nfail last access
171
+ # XX.XXX.XX.XX/32:22 OK 3/3 2026/03/28 04:24:51
172
+ #
173
+ # Format 2025:
174
+ # blocklistctl dump
175
+ # rulename address/ma:port id nfail last access
176
+ # blocklistd XXX.XX.XXX.XX/32:25 3/3 2026/03/28 20:40:06
177
+ #
178
+
167
179
  load_cache
168
180
  list = []
169
181
  raw = `#{BLOCKLISTCTL} dump -b -n -w`
170
182
  # pp raw
171
183
  raw.split( "\n" ).each do |line|
172
- address_port, state, _nfail, access = line.split( "\t", 4 )
184
+ if line[ 0 ] == ' ' # Format 2024
185
+ address_port, state, _nfail, access = line.split( "\t", 4 )
186
+ else
187
+ _rulename, address_port, state, _nfail, access = line.split( "\t", 5 )
188
+ end
173
189
  list.push( [ access, address_port, state ] )
174
190
  end
175
191
  list.sort.each do |row|
data/bin/unblock.rb CHANGED
@@ -32,6 +32,8 @@ require 'bdb1'
32
32
 
33
33
  # /usr/src/contrib/blacklist/bin/conf.h
34
34
  # struct conf {
35
+ # size_t c_lineno; # Fromat 2025
36
+ # struct sockaddr_storage c_ss;
35
37
  # struct sockaddr_storage c_ss;
36
38
  # int c_lmask;
37
39
  # int c_port;
@@ -60,6 +62,15 @@ require 'bdb1'
60
62
  # char __ss_pad2[_SS_PAD2SIZE];
61
63
  # };
62
64
 
65
+ def fix_key( key )
66
+ case key.size
67
+ when 296 # Format 2025
68
+ return key[ 8 .. ]
69
+ end
70
+ # Format 2024
71
+ key
72
+ end
73
+
63
74
  def decode_ip( key, afamily )
64
75
  case afamily
65
76
  when 2
@@ -92,7 +103,7 @@ def search_db( dbh, list )
92
103
  found = []
93
104
  dbh.each_key do |key|
94
105
  # pp key, val
95
- ip2 = ip_from_key( key ).to_s
106
+ ip2 = ip_from_key( fix_key( key ) ).to_s
96
107
  next unless list.include?( ip2 )
97
108
 
98
109
  puts "ip2: #{ip2}"
@@ -122,25 +133,25 @@ def decode_key( key )
122
133
  rmask: key[ 280 .. 283 ].unpack1( 'L' ),
123
134
  duration: key[ 284 .. 287 ].unpack1( 'L' )
124
135
  }
125
- end
136
+ end
126
137
 
127
- def decode_data( key )
138
+ def decode_data( buffer )
128
139
  {
129
- count: key[ 0 .. 3 ].unpack1( 'L' ),
130
- pad1: key[ 4 .. 7 ].unpack1( 'L' ),
131
- time1: Time.at( key[ 8 .. 11 ].unpack1( 'L' ) ),
132
- time2: key[ 12 .. 15 ].unpack1( 'L' ),
133
- text: key[ 16 .. 79 ].delete( "\0" )
140
+ count: buffer[ 0 .. 3 ].unpack1( 'L' ),
141
+ pad1: buffer[ 4 .. 7 ].unpack1( 'L' ),
142
+ time1: Time.at( buffer[ 8 .. 11 ].unpack1( 'L' ) ),
143
+ time2: buffer[ 12 .. 15 ].unpack1( 'L' ),
144
+ text: buffer[ 16 .. 79 ].delete( "\0" )
134
145
  }
135
- end
146
+ end
136
147
 
137
148
  def remove_db( dbh, found )
138
149
  removed = 0
139
150
  found.each do |key|
140
151
  # pp key
141
- h = decode_key( key )
142
- # data = dbh[ key ]
143
- # pp decode_data( data )
152
+ h = decode_key( fix_key( key ) )
153
+ # buffer = dbh[ key ]
154
+ # pp decode_data( buffer )
144
155
  dbh.delete( key )
145
156
  # pp h
146
157
  line = "#{HELPER_FILE} 'rem' '#{h[ :name ]}' '#{h[ :proto ]}' '#{h[ :ip ]}' '#{h[ :mask ]}' '#{h[ :port ]}' '#{h[ :uid ]}'"
metadata CHANGED
@@ -1,18 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blocklistshow
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Meyer
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Display of data from blocklistd on FreeBSD with country codes and reverse
14
13
  DNS.
15
- email:
16
14
  executables:
17
15
  - blocklist.rb
18
16
  - geodb-lookup.rb
@@ -26,15 +24,17 @@ files:
26
24
  - CHANGELOG.md
27
25
  - Gemfile
28
26
  - LICENSE.txt
27
+ - Makefile
29
28
  - README.md
29
+ - TODO
30
30
  - bin/blocklist.rb
31
31
  - bin/geodb-lookup.rb
32
32
  - bin/unblock.rb
33
33
  homepage: https://rubygems.org/gems/blocklistshow
34
34
  licenses:
35
35
  - MIT
36
- metadata: {}
37
- post_install_message:
36
+ metadata:
37
+ rubygems_mfa_required: 'true'
38
38
  rdoc_options: []
39
39
  require_paths:
40
40
  - lib
@@ -49,8 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.5.22
53
- signing_key:
52
+ rubygems_version: 4.0.7
54
53
  specification_version: 4
55
54
  summary: show blocklistd data
56
55
  test_files: []