apache-log-geo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/apache-log-geo +3 -0
- data/lib.rb +1 -0
- data/mmdb-lookup +13 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34da9d9d49ed08a9b3c0fc01aafd3051de023dc0632909d804cb4640d5cbff00
|
4
|
+
data.tar.gz: fb5d34390295623bfacfb093f28cd4ccf794dc6bd34f0fb65b4c3f042230f085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b90aea1bf592f196d8573b41f8e938163d78411c13246847d126f5e231c5653a41614df5168efbccda596ea9f5b122b3fa3e79c1a5d528a88cac70448b81a31
|
7
|
+
data.tar.gz: ff158b0ad399224776055d414c7b84fc52fee9c08ee3b500e20bfa19ecb6ae0d032257487e19d48ee392291381b351ad762394a028757faabfdbae5c8be0c28d
|
data/README.md
CHANGED
@@ -79,8 +79,8 @@ $ cat test/access.log | ./apache-log-geo --cc 'ie|de' | wc -l
|
|
79
79
|
|
80
80
|
### mmdb-lookup
|
81
81
|
|
82
|
-
Renders
|
83
|
-
|
82
|
+
Renders data about ip addresses in newline-delimited json (default) or
|
83
|
+
in a shell script ready format:
|
84
84
|
|
85
85
|
~~~
|
86
86
|
$ ./mmdb-lookup -h
|
@@ -104,7 +104,7 @@ Kyiv City
|
|
104
104
|
Replicate `apache-log-geo` util--print only the requests from the Irish
|
105
105
|
(the example requires `npm -g json`):
|
106
106
|
|
107
|
-
$ cat test/access.log | ./mmdb-lookup | json -c 'this.country_code == "IE"' -a ip | grep -h -f - test/access.log
|
107
|
+
$ cat test/access.log | ./mmdb-lookup | json -g -c 'this.country_code == "IE"' -a ip | grep -h -f - test/access.log
|
108
108
|
|
109
109
|
## Exit status
|
110
110
|
|
data/apache-log-geo
CHANGED
data/lib.rb
CHANGED
data/mmdb-lookup
CHANGED
@@ -5,8 +5,8 @@ require_relative 'lib'
|
|
5
5
|
include ApacheLogGeo
|
6
6
|
|
7
7
|
class FMT
|
8
|
-
def initialize input, geo
|
9
|
-
@input = input; @geo = geo
|
8
|
+
def initialize input, geo, callback
|
9
|
+
@input = input; @geo = geo; @cb = method(callback)
|
10
10
|
@errors = 0
|
11
11
|
end
|
12
12
|
attr_accessor :errors
|
@@ -24,7 +24,7 @@ class FMT
|
|
24
24
|
"#{k}=#{(v.is_a?(Array) ? v.join(',') : v.to_s).shellescape}"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
r.join "\n"
|
27
|
+
@cb.call r.join "\n"
|
28
28
|
end
|
29
29
|
|
30
30
|
def json
|
@@ -36,11 +36,12 @@ class FMT
|
|
36
36
|
end
|
37
37
|
|
38
38
|
if @input.is_a?(IO) # stdin, in which we expect an apache log
|
39
|
-
@input.
|
39
|
+
@input.each_line do |line|
|
40
|
+
next if line =~ /^\s*$/
|
41
|
+
@cb.call trans.call(line.split[0]).to_json
|
42
|
+
end
|
40
43
|
else # argv
|
41
|
-
@input.map
|
42
|
-
list.split.map { |ip| trans.call ip }
|
43
|
-
end.flatten.to_json
|
44
|
+
@input.map {|ip| @cb.call trans.call(ip).to_json }
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
@@ -66,6 +67,9 @@ rescue
|
|
66
67
|
errx 2, $!
|
67
68
|
end
|
68
69
|
|
69
|
-
|
70
|
-
|
70
|
+
Signal.trap 'SIGINT', sigint_handler
|
71
|
+
Signal.trap 'SIGPIPE', sigint_handler
|
72
|
+
|
73
|
+
fmt = FMT.new (ARGV.size > 0 ? ARGV : $stdin), geo, :puts
|
74
|
+
fmt.send opt[:fmt]
|
71
75
|
exit fmt.errors > 0 ? 1 : 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apache-log-geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Gromnitsky
|
8
8
|
autorequire:
|
9
9
|
bindir: "."
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maxmind-db
|