Tag Archive for 'byrbt'

php识别Google的爬虫

给byrbt稍微加点SEO,遇到一个问题是让google可以访问一些原本必须登录之后才能访问的页面。

google了一个晚上无果……这里有一个帖子从来没有人回答过……其他地方找到的方法就是用UA来识别google bot

参考了谷歌中文网站管理员博客上的一篇日志这个帖子写了一个函数判断是否为googlebot

懒得排版了……

function isgooglebot(){
$ua=strtolower($_SERVER['HTTP_USER_AGENT']);
$ip=$_SERVER['REMOTE_ADDR'];
if(strpos($ua,"googlebot")!==false){
$hostname=gethostbyaddr($ip);
if(strpos($hostname,"googlebot.com") !==false ){
$ip_reversed=gethostbyname($hostname);
if($ip==$ip_reversed){
return true;
}else return false;
}else return false;
}else return false;
}

BTW:我依稀记得google提供了一个网页,提交用户名密码以及对应的字段名,google可以自己post用户名密码来完成登录再抓取需要登录才能看到的网页……谁知道这个页面在哪……

关于transmission的ipv6支持问题

transmission是一个在linux下比较流行的bt客户端,gtk界面,支持daemon,并有方便的web前端第三方的客户端

transmission在大约1.50版的时候开始声明支持ipv6了,但是实际使用过程中却发现连接到byrbt的tracker时,服务端见到的ip是v4的ip,即使在/etc/hosts文件中指定了tracker的v6地址也一样。

google到了transmission的trac上有讨论这个问题(12)。似乎是transmission在对byrbt这样的v4/v6双栈的tracker时只解析v4地址,不解析v6地址。

trac里原文:

Brief explanation for posterity and those out of the loop: In libTransmission (pre-1.60?, that’s the plan anyway) “torrent” and “tracker” are used interchangeably. With the addition of IPv6 support, the two concepts need to be separated. This is a fairly major refactoring job. For 1.5x and in trunk currently, IPv6 DNS resolution in libcurl (the library we use for tracker communication) is disabled to prevent breakage of trackers with AAAA and A records on the same hostname (notably, TPB). For those of you coming here from #1937, the curl option to disable IPv6 “DNS resolution” apparently also causes curl to bail if given an explicit IPv6 tracker address (such as http://[::1]/announce), so that bug is the same as this one.

解决的办法很简单,修改源码里libtransmission/web.c,找到curl_easy_setopt( easy, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );一行,将CURL_IPRESOLVE_V4修改为CURL_IPRESOLVE_V6,然后正常编译安装即可。如果同时需要使用v4的tracker,可以把这部分修改成CURL_IPRESOLVE_WHATEVER。

实际使用效果甚好。原本都是做种很久后才有零星的ipv6的peer连接,现在连上tracker后不久就能得到ipv6的peer了

BTW,不知道为什么,transmissionbt.com也被墙了……万恶的GFW……

byrbt上线

快一个月时间,幸亏有现成的tracker,不然开发时间还要往上涨……

http://bt.byr.edu.cn

thubt的迁移也马上要开始了,继续开发功能……