From 3e04ffd7f6d8bf7151bb3f03bbf3bc29db971d41 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 4 Nov 2025 18:05:23 -0300 Subject: [PATCH] feat: retrieve asn owner --- src/asn.cr | 4 +++- src/ip2asn_server.cr | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/asn.cr b/src/asn.cr index 6e2dd7c..4248912 100644 --- a/src/asn.cr +++ b/src/asn.cr @@ -6,12 +6,14 @@ class AsnResult property id : Int64? property country : String? + # TODO: Deprecate? property description : String? + property owner_id : Int64? property blocked : Bool? end class ASN - QUERY = "select id, country, description from asn where ? between range_start and range_end limit 1;" + QUERY = "select asns.id, country, owners.description, owner_id from asns left join owners on owners.id = asns.owner_id where ? between range_start and range_end limit 1;" STATUS = "select blocked from status where id = ? limit 1;" property db : DB::Database diff --git a/src/ip2asn_server.cr b/src/ip2asn_server.cr index d57a512..fd378b0 100644 --- a/src/ip2asn_server.cr +++ b/src/ip2asn_server.cr @@ -16,6 +16,7 @@ Log.setup_from_env VERSION = "0.2.0" ASN_ID = "id" ASN_DESCRIPTION = "description" +ASN_OWNER_ID = "owner_id" ASN_COUNTRY = "country" ASN_BLOCKED = "blocked" @@ -70,6 +71,7 @@ RedisServer.new(interface, port) do |client, _, key| response = case field when ASN_ID then result.try(&.id).try(&.to_s) + when ASN_OWNER_ID then result.try(&.owner_id).try(&.to_s) when ASN_COUNTRY then result.try(&.country) when ASN_DESCRIPTION then result.try(&.description) when ASN_BLOCKED then