Files
programming/python/DomainUpdater/__pycache__/DomainUpdater.cpython-36.pyc

41 lines
3.7 KiB
Plaintext
Raw Normal View History

2026-03-12 21:51:59 +01:00
3
_&Y`}<00>@s<>ddlZddlZddlmZddlmZddlZddlZddlZddl Z dd<05>Z
Gdd<07>d<07>Z e dkr<>ej jej je<10><01>Zej je<10>Ze
ed <00>Zejd
<EFBFBD>e e<11>Zej<17>eej<19>dkr<>ej<1A>ejd <0B>dS) <0C>N)<01> EmailMessage)<01>MIMETextcCsNtjt<02>}|jtj<04>tj|<00>}|jtj<04>tjd<01>}|j|<03>|j|<02>|S)Nz4%(asctime)s - %(name)s - %(levelname)s - %(message)s) <09>loggingZ getLogger<65>__name__ZsetLevelZINFOZ FileHandlerZ FormatterZ setFormatterZ
addHandler)Zlogfile<6C>loggerZhandlerZ formatter<65>r<00>*/root/shell/DomainUpdater/DomainUpdater.py<70> start_loggings
 
 


r c@s,eZdZdd<02>Zdd<04>Zdd<06>Zdd<08>Zd S)
<EFBFBD> DomainUpdaterc Cs<>||_t|jddd<03><02>}tj|<02>|_WdQRXtj|jd<00>}|j<02>d|_tj d|j<00>g|_
|jd|jdf|_ |jd |_ d
}tj|j ||j d <0B>}|j<02>d }|jd j d<0E>|_tj ddj|j<0E><00>g|_x<>|D]<5D>}|d}|d}dt|d<00>d}tj|j ||j d <0B>}|j<02>d } xp| D]h}
|
ddk<02>r2|
d} |
d} |
d} d| |f}||| | f}||jk<06>r2|jj|<0E>|j
j|<0F><00>q2Wq<>Wtj ddj|j<10><00>dS)N<>/zDomainUpdater.conf<6E>rZget_current_ip_api_urlZipzCurrent public IP is Z dnsmanager_idZdnsmanager_keyZdnsmanager_api_url_basez /user/domains)<01>authZresultsZsubdomain_list<73>,zSubdomains list: <20>domain<69>idz /user/domain/z/records<64>type<70>A<>name<6D>contentz%s.%szUpdating subdomain(s): )<13>rootdir<69>open<65>json<6F>load<61>config<69>requests<74>get<65>
current_ipr<00>info<66>subdomains_listr <00>url_base<73>splitZ fqdn_list<73>joinZfqdn_to_update<74>str<74>append)<10>selfr<00>fr <00>url_endZ domain_dictrZ domain_name<6D> domain_idZ records_dictZ record_dict<63> subdomain_idZsubdomain_name<6D> subdomain_ip<69>fqdn<64>recordrrr<00>__init__#sB  
 
    zDomainUpdater.__init__cCspt<00>}d|d<d|d<d|d<d|jdj|j<03>f}|j|<02>tjd <09>}|j|<01>|j<08>t j
d
|d<00>dS) NzYour public IP changedZSubjectzdomain-updater@databasepro.frZFromzvplesnila@gmail.comZToz<6F>
Hello,
You have a new public IP: %s
Following subdomains has been updated: %s
--------------
Domain Updater
z, Z localhostzEmail sent to ) rrr!<00>updated_subdomain_listZ set_content<6E>smtplibZSMTPZ send_message<67>quitrr)r$<00>msgZbody<64>srrr<00>send_email_new_ipTs


zDomainUpdater.send_email_new_ipcCsxg|_xl|jD]b}|\}}}}||jkr@tj|d|d<00>qtjd|d|j<00>|j||<04>|jj|<02>qWdS)Nz already set to z, nothing to doz Updating z with the new IP value )r-rrrr<00>update_subdomainr#)r$r+r*r'r(r)rrr<00>check_subdomainsgs  
 zDomainUpdater.check_subdomainscCsPdt|<01>dt|<02>}tj||jd<03><02>}ddi}tj|j||j||d<06>}dS)Nz /user/domain/z/record/)rrz Content-Typezapplication/json)r <00>data<74>headers)r"r<00>dumpsrrZputrr )r$r'r(r&r5r6r rrrr3ss
zDomainUpdater.update_subdomainN)r<00>
__module__<EFBFBD> __qualname__r,r2r4r3rrrrr
"s1 r
<00>__main__z/DomainUpdater.logZ__BEGIN_BATCH__Z __END_BATCH__)<1B>osr.Z email.messagerZemail.mime.textrZsocketrrrr r
r<00>path<74>dirname<6D>abspath<74>__file__Z script_path<74>basenameZ script_namerrZ domainupdaterr4<00>lenr-r2rrrr<00><module>s&  X