Source

iredmail / iRedMail / samples / cluebringer / extra.sql

Diff from to

iRedMail/samples/cluebringer/extra.sql

 --   - Type=email: a valid full email address
 --   - Type=domain: a valid domain name
 --
--- We can use multiple policies for different types, but it bringer more SQL
+-- We can use multiple policies for different types, but it brings more SQL
 -- queries for each policy request, this is not a good idea for performance
 -- since Cluebringer is used to process every in/out SMTP session.
 ALTER TABLE policy_group_members ADD COLUMN Type VARCHAR(10) NOT NULL DEFAULT '';
 -- ------------------------------------
 INSERT INTO policies (Name, Priority, Disabled, Description)
     VALUES ('no_greylisting', 20, 0, 'Disable grelisting for certain domain and users');
-INSERT INTO policy_groups (Name, Disabled) VALUES ('no_greylisting', 0);
+
+-- No greylisting for certain local domains/users
+INSERT INTO policy_groups (Name, Disabled) VALUES ('no_greylisting_to_internal', 0);
 INSERT INTO policy_members (PolicyID, Source, Destination, Disabled)
-    SELECT id, '!%internal_ips,!%internal_domains', '%no_greylisting', 0
+    SELECT id, '!%internal_ips,!%internal_domains', '%no_greylisting_to_internal', 0
     FROM policies WHERE name='no_greylisting' LIMIT 1;
+
+-- No greylisting for certain external domains/users
+INSERT INTO policy_groups (Name, Disabled) VALUES ('no_greylisting_from_external', 0);
+INSERT INTO policy_members (PolicyID, Source, Destination, Disabled)
+    SELECT id, '%no_greylisting_from_external', '%internal_domains', 0
+    FROM policies WHERE name='no_greylisting' LIMIT 1;
+
 -- Disable greylisting for %no_greylisting
 INSERT INTO greylisting (PolicyID, Name, UseGreylisting, Track, UseAutoWhitelist, AutoWhitelistCount, AutoWhitelistPercentage, UseAutoBlacklist, AutoBlacklistCount, AutoBlacklistPercentage, Disabled)
     SELECT id, 'no_greylisting', 0, 'SenderIP:/32', 0, 0, 0, 0, 0, 0, 0
     FROM policies WHERE name='no_greylisting' LIMIT 1;
 
--- Sample: Disable greylisting for certain domain/users:
+-- Sample: Disable greylisting for certain local domain/users:
 -- INSERT INTO policy_group_members (PolicyGroupID, Member, Disabled)
---    SELECT id, '@domain.com', 0 FROM policy_groups WHERE name='no_greylisting' LIMIT 1;
+--    SELECT id, '@domain.com', 0 FROM policy_groups WHERE name='no_greylisting_to_internal' LIMIT 1;
 
 -- ---------------
 -- INDEXES
 CREATE INDEX policy_group_members_member ON policy_group_members (member);
 -- Unique index to avoid duplicate records
 CREATE UNIQUE INDEX policy_group_members_policygroupid_member ON policy_group_members (policygroupid, member);
-
--- CREATE INDEX policy_members_source ON policy_members (source);
--- CREATE INDEX policy_members_destination ON policy_members (destination);
-
--- -------------------------------
--- TODO Per-domain white/blacklist
--- -------------------------------
--- Add policy: domain_blacklist_domain.com (prefix 'domain_blacklist_')
--- Add policy_group: domain_domain.com (prefix 'domain_' + domain name)
--- Add policy_members: !internal_ips,!internal_domains -> domain_domain.com
--- Add policy_members: !internal_ips,!internal_domains -> domain_[alias_domain]
--- Add policy_group_members: domain_domain.com -> primary domain and all alias domains
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.