This Varnish module exports functions to look up Autonomous System Numbers (ASN) from https://iptoasn.com/ tsv database.
Example
vcl 4.1;
import asn;
backend be none;
sub vcl_init {
new objasn = asn.init("ip2asn-combined.tsv");
}
sub vcl_recv {
set req.http.asn = objasn.asn(client.ip);
set req.http.company = objasn.asn(
std.ip(req.http.X-forwarded-for, "0.0.0.0"));
}
OBJECT init(STRING)
Create an ASN object and load a TSV file.
Arguments: None
Type: Object
Returns: Object.
STRING .asn(IP)
Lookup ASN from IP
Arguments: None
Type: Method
Returns: String
STRING .company(IP)
Lookup company from IP
Arguments: None
Type: Method
Returns: String
STRING .country(IP)
Lookup country of ASN from IP
vcl(7), varnishd(1)
Arguments: None
Type: Method
Returns: String