blocklistshow 1.2 → 1.3
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/CHANGELOG.md +20 -0
- data/README.md +1 -1
- data/bin/blocklist.rb +30 -3
- data/bin/unblock.rb +70 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d12abe9119afea6df652e56becb1cd8589a7cc877c6d02906924c9a4c1fc55de
|
4
|
+
data.tar.gz: 04ccb9bd6eb05003552941e5e7f97ee69962e88600549ef1b4f61f763776bcd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e00f66b08006f8027d4dfca7a5cec2b20246426e5b4f4d0774eff69dcc049cc2f58555a1a6903bfe9710badbe97d87ea2ec912109040a5c42ccc80fef715914
|
7
|
+
data.tar.gz: a789c14563f452b07f127c4eef4e8b95c1cfde14936a6b9671a734bd102bece3c879c1357315acae4848fba6d425256268e194c11136bc5c5c28f9c158152219
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 1.3 (2024-12-01)
|
2
|
+
|
3
|
+
- Gem release
|
4
|
+
- call helper to unblock
|
5
|
+
- support new filenames
|
6
|
+
|
7
|
+
## 1.2 (2023-09-30)
|
8
|
+
|
9
|
+
- Gem release
|
10
|
+
- add unblock.rb
|
11
|
+
|
12
|
+
## 1.1 (2023-09-27)
|
13
|
+
|
14
|
+
- Gem release
|
15
|
+
- rubocop cleanups
|
16
|
+
|
17
|
+
## 1.0 (2021-05-02)
|
18
|
+
|
19
|
+
- Gem release
|
20
|
+
|
1
21
|
## 1.0 (2020-11-06)
|
2
22
|
|
3
23
|
- Initial Release.
|
data/README.md
CHANGED
data/bin/blocklist.rb
CHANGED
@@ -3,8 +3,35 @@
|
|
3
3
|
require 'ipaddr'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
# find matching filenames
|
7
|
+
def find_files( list )
|
8
|
+
list.each do |filename|
|
9
|
+
next if filename == ''
|
10
|
+
|
11
|
+
return filename if File.exist?( filename )
|
12
|
+
end
|
13
|
+
|
14
|
+
list.first
|
15
|
+
end
|
16
|
+
|
17
|
+
CC_CACHE_FILES = [
|
18
|
+
'/var/db/blocklistd.cc.json',
|
19
|
+
'/var/db/blacklistd.cc.json'
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
DNS_CACHE_FILES = [
|
23
|
+
'/var/db/blocklistd.dns.json',
|
24
|
+
'/var/db/blacklistd.dns.json'
|
25
|
+
].freeze
|
26
|
+
|
27
|
+
BLOCKLISTCTL_FILES = [
|
28
|
+
`which blocklistctl`.delete( "\n" ),
|
29
|
+
`which blacklistctl`.delete( "\n" )
|
30
|
+
]
|
31
|
+
|
32
|
+
CC_CACHE_FILE = find_files( CC_CACHE_FILES )
|
33
|
+
DNS_CACHE_FILE = find_files( DNS_CACHE_FILES )
|
34
|
+
BLOCKLISTCTL = find_files( BLOCKLISTCTL_FILES )
|
8
35
|
|
9
36
|
# pkg install databases/ruby-bdb net/webalizer-geodb
|
10
37
|
GEODB_FILE = '/usr/local/share/geolizer/GeoDB.dat'.freeze
|
@@ -139,7 +166,7 @@ end
|
|
139
166
|
|
140
167
|
load_cache
|
141
168
|
list = []
|
142
|
-
raw =
|
169
|
+
raw = `#{BLOCKLISTCTL} dump -b -n -w`
|
143
170
|
# pp raw
|
144
171
|
raw.split( "\n" ).each do |line|
|
145
172
|
address_port, state, _nfail, access = line.split( "\t", 4 )
|
data/bin/unblock.rb
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
#!/usr/local/bin/ruby
|
2
2
|
|
3
|
-
|
3
|
+
def find_files( list )
|
4
|
+
list.each do |filename|
|
5
|
+
next if filename == ''
|
6
|
+
|
7
|
+
return filename if File.exist?( filename )
|
8
|
+
end
|
9
|
+
|
10
|
+
list.first
|
11
|
+
end
|
12
|
+
|
13
|
+
BDB_FILES = [
|
14
|
+
'/var/db/blocklistd.db',
|
15
|
+
'/var/db/blacklistd.db'
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
HELPER_FILES = [
|
19
|
+
'/usr/local/libexec/blocklistd-helper',
|
20
|
+
'/usr/libexec/blacklistd-helper',
|
21
|
+
'/libexec/blocklistd-helper'
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
BDB_FILE = find_files( BDB_FILES ).freeze
|
25
|
+
HELPER_FILE = find_files( HELPER_FILES ).freeze
|
26
|
+
|
4
27
|
LOCAL_BDB_FILE_MODE = 0o0600
|
5
28
|
LOCAL_BDB_OPTIONS = { 'set_pagesize' => 1024, 'set_cachesize' => 32 * 1024 }.freeze
|
6
29
|
|
@@ -78,10 +101,51 @@ def search_db( dbh, list )
|
|
78
101
|
found
|
79
102
|
end
|
80
103
|
|
104
|
+
PROTOCOLS = {
|
105
|
+
6 => 'tcp',
|
106
|
+
17 => 'udp',
|
107
|
+
132 => 'sctp'
|
108
|
+
}.freeze
|
109
|
+
|
110
|
+
def decode_key( key )
|
111
|
+
af = key[ 1 .. 1 ].unpack1( 'C' )
|
112
|
+
{
|
113
|
+
af: af,
|
114
|
+
ip: decode_ip( key, af ),
|
115
|
+
mask: key[ 128 .. 131 ].unpack1( 'L' ),
|
116
|
+
port: key[ 132 .. 135 ].unpack1( 'L' ),
|
117
|
+
proto: PROTOCOLS[ key[ 136 .. 139 ].unpack1( 'L' ) ],
|
118
|
+
family: key[ 140 .. 143 ].unpack1( 'L' ),
|
119
|
+
uid: key[ 144 .. 147 ].unpack1( 'L' ),
|
120
|
+
nfail: key[ 148 .. 151 ].unpack1( 'L' ),
|
121
|
+
name: key[ 152 .. 279 ].delete( "\0" ),
|
122
|
+
rmask: key[ 280 .. 283 ].unpack1( 'L' ),
|
123
|
+
duration: key[ 284 .. 287 ].unpack1( 'L' )
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
def decode_data( key )
|
128
|
+
{
|
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" )
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
81
137
|
def remove_db( dbh, found )
|
82
138
|
removed = 0
|
83
139
|
found.each do |key|
|
140
|
+
# pp key
|
141
|
+
h = decode_key( key )
|
142
|
+
# data = dbh[ key ]
|
143
|
+
# pp decode_data( data )
|
84
144
|
dbh.delete( key )
|
145
|
+
# pp h
|
146
|
+
line = "#{HELPER_FILE} 'rem' '#{h[ :name ]}' '#{h[ :proto ]}' '#{h[ :ip ]}' '#{h[ :mask ]}' '#{h[ :port ]}' '#{h[ :uid ]}'"
|
147
|
+
puts line
|
148
|
+
`#{line}`
|
85
149
|
removed += 1
|
86
150
|
end
|
87
151
|
puts "removed: #{removed}"
|
@@ -89,6 +153,11 @@ def remove_db( dbh, found )
|
|
89
153
|
dbh.close
|
90
154
|
end
|
91
155
|
|
156
|
+
if ARGV.empty?
|
157
|
+
warn "#{$0} IP-Addresss [ IP-Addresss ] [ ... ]"
|
158
|
+
exit 64
|
159
|
+
end
|
160
|
+
|
92
161
|
dbh = BDB1::Hash.open( BDB_FILE,
|
93
162
|
BDB1::WRITE | BDB1::CREATE,
|
94
163
|
LOCAL_BDB_FILE_MODE,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blocklistshow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dirk Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Display of data from blocklistd on FreeBSD with country codes and reverse
|
14
14
|
DNS.
|
@@ -49,7 +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.
|
52
|
+
rubygems_version: 3.5.22
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: show blocklistd data
|