0
A
回答
1
要獲得頻道中人員的位置,您可以簡單地查看他們的主機名 - IRC上的名稱由暱稱,用戶名和主機名組成,格式爲暱稱!用戶名@主機名。
主機名可能是三件事之一 - IP地址,DNS名稱或「斗篷」。您可以使用DNS客戶端將主機名轉換爲IP地址,然後使用IP地址使用IP地理定位工具(例如ipinfodb.com,它有一個很好的免費API),並檢索每個用戶的經度和緯度。
如果主機名稱是一種幌子,並且其格式因網絡而異,則無法獲得該用戶的真實IP /主機名(以及位置)(除非您擁有IRC網絡上的高級權限) 。
1
拉多斯拉夫·傑林斯基(拉狄克在PLD-linux的點ORG)寫了一個Perl腳本在XChat的IRC客戶端暱稱的地理位置:
我寫了一個簡單的插件來查找IP地址,在Maxmind的GeoIP查找數據庫,你可以在這裏找到它:xchat-geo.pl。有關安裝說明,請參閱「perldoc xchat-geo.pl」。
用法:
/geo some_nickname
輸出:
[17時33] ==> some_nickname |美國加州舊金山37.7525 -122.3194 [email protected]
原始博客文章:www.radek.cc/2009/09/06/irc-xchat-geolocation-plugin/
它要求您安裝:
- 的Perl
- 的的MaxMind GeoIP的數據庫之一(有些是免費的)
- 的地理的MaxMind :: IP模塊(其爲Perl API)
- XChat的與一個Perl腳本接口插件
xchat-geo.pl,檢索2012-03-06:
#!/usr/bin/perl -w
use strict;
use Geo::IP();
our $VERSION = '0.04';
=head1 NAME
xchat-geo.pl - geolocation plugin for xchat
=head1 SYNOPSIS
perl -MCPAN -e 'install Geo::IP'
chmod +x xchat-geo.pl
mv xchat-geo.pl ~/.xchat/
# in xchat
/unload .xchat/xchat-geo.pl
/load .xchat/xchat-geo.pl
/geo some-nickname
=head1 DESCRIPTION
Usage:
/geo some_nickname
[17:33] ==> some_nickname | US San Francisco CA 37.7525 -122.3194
[email protected]
Provides a single C</geo> command, which attempts to lookup the IP address in
the maxmind GeoIP database.
Requires the Geo::IP module to be installed, along with the GeoIP City (or its
free GeoLite counterpart); see L<http://www.maxmind.com/app/ip-location> and
L<http://www.maxmind.com/app/geolitecity>.
On my machine, the installed databases look like this:
$ ls -l /usr/share/GeoIP
lrwxrwxrwx 1 root root 15 Sep 6 16:54 GeoIPCity.dat -> GeoLiteCity.dat
-rw-r--r-- 1 root root 877738 Sep 6 16:25 GeoIP.dat
-rw-r--r-- 1 root root 27711885 Sep 6 16:31 GeoLiteCity.dat
Released 2009-09-06
=head1 AUTHOR
Radoslaw Zielinski E<lt>[email protected]<gt>
http://radek.cc/2009/09/06/irc-xchat-geolocation-plugin/
=head1 LICENSE
GPL v3
=cut
our $geo = Geo::IP->open_type(Geo::IP::GEOIP_CITY_EDITION_REV1) # Geo::IP::GEOIP_STANDARD
or die "can't load the GeoIP database";
Xchat::print('xchat geo starting');
Xchat::register('xchat geo', $VERSION, 'geo location for xchat', \&unload);
Xchat::hook_print('Join', \&Join,);
Xchat::hook_command('geo', sub { geo(@_); Xchat::EAT_ALL; },);
# for debugging/plugin development
#Xchat::hook_command('xev', sub { eval $_[1][0]; Xchat::EAT_ALL; },);
sub Join {
my ($user, $channel, $host) = @{ $_[0] };
my $r = record_from_ihost($host);
Xchat::printf("-\x0311->\x03\t\x02%s \x0f\x0314(\x0311%s\x0314) \x03has joined %s [\x0308%s\x0f]",
$user, $host, $channel,
$r && ref $r
? join(', ', map { defined $_ ? $_ : '' } $r->country_code, $r->city, $r->region, $r->postal_code,)
: '');
return Xchat::EAT_XCHAT;
}
# /geo some_nickname
sub geo {
my ($cmd) = @_;
defined $cmd->[1] && length $cmd->[1]
or return Xchat::print('nick?');
my $user = Xchat::user_info($cmd->[1])
or return Xchat::print("no such nick $cmd->[1]");
my $r = record_from_ihost($user->{host})
or return;
return ref $r
? Xchat::print(
' ==> ' . join "\t", $user->{nick}, $r->country_code, $r->city, $r->region,
$r->latitude, $r->longitude, $r->postal_code, $user->{host}
)
: Xchat::print($r);
}
# input: nick and hostname, as reported by xchat
# - [email protected]
# - [email protected]
# - [email protected]/freenode/cloak (useless)
# output: a string with error message or a Geo::IP record
sub record_from_ihost {
my $ihost = shift
or return;
(my $nick = $ihost) =~ s/^.=|\@.*//g;
$ihost =~ /^ [^@]* \@ (?: ((?:\d{1,3}\.){3}\.\d{1,3}) | ([a-zA-Z\d_-]+\.[.a-zA-Z\d_-]+)) (?: \s.*)? $/x
or return "no useful host for <$nick> -- $ihost";
my $r = ($1 ? $geo->record_by_ip($1) : $geo->record_by_name($2))
or return "no useful geo info for <$nick> -- $ihost " . ($1 ? "1: $1" : "2: $2");
return $r;
}
sub unload {
undef $geo;
Xchat::print('xchat geo exiting');
}
# vim: ts=4 sw=4 noet
相關問題
- 1. AJAX IRC客戶端,如何?
- 2. C++ IRC客戶端設計
- 3. 好ruby irc客戶端庫
- 4. IRC客戶端的C庫
- 5. Python的IRC客戶端
- 6. python中的IRC客戶端
- 7. Python的IRC客戶端
- 8. 情節經緯度點?
- 9. C++ winsock irc客戶端問題
- 10. 當前經緯度
- 11. C++ irc客戶端異步讀寫
- 12. java IRC客戶端文件傳輸
- 13. 創建程序Ala IRC客戶端,FICS客戶端
- 14. 通過IRC的SSH客戶端輸出
- 15. java客戶端訂閱cometd頻道
- 16. grpc活動客戶端/頻道數
- 17. 客戶端取消訂閱頻道
- 18. 近緯度經緯度
- 19. 使用Twisted Python IRC框架在IRC頻道中列出用戶
- 20. 爲客戶實體填充經度緯度字段的方法
- 21. IRC客戶端C#PING請求
- 22. 紅寶石IRC服務器/客戶端
- 23. C#TcpClient更新(針對IRC客戶端)
- 24. VB.net簡單的IRC客戶端
- 25. 從oracle數據庫獲取酒店詳情給定經度和緯度
- 26. 試圖檢索視頻經緯度時不存在列「緯度」
- 27. VB IRC客戶端 - writeStream只在IRC中顯示單個字
- 28. 加入IRC頻道只讀
- 29. sendMessage與PircBot的IRC頻道
- 30. KDTree經度/緯度
IRC通道沒有位置。你是說如果你能找到運行IRC守護進程的服務器的位置?在這種情況下,只能使用服務器的IP地址和一些地理位置庫。 – Dimme
你實際要求什麼位置?您要連接的服務器的位置?頻道中人員的位置? IRC頻道真的沒有物理「位置」。 – evan
@evan其實我正在尋找頻道中人員的位置 –