Closed ScrumpyJack closed 3 years ago
I think the problem is here
https://github.com/nitefood/asn/blob/d280c0aeaa1edb032e3f5c1fae88cbf42282d637/asn#L2300-L2304
If ipify returns an IPv6 address for the host it's run from, then HAVE_IPV6 is set to true, but if a host passed to /asn_lookup& resolves to A records (and no AAAA records, thus populating $ip with a list of IPv4 addresses), then the grep on 2301 fails and $ip_to_trace doesn't get assigned anything.
Not sure why it works on the command line mode yet, it's possibly due to the fact that this bit gets skipped.
Great catch! Again good analysis, this check gets indeed skipped when running from command line since its only purpose is to grab the first relevant IP when running web lookups, in order to speed up execution. The use case you describe (IPv6 on the server, IPv4-only target) is one that I missed while testing.
Can you please try changing line 2300 from:
if [ "$HAVE_IPV6" = true ]; then
to:
if [ "$HAVE_IPV6" = true ] && grep -q ':' <<<"$ip"; then
and confirm it fixes it?
Thanks again for your feedback!
That'll do it. Thanks.
When running in server mode, compare if you will
/asn_lookup&bbc.co.uk
and
/asn_lookup&www.bbc.co.uk
The error is:
Looks like $rev doesn't get a value. I'll take a closer when i get some time
./asn www.bbc.co.uk works fine on the command line.