12月 222012
 

先来看一下官方对gevent的介绍

gevent is a Python networking library that uses greenlet to provide a synchronous API on top of libevent event loop. Features include: Fast event loop based on libevent (epoll on Linux, kqueue on FreeBSD). Lightweight execution units based on greenlet. API that re-uses concepts from the Python standard library (e.g. Event, Queue). Cooperative socket and ssl modules. Ability to use standard library and 3rd party modules written for standard blocking sockets (gevent.monkey). DNS queries performed through libevent-dns. Fast WSGI server based on libevent-http.

虽然新版本的GoAgent不再要求Gevent环境,但Gevent可以提高运行效率,那为什么不装呢?Google后发现这篇文章,本文参考这篇文章后编译成功,在此谢谢此文作者。

下面开始:

首先当然是要安装好optware环境,具体可参考《RT-N66U+tomato安装optware流水账》这篇文章。

1、首先ssh到路由器上,执行以下命令更新optware包的信息。

ipkg update ipkg upgrade

2、安装编译环境

ipkg install buildroot ipkg install make

3、安装python2.7及相关包

ipkg install python27 py27-setuptools libuclibc++ ipkg install grep openssl openssl-dev

4、安装greenlet

easy_install-2.7 greenlet

5、安装cython,缺少时会抛出错误:”AssertionError: ‘cython -o gevent.core.c gevent/core.pyx’ failed with code 32512″。

easy_install-2.7 cython ln -s /opt/local/bin/cygdb /opt/bin/cygdb ln -s /opt/local/bin/cython /opt/bin/cython

注意,由于路由器处理器性能比较低,此过程可能会持续几个小时,be patient!

6、编译安装gevent

wget https://github.com/surfly/gevent/archive/master.zip unzip master.zip cd gevent vi libev/ev.c 修改libev/ev.c再进行编译: #elif defined __mips__ #define ECB_MEMORY_FENCE __asm__ __volatile__ (".set mips2; sync; .set mips0": : :"memory") 然后执行 python2.7 setup.py install

此过程同样可能会持续几个小时,be patient!

7、编译安装pyOpenSSL

最新的pyOpenSSL是0.13版,此版本需要打补丁,否则无法编译通过,换用0.12版本就没有问题了。

wget http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.12.tar.gz tar zvxf pyOpenSSL-0.12.tar.gz cd pyOpenSSL-0.12 python2.7 setup.py install

补充:如果遇到”Permission denied: ‘//.python-eggs'”错误,还需要以下步骤

unzip/opt/local/lib/python2.7/site-packages/gevent-1.0dev-py2.7-linux-mips.egg mv gevent-1.0dev-py2.7-linux-mips.egg .gevent-1.0dev-py2.7-linux-mips.egg

至此所有编译安装过程结束!

最后补上两张图:

image

image

  8 条评论 到 “RT-N66U+tomato编译安装gevent及pyOpenSSL”

  1. 感谢分享!已经按照您的教程使用python2.7和1.0的gevent运行最新的goagent啦!谢谢!升级之后有遇到/2的地址错误,把appid重新更新一下就行了,goagent+ipv6基本上很‘自由’啦~
    我有在DHCP的dnsmasq里加上addn-hosts=/jffs/ipv6hosts和一些去广告的host,这样配合ipv6像推特,FB什么的可以直接访问了,其他一些没有ipv6的网站再用goagent,完美啦!再次感谢!

  2. 有个问题请教博主
    我想把所有80端口的访问劫持到8087
    iptables -t nat -I PREROUTING -i br0 -p tcp –dport 80 -j REDIRECT –to-ports 8087
    在Toastman里这里设置好像无效,无论是放在Firewall还是Wan up

  3. 执行easy_install-2.7 greenlet时,报错,请帮忙看看:
    /tmp/home/root# easy_install-2.7 greenlet
    Searching for greenlet
    Reading http://pypi.python.org/simple/greenlet/
    Best match: greenlet 0.4.1
    Downloading https://pypi.python.org/packages/source/g/greenlet/greenlet-0.4.1.zip#md5=c2deda75bdda59c38cae12a77cc53adc
    Processing greenlet-0.4.1.zip
    Running greenlet-0.4.1/setup.py -q bdist_egg –dist-dir /opt/tmp/easy_install-qmud_F/greenlet-0.4.1/egg-dist-tmp-fZeYXp
    unable to execute /opt/bin/gcc: No such file or directory
    unable to execute /opt/bin/gcc: No such file or directory
    error: Setup script exited with error: command ‘/opt/bin/gcc’ failed with exit status 1

  4. […] shadowsocks-libev-masterlibev 下的 ev.c :(其实跟RT-N66U+tomato编译安装gevent及pyOpenSSL […]

  5. […] ASUS RT-N66U,为TOMATO挂载的GoAgent配置Gevent环境。完美实现 教程2 RT-N66U+tomato编译安装gevent及pyOpenSSL 教程3 在路由器上安装代理软件goagent,实现自动翻出墙 教程4 Tomato […]

 评论

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*(必需)

*(必需)

Time limit is exhausted. Please reload CAPTCHA.

10,083 人阅读