Add MailIgnore option support
This commit is contained in:
parent
7599ec2684
commit
2609ce5f6d
11
dyndomain
11
dyndomain
@ -20,7 +20,7 @@ def load_conf():
|
|||||||
global zone_filename, log_filename
|
global zone_filename, log_filename
|
||||||
global wan_hostname, zone_domain, zone_subdomain
|
global wan_hostname, zone_domain, zone_subdomain
|
||||||
global hosts_list, hosts_ipv4_nat_list, hosts_alias_list
|
global hosts_list, hosts_ipv4_nat_list, hosts_alias_list
|
||||||
global mail_from, mail_to
|
global mail_from, mail_to, mail_ignore_list
|
||||||
|
|
||||||
conf = configparser.ConfigParser(allow_no_value=True)
|
conf = configparser.ConfigParser(allow_no_value=True)
|
||||||
conf.read('home.conf')
|
conf.read('home.conf')
|
||||||
@ -33,6 +33,7 @@ def load_conf():
|
|||||||
zone_subdomain = conf['Zone']['subdomain']
|
zone_subdomain = conf['Zone']['subdomain']
|
||||||
mail_from = conf['Mail']['from']
|
mail_from = conf['Mail']['from']
|
||||||
mail_to = conf['Mail']['to']
|
mail_to = conf['Mail']['to']
|
||||||
|
mail_ignore_list = [ host for host in conf['MailIgnore'] ]
|
||||||
|
|
||||||
hosts_list = [ host for host in conf['Hosts'] ]
|
hosts_list = [ host for host in conf['Hosts'] ]
|
||||||
hosts_ipv4_nat_list = [ host for host in conf['NatHosts'] ]
|
hosts_ipv4_nat_list = [ host for host in conf['NatHosts'] ]
|
||||||
@ -176,7 +177,7 @@ def ovh_update_zone(domain, update_zone_list, delete_zone_list):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def send_update_mail(mail_to, mail_from, zone_domain, update_zone_list, delete_zone_list, wan):
|
def send_update_mail(mail_to, mail_from, zone_domain, update_zone_list, delete_zone_list, mail_ignore_list, wan):
|
||||||
#print('Send email to %s' % mail_to)
|
#print('Send email to %s' % mail_to)
|
||||||
msg = EmailMessage()
|
msg = EmailMessage()
|
||||||
|
|
||||||
@ -190,6 +191,10 @@ def send_update_mail(mail_to, mail_from, zone_domain, update_zone_list, delete_z
|
|||||||
|
|
||||||
txt = txt + "\nZone %s has been updated:\n" % zone_domain
|
txt = txt + "\nZone %s has been updated:\n" % zone_domain
|
||||||
|
|
||||||
|
filtered_update_list = [ h for h in update_zone_list if not h[0] in mail_ignore_list ]
|
||||||
|
filtered_delete_list = [ h for h in delete_zone_list if not h[0] in mail_ignore_list ]
|
||||||
|
|
||||||
|
if len(filtered_update_list) or len(filtered_delete_list):
|
||||||
for host,tp,addr in update_zone_list:
|
for host,tp,addr in update_zone_list:
|
||||||
txt = txt + " %-20s %-4s %s\n" % (host,tp,addr)
|
txt = txt + " %-20s %-4s %s\n" % (host,tp,addr)
|
||||||
|
|
||||||
@ -242,6 +247,6 @@ sucess = ovh_update_zone(zone_domain, update_zone_list, delete_zone_list)
|
|||||||
|
|
||||||
if sucess:
|
if sucess:
|
||||||
new_zone_list = write_zone_list_to_file(zone_filename, zone_list)
|
new_zone_list = write_zone_list_to_file(zone_filename, zone_list)
|
||||||
send_update_mail(mail_to, mail_from, zone_domain, update_zone_list, delete_zone_list, wan)
|
send_update_mail(mail_to, mail_from, zone_domain, update_zone_list, delete_zone_list, mail_ignore_list, wan)
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,3 +28,5 @@ subdomain = home
|
|||||||
from = me@example.com
|
from = me@example.com
|
||||||
to = you@example.com
|
to = you@example.com
|
||||||
|
|
||||||
|
[MailIgnore]
|
||||||
|
mypc2.home
|
||||||
|
Loading…
Reference in New Issue
Block a user