~semi-hallikas/sspamm/3.0-devel

« back to all changes in this revision

Viewing changes to sspamm.py

  • Committer: Sami-Pekka Hallikas
  • Date: 2010-11-26 14:09:40 UTC
  • Revision ID: semi@hallikas.com-20101126140940-c0n1rwkzw7ku220z
Added possibility to use different action for different RBL servers, like:
        (?#flag)cbl.abuseat.org

.. Will flag CBL Abuseat matches, even if default action would be block.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1352
1352
                        a = split(mail["received"][rec]["ip"], '.')
1353
1353
                        a.reverse()
1354
1354
                        for rbl in conf["settings"]["ipservers"]:
1355
 
                                debug("\t\tFrom: %s" % (rbl), LOG_DEBUG, id=mail["id"])
 
1355
                                if rbl[0:3] == "(?#":
 
1356
                                        action = rbl[3:rbl.find(")")]
 
1357
                                        rbl = rbl[rbl.find(")")+1:]
 
1358
                                else:
 
1359
                                        action = conf["actions"]["rbl"]
 
1360
                                debug("\t\tFrom: %s (if match %s)" % (rbl, action), LOG_DEBUG, id=mail["id"])
1356
1361
                                b=join(a, '.')+'.'+rbl
1357
1362
                                try:
1358
1363
                                        globaltmp[mail["id"]] += 1
1365
1370
                                                                res = (True, q.answers[0]['data'][0])
1366
1371
                                                except:
1367
1372
                                                        pass
1368
 
                                                if not res: res = (True, "BLACKLISTED")
 
1373
                                                if not res: res = (True, "BLACKLISTED from %s" % (rbl))
1369
1374
                                                break
1370
1375
                                except:
1371
1376
## Reason for exception is usually timeout, ignore
1389
1394
 
1390
1395
        if res and res[0] == True:
1391
1396
                tmp = res[1]
1392
 
                res = (conf["actions"]["rbl"], tmp)
 
1397
                res = (action, tmp)
1393
1398
        if conf["main"]["timeme"] is True: mail["timer"]["rbl"] = str("%.4f") % timeme(timer, id=mail["id"])
1394
1399
        return (res, mail)
1395
1400