resolver.pl
来自「boa:著名嵌入式系统网页服务器源代码。」· PL 代码 · 共 25 行
PL
25 行
#!/usr/bin/perl
# IP address resolver for Boa
# If you want an "in place" change to the log file,
# change the first line to
#!/usr/local/bin/perl -i.bak
# Otherwise, send the output of this program wherever you want:
# resolver.pl access_log >access_log_resolved
$AF_INET = 2;
while(<>) {
next unless (($ip, $rest) = /([\d\.]+) (.*)/o);
if(!$hosts{$ip}) {
$packed_ip = pack('C4', split(/\./, $ip));
$host = (gethostbyaddr($packed_ip, $AF_INET))[0];
$hosts{$ip} = ($host ? $host : $ip);
}
print "$hosts{$ip} $rest\n";
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?