Add MailIgnore option support
This commit is contained in:
parent
7599ec2684
commit
2609ce5f6d
31
dyndomain
31
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,21 +191,25 @@ 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
|
||||||
|
|
||||||
for host,tp,addr in update_zone_list:
|
filtered_update_list = [ h for h in update_zone_list if not h[0] in mail_ignore_list ]
|
||||||
txt = txt + " %-20s %-4s %s\n" % (host,tp,addr)
|
filtered_delete_list = [ h for h in delete_zone_list if not h[0] in mail_ignore_list ]
|
||||||
|
|
||||||
txt = txt + "\nRemoved entries:\n"
|
if len(filtered_update_list) or len(filtered_delete_list):
|
||||||
|
for host,tp,addr in update_zone_list:
|
||||||
|
txt = txt + " %-20s %-4s %s\n" % (host,tp,addr)
|
||||||
|
|
||||||
for host,tp,addr in delete_zone_list:
|
txt = txt + "\nRemoved entries:\n"
|
||||||
txt = txt + " %-20s %-4s %s\n" % (host,tp,addr)
|
|
||||||
|
|
||||||
txt = txt + '\n'
|
for host,tp,addr in delete_zone_list:
|
||||||
|
txt = txt + " %-20s %-4s %s\n" % (host,tp,addr)
|
||||||
|
|
||||||
msg.set_content(txt)
|
txt = txt + '\n'
|
||||||
|
|
||||||
s = smtplib.SMTP('localhost')
|
msg.set_content(txt)
|
||||||
s.send_message(msg)
|
|
||||||
s.quit()
|
s = smtplib.SMTP('localhost')
|
||||||
|
s.send_message(msg)
|
||||||
|
s.quit()
|
||||||
|
|
||||||
|
|
||||||
load_conf()
|
load_conf()
|
||||||
@ -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