用socks代理 fetchmail from gmail

| | Comments (0) | TrackBacks (0)

在学校里,不能直接连接国外网站,当然我们有办法找到代理来浏览网页 :P . 不过对于fetchmail + mutt的邮件解决方案,fetchmail怎么利用代理收gmail的信呢?

首先你得有能用的socks代理。

其次,你需要有runsocks或者tsocks这一类socks客户端。这种客户端当你配置好配置文件以后,可以用runsocks command的方式运行你的程序“command”,它就会用socks代理出去了.关于这么配置,我就不赘述了,请参照文档。

这时,你可能已经想到,那我直接用runsocks运行fetchmail不就行了么? 没错, 当然可行,不过前提是你的fetchmail是支持SSL的。而且有些小问题:

1。有可能你的fetchmail不止收取一个gmail的信件,还有其他服务器的,比如(eyou.com? :P),他就是国内的了,用了代理反而慢了。(当然这个问题也能解决,比如你自己在本地建一个socks代理,配置成访问指定目标地址时使用另一个站外socks服务)

2。还有可能,你的整个Linux系统就只运行了一个fetchmail daemon他是全局的,读取所有用户的配置文件,你没法让它以runsocks运行,或者你不想修改配置好的/etc/init.d/fetchmail启动文件。 那就可以用我下面说的方法:

答案是:stunnel . stunnel可以建立一个SSL的tunnel. 看下面这个命令

runsocks stunnel -d 10000 -c -r pop.gmail.com:995

-d 10000 表示在本地监听10000这个TCP端口。-c 表示使用client模式。 -r pop.gmail.com:995 表示连接远程的服务器以及端口。

运行完这条命令之后,你在试一下telnet localhost 10000 ?然后再输入 user yourid, pass yourpass , list, exit等POP3会话命令试试,可以了吧? 没错,我们在本地10000端口和远程的pop.gmail.com:995建立了一个tunnel,而且是脱掉了SSL的,就是明文,(没关系,这是本地的连接,不怕sniffer的).

利用这种方法,你只需要在你的fetchmail配置文件中配置主机为localhost,端口为10000就可以了。


BTW:值得提到的是,fetmail是支持plugin的,在命令行里写 --plugin "command %h %p" 或者在配置文件里写 poll xx.xx.xxx.xx plugin "command %h %p", command就是你提供的程序,%h是host,%p是port,fetchmail从command的stdout读东西,把要写数据写给command的stdin,
所以我们又有了一个方案,前提是fetchmail支持ssl, plugin里面写

plugin "runsocks nc %h %p"

其中nc就是有着TCP/IP瑞士军刀之称的 netcat

0 TrackBacks

Listed below are links to blogs that reference this entry: 用socks代理 fetchmail from gmail.

TrackBack URL for this entry: http://www.ieasy.org/cgi-bin/MTOS/mt-tb.cgi/113

Leave a comment

About this Entry

This page contains a single entry by 科学家 published on April 7, 2005 2:50 PM.

links for 2005-04-06 was the previous entry in this blog.

jabber server ready is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.