Last active
December 19, 2021 04:50
-
-
Save DrI-T/ee7ac22e9f7ed01cb75708dfa2b12d5a to your computer and use it in GitHub Desktop.
nf-req-id.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# curl -I https://app.netlify.app/ | |
use YAML::XS qw(Dump); | |
my $resp = &head_url('http://clock.netlify.app/'); | |
#printf "resp: %s\n",Dump($resp); | |
#printf "headers: %s\n",Dump($resp->headers); | |
my $rid = $resp->headers()->{'x-nf-request-id'}; | |
printf "rid: %s\n",$rid; | |
my $stamp = &decode_base36($rid); | |
printf "t: %s\n",time; | |
printf "stamp: %s (%db)\n",unpack('H*',$stamp),length($stamp)*8; | |
my @n = unpack'N*',$stamp; | |
printf "n: %s\n",join',',@n; | |
exit $?; | |
sub head_url { | |
my $url = shift; | |
use LWP::Simple qw(head); | |
my $resp = head $url; | |
warn "Couldn't head $url" unless defined $resp; | |
return $resp; | |
} | |
sub encode_base36 { | |
use Math::BigInt; | |
use Math::Base36 qw(); | |
my $n = Math::BigInt->from_bytes(shift); | |
my $k36 = Math::Base36::encode_base36($n,@_); | |
#$k36 =~ y,0-9A-Z,A-Z0-9,; | |
return $k36; | |
} | |
sub decode_base36 { | |
use Math::BigInt; | |
use Math::Base36 qw(); | |
#$k36 = uc($_[0]) | |
#$k36 =~ y,A-Z0-9,0-9A-Z; | |
my $n = Math::Base36::decode_base36($_[0]); | |
my $bin = Math::BigInt->new($n)->as_bytes(); | |
return $bin; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment