Two different Varnish implementations of uap-core
allowing Varnish to classify a user-agent string and extracts some information from them.
It's not as advanced as deviceAtlas, but it relies on an open-database.
The first implementation targets Varnish Enterprise and uses vmod-rewrite to match the user-agent with the database entries. The second one is a pure-VCL implementation suitable for Varnish Cache. It's slower than the Varnish Enterprise option, but it requires no vmod.
You'll need:
go>= 1.16makecurl- either Varnish Cache or Varnish Enterprise
# build
make
# run tests on Enterprise
make check-enterprise
# or on Cache
make check-ossRunning make will generate both uap-enterprise.vcl uap-enterprise.vtc. Include either of them and call uap_detect (they both implement it) from a client subroutine such as vcl_recv.
As a result, uap_detect will populate these request headers (req.http.*) matching the results found in regexes.yaml:
ua-familyua-majorua-minorua-patchos-familyos-majoros-minoros-patchos-patch_minordevice-familydevice-branddevice-model
Example VCL:
vcl 4.1;
import std;
include "./uap-oss.vcl";
backend default none;
sub vcl_recv {
call uap_detect;
std.log("device family is: " + req.http.device-family);
return (synth(200));
}