HSAdmin Backend Domains, E-Mail, Datenbanken
Purodha Blissenbach
2012-08-16 a1d97ed10fc24bb33d302e650e9615b9efbfc058
implement greylisting domain option
2 files modified
1 files added
31 ■■■■ changed files
hsarback/database/data.sql 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 16 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl 11 ●●●●● patch | view | raw | blame | history
hsarback/database/data.sql
@@ -155,6 +155,6 @@
-- table: domain_option
--
INSERT INTO domain_option (domain_option_name) 
    VALUES ('greylisting');
    VALUES ('nogreylisting');
INSERT INTO domain_option (domain_option_name)
    VALUES ('htdocsfallback');
    VALUES ('nohtdocsfallback');
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -1,5 +1,6 @@
package de.hsadmin.mods.dom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -53,7 +54,7 @@
            mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net");
        }
        for (String queueName : config.getProperty("queues.mail").split(",")) {
            mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net");
            mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, domName, pac), queueName + ".hostsharing.net");
        }
        templateVars = new HashMap<String, String>();
        templateVars.put("PAC", pacName);
@@ -162,8 +163,19 @@
                " && invoke-rc.d bind9 reload");
    }
    private Processor createMailinSetupProcessor(String domName, Pac pac) {
    private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException {
        ArrayList<Map<String, String>> domsMaps = new ArrayList<Map<String, String>>();
        Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option");
        query.setParameter("option", "nogreylisting");
        List<Domain> result = query.getResultList();
        for (Domain dom : result) {
            HashMap<String, String> hashMap = new HashMap<String, String>();
            domsMaps.add(hashMap);
        }
        return new CompoundProcessor(
            new TemplateProcessor("/de/hdsadmin/mods/dom/postgrey-whitelist-recipients.jtpl",
                                    hashMap, domsMaps.iterator(), "/etc/postgeay/whitelist_recipients", true),
            new ShellProcessor("invoke-rc.d postgrey reload"),
            new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains", 
                        domName + " anything\n" +
                        "." + domName + " anything\n"), 
hsarback/src/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl
New file
@@ -0,0 +1,11 @@
<!-- BEGIN: main -->### Do not edit this file manually
### Generated by HSAdmin Queue Server
abuse@
postmaster@
################################################################################
<!-- BEGIN: iterate -->{DOM}
<!-- END: iterate -->
<!-- END: main -->