- eMule Fans 电骡爱好者 - https://www.emulefans.com -

MLDonkey屏蔽Leecher的方法

原文地址:http://www.ied2k.com/forum/index.php?showtopic=18838 [1]
作者:moh

名字起的有点大 🙂
最近搞好了TrafficShapping,这样MLDonkey就可以全放开上传了,但是吸血骡,尤其是迅雷来吸的太多了。利用周末Google了一下,可以做到屏蔽部分吸血骡。但是有如下几个缺点:

  1. 没有DLP这么全面,主要是屏蔽国内的迅雷,快车之类的。
  2. 偶有漏网的。
  3. 有误伤。
  4. 可能会占用一部分资源,尤其是刚启动fail2ban时。

所以完美主义者,骡道主义者就不要用了 🙂 期待你们开发出好的MLDonkey可用的DLP 😛

下面是步骤,我用的是Gentoo系统,可能会与别的版本不太一样,但应该是大同小异。

  1. 首先,要修改MLDonkey的一个配置,用web控制,还是用Telnet敲命令,还是直接修改~/.mldonkey/download.ini都随便,命令是
    set verbosity "mct"

    完成后,去~/.mldonkey/mlnet.log看看,会发现有很多过去没有见过的log文件,mct的意思就是显示Client的Tag。当然还有很多的不同的选项可以改,具体可以看~/.mldonkey/download.ini里的解释。

  2. 安装fail2ban,Gentoo就简单了,直接emerge就可以,其它的版本应该也不会太难。
  3. 修改/etc/fail2ban/jail.conf,在末尾加上。
    [dlp-iptables]
    
    enabled = true
    filter = dlp
    action = iptables-allports[name=dlp, protocol=tcp]
    logpath = /home/xxxx/.mldonkey/mlnet.log
    maxretry = 1

    具体的logpath要换成自己的 🙂

  4. 新建/etc/fail2ban/filter.d/dlp.conf,加入如下的内容
    # Fail2Ban configuration file
    #
    # Author: Sparkplug
    # http://sparkplug-moh.blogspot.com
    #
    
    [INCLUDES]
    
    # Read common prefixes. If any customizations available -- read them from
    # common.local
    before = common.conf
    
    
    [Definition]
    
    _daemon = dlp
    
    # Option: failregex
    # Notes.: regex to match the password failures messages in the logfile. The
    # host must be matched by a group named "host". The tag "" can
    # be used for standard IP/hostname matching and is only an alias for
    # (?:::f{4,6}(IMG:style_emoticons/default/smile.gif) ?(?P[\w\-.^_]+)
    # Values: TEXT
    #
    failregex = ip: :.*(xthame|Flashget|VeryCD|QQDownload|FreeCD|dianlei|TUOTU|PPMule|eMuleBT|kaggo|Chinfo|21cn)
    ip: :.*\(version\)=\(60\) \(mod_version
    ip: :.*mod_version\)=\(.*(ery|easy)
    ip: :(80|65535)
    :.*(xthame|Flashget|VeryCD|QQDownload|FreeCD|dianlei|TUOTU|PPMule|eMuleBT|kaggo|Chinfo|21cn)
    :.*0.48a
    :.*mod_version.*(ery|easy)
    :(80|65535)
    # Option: ignoreregex
    # Notes.: regex to ignore. If this regex matches, the line is ignored.
    # Values: TEXT
    #
    ignoreregex =

    其中failregex里的红色部分(转载注:请参考原帖 [1])是屏蔽了VeryCD的MOD,包括那个什么EasyMule,原因是它们违反了GPL协议,除了DLP不开源外,具体可以去Google:“easymule amule”(转载注:请参考EasyMule2涉嫌抄袭aMule代码 [2]);第一行里VeryCD的TAG,这样名字里VeryCD的Client也一样会屏蔽,如果不想屏蔽VC的MOD或者名字里加了VeryCD的 Client的话就不要加载这些了,直接去掉就可以。

    这些只是屏掉了国内一些Client,有人能把DLP里的Username_Hard和Modstring_Hard整理出来做个完全的就更好了 🙂
    另外,所有0.48a的emule版本都屏掉了,有误杀,阿弥陀佛,罪过罪过 🙂

  5. 运行fail2ban,
    /etc/init.d/fail2ban start

    如果没有问题,

    rc-update add fail2ban default

    另外,也可以在MLDonkey里输入

    set verbosity "up"

    再根据相应的调整/etc/filter.d/dlp.conf就可以吸这些吸血骡的血了,是不是太邪恶了 :mrgreen: