Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
b4e6a0100a
|
|||
|
b86f0318a3
|
|||
|
9fdf239422
|
|||
|
01833e22ca
|
|||
|
8a5f6cc260
|
@@ -1,5 +1,9 @@
|
||||
version: 2.0
|
||||
shards:
|
||||
blank:
|
||||
git: https://github.com/kostya/blank.git
|
||||
version: 0.2.0
|
||||
|
||||
db:
|
||||
git: https://github.com/crystal-lang/crystal-db.git
|
||||
version: 0.11.0
|
||||
|
||||
@@ -12,3 +12,5 @@ dependencies:
|
||||
github: "will/crystal-pg"
|
||||
sqlite3:
|
||||
github: "crystal-lang/crystal-sqlite3"
|
||||
blank:
|
||||
github: "kostya/blank"
|
||||
|
||||
+48
-42
@@ -11,8 +11,9 @@ require "./models/access_log"
|
||||
require "./models/crawler"
|
||||
require "./swd"
|
||||
require "./asn"
|
||||
require "./presence"
|
||||
|
||||
VERSION = "0.6.2"
|
||||
VERSION = "0.6.4"
|
||||
|
||||
Log.setup_from_env
|
||||
|
||||
@@ -167,52 +168,52 @@ DB.open database do |db|
|
||||
# AccessLog as a NamedTuple.
|
||||
db.exec query,
|
||||
UUID.random.to_s,
|
||||
access_log.remote_user,
|
||||
access_log.host,
|
||||
access_log.msec,
|
||||
access_log.server_protocol,
|
||||
access_log.request_method,
|
||||
access_log.request_completion,
|
||||
access_log.uri,
|
||||
access_log.request_uri,
|
||||
access_log.query_string,
|
||||
access_log.remote_user.presence,
|
||||
access_log.host.presence,
|
||||
access_log.msec.presence,
|
||||
access_log.server_protocol.presence,
|
||||
access_log.request_method.presence,
|
||||
access_log.request_completion.presence,
|
||||
access_log.uri.presence,
|
||||
access_log.request_uri.presence,
|
||||
access_log.query_string.presence,
|
||||
access_log.status,
|
||||
access_log.sent_http_content_type,
|
||||
access_log.sent_http_content_encoding,
|
||||
access_log.sent_http_etag,
|
||||
access_log.sent_http_last_modified,
|
||||
access_log.http_accept,
|
||||
access_log.http_accept_encoding,
|
||||
access_log.http_accept_language,
|
||||
access_log.http_pragma,
|
||||
access_log.http_cache_control,
|
||||
access_log.http_if_none_match,
|
||||
access_log.http_dnt,
|
||||
access_log.http_user_agent,
|
||||
access_log.http_origin,
|
||||
access_log.http_referer,
|
||||
access_log.sent_http_content_type.presence,
|
||||
access_log.sent_http_content_encoding.presence,
|
||||
access_log.sent_http_etag.presence,
|
||||
access_log.sent_http_last_modified.presence,
|
||||
access_log.http_accept.presence,
|
||||
access_log.http_accept_encoding.presence,
|
||||
access_log.http_accept_language.presence,
|
||||
access_log.http_pragma.presence,
|
||||
access_log.http_cache_control.presence,
|
||||
access_log.http_if_none_match.presence,
|
||||
access_log.http_dnt.presence,
|
||||
access_log.http_user_agent.presence,
|
||||
access_log.http_origin.presence,
|
||||
access_log.http_referer.presence,
|
||||
access_log.request_time,
|
||||
access_log.bytes_sent,
|
||||
access_log.body_bytes_sent,
|
||||
access_log.request_length,
|
||||
access_log.http_connection,
|
||||
access_log.pipe,
|
||||
access_log.http_connection.presence,
|
||||
access_log.pipe.presence,
|
||||
access_log.connection_requests,
|
||||
access_log.geoip2_data_country_name,
|
||||
access_log.geoip2_data_city_name,
|
||||
access_log.ssl_server_name,
|
||||
access_log.ssl_protocol,
|
||||
access_log.ssl_early_data,
|
||||
access_log.ssl_session_reused,
|
||||
access_log.ssl_curves,
|
||||
access_log.ssl_ciphers,
|
||||
access_log.ssl_cipher,
|
||||
access_log.sent_http_x_xss_protection,
|
||||
access_log.sent_http_x_frame_options,
|
||||
access_log.sent_http_x_content_type_options,
|
||||
access_log.sent_http_strict_transport_security,
|
||||
access_log.nginx_version,
|
||||
access_log.pid,
|
||||
access_log.geoip2_data_country_name.presence,
|
||||
access_log.geoip2_data_city_name.presence,
|
||||
access_log.ssl_server_name.presence,
|
||||
access_log.ssl_protocol.presence,
|
||||
access_log.ssl_early_data.presence,
|
||||
access_log.ssl_session_reused.presence,
|
||||
access_log.ssl_curves.presence,
|
||||
access_log.ssl_ciphers.presence,
|
||||
access_log.ssl_cipher.presence,
|
||||
access_log.sent_http_x_xss_protection.presence,
|
||||
access_log.sent_http_x_frame_options.presence,
|
||||
access_log.sent_http_x_content_type_options.presence,
|
||||
access_log.sent_http_strict_transport_security.presence,
|
||||
access_log.nginx_version.presence,
|
||||
access_log.pid.presence,
|
||||
(crawler ? !!(crawler_re =~ access_log.http_user_agent) : false),
|
||||
(swd ? s.try(&.datacenter_co2) : nil),
|
||||
(swd ? s.try(&.network_co2) : nil),
|
||||
@@ -221,7 +222,12 @@ DB.open database do |db|
|
||||
(swd ? s.try(&.total_co2) : nil),
|
||||
(node ? System.hostname : nil),
|
||||
a.try(&.id),
|
||||
access_log.http3
|
||||
access_log.http3.presence,
|
||||
access_log.http_sec_fetch_mode.presence,
|
||||
access_log.http_sec_fetch_dest.presence,
|
||||
access_log.http_sec_fetch_site.presence,
|
||||
access_log.http_sec_fetch_user.presence,
|
||||
access_log.http_sec_purpose.presence
|
||||
|
||||
# Ignore parsing errors
|
||||
rescue e : JSON::ParseException
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
require "blank"
|
||||
|
||||
class Object
|
||||
def presence
|
||||
return nil if blank?
|
||||
|
||||
self
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user