Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dex4er/perl-anyevent-dns-etchosts
AnyEvent::DNS::EtcHosts - Use /etc/hosts before DNS
https://github.com/dex4er/perl-anyevent-dns-etchosts
Last synced: 11 days ago
JSON representation
AnyEvent::DNS::EtcHosts - Use /etc/hosts before DNS
- Host: GitHub
- URL: https://github.com/dex4er/perl-anyevent-dns-etchosts
- Owner: dex4er
- Created: 2013-12-09T00:39:20.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-06-28T22:18:33.000Z (over 1 year ago)
- Last Synced: 2024-10-28T09:02:01.515Z (about 2 months ago)
- Language: Perl
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
AnyEvent::DNS::EtcHosts - Use /etc/hosts before DNS
SYNOPSIS
use AnyEvent::DNS::EtcHosts;
use AnyEvent::DNS;
my $cv = AE::cv;
AnyEvent::DNS::any 'example.com', sub {
say foreach map { $_->[4] } grep { $_->[1] =~ /^(a|aaaa)$/ } @_;
$cv->send;
};
use AnyEvent::Socket;
my $cv = AE::cv;
AnyEvent::Socket::resolve_sockaddr $domain, $service, $proto, $family, undef, sub {
say foreach map { format_address((AnyEvent::Socket::unpack_sockaddr($_->[3]))[1]) } @_;
$cv->send;
};DESCRIPTION
AnyEvent::DNS::EtcHosts changes AnyEvent::DNS behavior. The /etc/hosts
file is searched before DNS, so it is possible to override DNS entries.The DNS lookups are emulated. This resolver returns the standard DNS
reply based on /etc/hosts file rather than real DNS.You can choose a different file by changing PERL_ANYEVENT_HOSTS
environment variable.This module also disables the original AnyEvent::Socket's helper
function which reads /etc/hosts file after the DNS entry was not found.
It prevents reading this file twice.The AnyEvent::Socket resolver searches IPv4 and IPv6 addresses
separately. If you don't want to check the addresses in DNS, both IPv4
and IPv6 addresses should be placed in /etc/hosts or the protocol
family should be set explicitly for resolve_sockaddr function.SEE ALSO
AnyEvent::DNS, AnyEvent::Socket.
BUGS
This module might be incompatible with further versions of AnyEvent
module.If you find the bug or want to implement new features, please report it
at https://github.com/dex4er/perl-AnyEvent-DNS-EtcHosts/issuesThe code repository is available at
http://github.com/dex4er/perl-AnyEvent-DNS-EtcHostsAUTHORS
Piotr Roszatycki
Helper functions taken from AnyEvent::Socket 7.05 by Marc Lehmann
LICENSE
Copyright (c) 2013-2014, 2023 Piotr Roszatycki .
This is free software; you can redistribute it and/or modify it under
the same terms as perl itself.See http://dev.perl.org/licenses/artistic.html