o
    'yAf                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZ	ddl
mZ ddlT edZde_i Zdd ZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deeZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eeZG d"d# d#eeZ G d$d% d%eeZ!G d&d' d'eZ"G d(d) d)eeZ#G d*d+ d+eZ$G d,d- d-eeZ%G d.d/ d/eZ&G d0d1 d1eeZ'G d2d3 d3eZ(G d4d5 d5eZ)G d6d7 d7eeZ*G d8d9 d9eeZ+G d:d9 d9eeZ+G d;d< d<eeZ,G d=d> d>eZ-G d?d@ d@eeZ.G dAdB dBeZ/G dCdD dDeeZ0G dEdF dFeeZ1G dGdH dHeeZ2G dIdJ dJeeZ3G dKdL dLeeZ4G dMdN dNeeZ5G dOdP dPeeZ6G dQdR dReeZ7G dSdT dTeZ8G dUdV dVeeZ9G dWdX dXeeZ:G dYdZ dZeZ;G d[d\ d\eeZ<G d]d^ d^eeZ=G d_d` d`eeZ>G dadb dbeeZ?G dcdd ddeeZ@G dedf dfeeZAG dgdh dheZBG didj djeZCG dkdl dleZDdS )m    N   )_)*zddns.providersc                   C   s   t  S )z@
		Returns a dict with all automatically registered providers.
	)
_providerscopy r   r   3/usr/lib/python3.10/site-packages/ddns/providers.pyget)   s   r	   c                       s  e Zd ZdZdZdZdZi ZdZdZ	dZ
dZedd Zdd	 Z fd
dZdd Zdd Zedd Zd3ddZedd Zedd Zedd Zedd Zd4ddZdd  Zd!d" Zd#d$ Zed%d& Zed'd( Zd)d* Zd+d, Z d-d. Z!d3d/d0Z"d1d2 Z#  Z$S )5DDNSProviderNipv6ipv4   g      ?Tc                   C   s   dS )z
			Should be overwritten to check if the system the code is running
			on has all the required tools to support this provider.
		Tr   r   r   r   r   	supportedP   s   zDDNSProvider.supportedc                 K   s"   || _ | j | _| j| d S N)coreDEFAULT_SETTINGSr   settingsupdate)selfr   r   r   r   r   __init__X   s   zDDNSProvider.__init__c                    s@   t  jdi | t| j| j| jfsttd| t| j< d S )Nz#Provider is not properly configuredr   )	super__init_subclass__allhandlenamewebsite	DDNSErrorr   r   )clskwargs	__class__r   r   r   `   s   zDDNSProvider.__init_subclass__c                 C   s   d| j | jf S )Nz<DDNS Provider %s (%s)>)r   r   r   r   r   r   __repr__l   s   zDDNSProvider.__repr__c                 C   s   dd | j |j S )Nc                 S   s   | |k| |k  S r   r   )abr   r   r   <lambda>p   s    z&DDNSProvider.__cmp__.<locals>.<lambda>)hostname)r   otherr   r   r   __cmp__o   s   zDDNSProvider.__cmp__c                 C   s   | j jS r   )r   dbr"   r   r   r   r*   r   s   zDDNSProvider.dbc                 C   s   | j ||S )z2
			Get a setting from the settings dictionary.
		)r   r	   )r   keydefaultr   r   r   r	   v   s   zDDNSProvider.getc                 C   
   |  dS )z#
			Fast access to the hostname.
		r'   r	   r"   r   r   r   r'   |      
zDDNSProvider.hostnamec                 C   r-   )z#
			Fast access to the username.
		usernamer.   r"   r   r   r   r0      r/   zDDNSProvider.usernamec                 C   r-   )z#
			Fast access to the password.
		passwordr.   r"   r   r   r   r1      r/   zDDNSProvider.passwordc                 C   r-   )z 
			Fast access to the token.
		tokenr.   r"   r   r   r   r2      r/   zDDNSProvider.tokenFc              
   C   s   |rt td| j  n| js| jsd S z|   W n ttfy%     t	y: } z
| j
j| j|  d }~ww t td| j| jd  | j
j| j d S )NzUpdating %s forcedz=Dynamic DNS update for %(hostname)s (%(provider)s) successfulr'   Zprovider)loggerdebugr   r'   has_failurerequires_updater   ZDDNSNetworkErrorDDNSInternalServerErrorr   r   r*   Zlog_failureinfor   Zlog_success)r   Zforceer   r   r   __call__   s"   
zDDNSProvider.__call__c                 C   s6   | j D ]}| |r| | q| jr| | qd S r   )	protocolshave_addressupdate_protocolcan_remove_recordsremove_protocol)r   Zprotocolr   r   r   r      s   


zDDNSProvider.updatec                 C   s   t r   )NotImplementedErrorr   protor   r   r   r>      s   zDDNSProvider.update_protocolc                 C   s   | j stdt)NzDcan_remove_records is enabled, but remove_protocol() not implemented)r?   RuntimeErrorrA   rB   r   r   r   r@      s   zDDNSProvider.remove_protocolc                 C   st   |  | jrttd| j| jd  dS |  r*ttd| j| jd  dS ttd| j| jd  dS )NzVAn update for %(hostname)s (%(provider)s) is performed because of an IP address changer3   Tz[An update for %(hostname)s (%(provider)s) is performed because the holdoff time has expiredz2No update required for %(hostname)s (%(provider)s)F)ip_address_changedr<   r4   r5   r   r'   r   holdoff_time_expiredr"   r   r   r   r7      s   


zDDNSProvider.requires_updatec                 C   s   | j | j}|dksdS | jdu r%ttd| j  ttd dS | j j| j|d}|tj	| jd }tj
 }||k rs| j | j}ttd| j  |rhttd	 | D ]	}td
|  q^ttd|  dS dS )z]
			Returns True when the last update has failed and no retry
			should be performed, yet.
		ZfailureFNzFAn update has not been performed because earlier updates failed for %szThere will be no retriesTZstatusZdayszLast failure message:  %sz)Further updates will be withheld until %s)r*   Zlast_update_statusr'   holdoff_failure_daysr4   Zwarningr   last_updatedatetime	timedeltautcnowZlast_update_failure_message
splitlines)r   Zlast_statusrK   holdoff_endnowZfailure_messageliner   r   r   r6      s(   

zDDNSProvider.has_failurec                 C   sR   |D ]$}| j j| j|}| |}|du r|r| jr dS q||vr& dS qdS )z{
			Returns True if this host is already up to date
			and does not need to change the IP address on the
			name server.
		NTF)r   systemZresolver'   get_addressr?   )r   ZprotosrC   Z	addressesZcurrent_addressr   r   r   rE     s   

zDDNSProvider.ip_address_changedc                 C   st   | j sdS | jj| jdd}|sdS |tj| j d }tj }||kr.td| j  dS td| j|f  dS )zV
			Returns true if the holdoff time has expired
			and the host requires an update
		FsuccessrG   TrH   z#The holdoff time has expired for %sz$Updates for %s are held off until %s)	holdoff_daysr*   rK   r'   rL   rM   rN   r4   r5   )r   rK   rP   rQ   r   r   r   rF      s   
z!DDNSProvider.holdoff_time_expiredc                 O   s   | j jj|i |S )z6
			Proxy connection to the send request
			method.
		)r   rS   send_request)r   argsr   r   r   r   rW   >  s   zDDNSProvider.send_requestc                 C   s   | j j|p|S )z2
			Proxy method to get the current IP address.
		)r   rS   rT   )r   rC   r,   r   r   r   rT   E  s   zDDNSProvider.get_addressc                 C   s   |  |}|r	dS dS )zS
			Returns True if an IP address for the given protocol
			is known and usable.
		TFrT   )r   rC   addressr   r   r   r=   K  s   
zDDNSProvider.have_addressr   )F)%__name__
__module____qualname__r   r   r   r<   r   rV   rJ   r?   supports_token_authstaticmethodr   r   r   r#   r)   propertyr*   r	   r'   r0   r1   r2   r;   r   r>   r@   r7   r6   rE   rF   rW   rT   r=   __classcell__r   r   r    r   r
   /   sP    









(
r
   c                   @   s0   e Zd ZdZdZdZdd Zdd Zdd Zd	S )
DDNSProtocolDynDNS2z
		This is an abstract class that implements the DynDNS updater
		protocol version 2. As this is a popular way to update dynamic
		DNS records, this class is supposed make the provider classes
		shorter and simpler.
	Fc                 C      | j | |d}|S Nr'   myipr'   rT   r   rC   datar   r   r   prepare_request_datak     z(DDNSProtocolDynDNS2.prepare_request_datac                 C   s   |  |}| |S r   )rj   rW   rh   r   r   r   r>   s  s   

z#DDNSProtocolDynDNS2.update_protocolc                 C   s   t j| | j|| j| jd}|  }|ds|drd S |dkr%t|dkr+t	|dkr5t
td|dkr?t
td	|d
krEt|dkrOttd|dkrUt|dkr[tttd| )Nri   r0   r1   goodnochgbadauthabusenotfqdnNo valid FQDN was givennohostSpecified host does not exist911dnserrDNS error encounteredZbadagentZbadipServer response: %s)r
   rW   urlr0   r1   readdecode
startswithDDNSAuthenticationErrorDDNSAbuseErrorDDNSRequestErrorr   r8   DDNSBlockedErrorDDNSUpdateError)r   ri   responseoutputr   r   r   rW   x  s*   z DDNSProtocolDynDNS2.send_requestN)	r[   r\   r]   __doc__r?   r^   rj   r>   rW   r   r   r   r   rb   X  s    rb   c                   @   s   e Zd ZdZdd ZdS )DDNSResponseParserXMLz
		This class provides a parser for XML responses which
		will be sent by various providers. This class uses the python
		shipped XML minidom module to walk through the XML tree and return
		a requested element.
	c                 C   s4   t jj|}||}|sd S |d j}|j}|S )Nr   )xmlZdomZminidomZparseStringZgetElementsByTagNameZ
firstChildZ	nodeValue)r   ZdocumentZcontentZxmldocZelementZ
firstchildvaluer   r   r   get_xml_tag_value  s   

z'DDNSResponseParserXML.get_xml_tag_valueN)r[   r\   r]   r   r   r   r   r   r   r     s    r   c                   @   0   e Zd ZdZdZdZdZdZdZdZ	dd Z
d	S )
DDNSProviderAllInklzall-inkl.comzAll-inkl.comzhttp://all-inkl.com/r   zhttps://dyndns.kasserver.comFc                 C   s>   | j | j| j| jd}|  }|ds|drd S t)N)r0   r1   rm   rn   )rW   ry   r0   r1   rz   r{   r|   r   )r   r   r   r   r   r   r     s
   zDDNSProviderAllInkl.updateNr[   r\   r]   r   r   r   r<   ry   r?   r^   r   r   r   r   r   r         r   c                   @   s<   e Zd ZdZdZdZdZdZedd Z	dd	 Z
d
d ZdS )DDNSProviderBindNsupdatensupdatezBIND nsupdate utilityz%http://en.wikipedia.org/wiki/Nsupdate<   Fc                  C   s@   t jd} | dD ]}t j|d}t j|r dS qdS )NPATH:r   TF)osenvironr	   splitpathjoinexists)pathsr   
executabler   r   r   r     s   z"DDNSProviderBindNsupdate.supportedc                 C   sX   |   }g d}tj|dtjtjtjd}||\}}|jdkr#d S td|j|f )N)r   z-vz-tZ60T)shellstdinstdoutstderrr   z,nsupdate terminated with error code: %s
  %s))_DDNSProviderBindNsupdate__make_scriptlet
subprocessPopenPIPEZcommunicate
returncoder   )r   	scriptletcommandpr   r   r   r   r   r     s   
zDDNSProviderBindNsupdate.updatec                 C   s  g }|  dd }|r|d|  |  dd }|r |d|  |  dd }|r6|  d}|d||f  |  d| j}d	D ]"\}}| |}	|	sKq?|d
| j|f  |d| j|||	f  q?|d |d ttd |D ]}
|
dr~d}
td|
  qud	|
 S )Nserverz	server %szonezzone %sr+   secretz	key %s %sttl))ZAAAAr   )Ar   zupdate delete %s. %szupdate add %s. %s %s %ssendquitz
Scriptlet:zkey **** ****rI   
)r	   appendDEFAULT_TTLrT   r'   r4   r5   r   r|   r   encode)r   r   r   r   r+   r   r   ZrrtyperC   rZ   rR   r   r   r   Z__make_scriptlet  s8   




z)DDNSProviderBindNsupdate.__make_scriptletN)r[   r\   r]   r   r   r   r   r^   r_   r   r   r   r   r   r   r   r     s    
r   c                   @   r   )
DDNSProviderChangeIPzchangeip.comzChangeIP.comzhttps://changeip.comr   z#https://nic.changeip.com/nic/updateFc              
   C   s   | j | |d}z| j| j| j| j|d}W n tjjy1 } z|j	dkr,t
td d }~ww |j	dkr9d S ttdt )Nre   r0   r1   ri     zDomain not found.   rx   )r'   rT   rW   ry   r0   r1   urlliberror	HTTPErrorcoder   r   r   r   )r   rC   ri   r   r:   r   r   r   r>   6  s   

z$DDNSProviderChangeIP.update_protocolNr[   r\   r]   r   r   r   r<   ry   r?   r^   r>   r   r   r   r   r   )      r   c                   @   s(   e Zd ZdZdZdZdZdZdd ZdS )DDNSProviderDesecIOzdesec.iozhttps://www.desec.ior   zhttps://update.dedyn.ioc                 C   0   t | d}| d}|r||d< | | d S Nr   r   myipv6rb   rj   rT   rW   r   ri   r   r   r   r   r   ]  
   
zDDNSProviderDesecIO.updateN	r[   r\   r]   r   r   r   r<   ry   r   r   r   r   r   r   O      r   c                   @   r   )
DDNSProviderDDNSSzddnss.deZDDNSSzhttp://www.ddnss.der   zhttps://www.ddnss.de/upd.phpFc                 C   s   |  || jd}| jr| j|d< n| jr#| jr#|| j| jd nt| j| j|d}|	d}|dks:|dkr<d S |dkrBt
|d	krLttd
|dkrVttd|dkr\t|dkrfttd|dkrpttdt)N)iphostr+   )userpwdri   zddnss-responserm   rn   ro   rq   rr   rs   rt   ru   rv   rw   ZdisabledzAccount disabled or locked)rT   r'   r2   r0   r1   r   DDNSConfigurationErrorrW   ry   Z	getheaderr}   r   r   r8   r   r   rC   ri   r   r   r   r   r   r>   y  s8   

z!DDNSProviderDDNSS.update_protocolNr   r   r   r   r   r   j  r   r   c                   @   r   )
DDNSProviderDHSzdhs.orgzDHS Internationalzhttp://dhs.org/r   z!https://members.dhs.org/nic/hostsFc                 C   sB   | j | |dddd}| j| j| j| j|d}|jdkrd S t)NZedit24)domainr   ZhostcmdZhostcmdstagetyper   r   )r'   rT   rW   ry   r0   r1   r   r   )r   rC   ri   r   r   r   r   r>     s   	
zDDNSProviderDHS.update_protocolNr   r   r   r   r   r         r   c                   @   r   )
DDNSProviderDNSparkzdnspark.comzDNS Parkzhttp://dnspark.com/r   z2https://control.dnspark.com/api/dynamic/update.phpFc                 C   s   | j | |d}| j| j| j| j|d}|  }|ds%|dr'd S |dkr-t	|dkr3t
|dkr9t|dkrCttd	|d
krMttd|dkrWttd|dkrattdt)N)r   r   r   okZnochangeZunauthrp   ZblockedZnofqdnrr   rs   Invalid hostname specifiedZnotdynz%Hostname not marked as a dynamic hostZinvalid Invalid IP address has been sent)r'   rT   rW   ry   r0   r1   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r>     s,   z#DDNSProviderDNSpark.update_protocolNr   r   r   r   r   r     r   r   c                   @   r   )
DDNSProviderDtDNSz	dtdns.comZDtDNSzhttp://dtdns.com/r   z%https://www.dtdns.com/api/autodns.cfmFc                 C   s   |  || j| jd}| j| j|d}|  }| }d|v r#d S |dkr-tt	d|dkr7tt	d|dkr=t
|d	krGtt	d
|dkrQtt	d|dkr[tt	dt)N)r   idZpwr   znow points toz#No hostname to update was supplied.zNo hostname specifiedz'The hostname you supplied is not valid.r   z'The password you supplied is not valid.z)Administration has disabled this account.zAccount has been disabledzIllegal character in IP.r   zToo many failed requests.zToo many failed requests)rT   r'   r1   rW   ry   rz   r{   stripr   r   r}   r   r   r   r   r   r>     s,   z!DDNSProviderDtDNS.update_protocolNr   r   r   r   r   r     r   r   c                   @   0   e Zd ZdZdZdZdZdZdZdZ	dd	 Z
d
S )DDNSProviderDuckDNSzduckdns.orgzDuck DNSzhttp://www.duckdns.org/r   zhttps://www.duckdns.org/updateFTc                 C   s   | j st| j| j d}| d}|r||d< | d}|r"||d< d|vr,d|vr,t| j| j|d}|  }| }|dkrDd S |dkrJt	t	)N)Zdomainsr2   r   r   r   r   OKZKO)
r2   r   r'   rT   rW   ry   rz   r{   r   r   )r   ri   address4address6r   r   r   r   r   r   C  s*   

zDDNSProviderDuckDNS.updateNr   r   r   r   r   r   6  r   r   c                   @   s$   e Zd ZdZdZdZdZdZdZdS )DDNSProviderDyFizdy.fizhttps://www.dy.fi/r   zhttps://www.dy.fi/nic/update   N)	r[   r\   r]   r   r   r   r<   ry   rV   r   r   r   r   r   q  s    r   c                   @       e Zd ZdZdZdZdZdZdS )DDNSProviderDynDNSz
dyndns.orgZDynzhttp://dyn.com/dns/r   z%https://members.dyndns.org/nic/updateNr[   r\   r]   r   r   r   r<   ry   r   r   r   r   r         r   c                   @   r   )DDNSProviderDomainOffensivezdo.dezDomain-Offensivezhttps://www.do.de/r   zhttps://ddns.do.de/Nr   r   r   r   r   r     r   r   c                   @   r   )
DDNSProviderDynUpzdynup.dezDynUp.DEzhttp://dynup.de/r   zhttps://dynup.de/dyn.phpFc                 C   sJ   | j | j| jdd}| j| j|d}|  }| }|dr#d S t	)N1)r0   r1   r'   printr   zI:OK)
r0   r1   r'   rW   ry   rz   r{   r   r|   r   r   r   r   r   r>     s   
z!DDNSProviderDynUp.update_protocolNr   r   r   r   r   r     r   r   c                   @   (   e Zd ZdZdZdZdZdZdd ZdS )	DDNSProviderDynUzdynu.comZDynuzhttp://dynu.com/r   zhttps://api.dynu.com/nic/updatec                 C   r   r   r   r   r   r   r   r     r   zDDNSProviderDynU.updateNr   r   r   r   r   r     r   r   c                   @   ,   e Zd ZdZdZdZdZdZdZdd Z	d	S )
DDNSProviderEasyDNSzeasydns.comZEasyDNSzhttp://www.easydns.com/r   z)https://api.cp.easydns.com/dyn/tomato.phpFc                 C   s   |  |d| jd}| j| j|| j| jd}|  }| }|	dr'd S |	dr.t
|	dr9ttd|	drDttd	|	d
rOttdt)N-)rf   r'   rl   ZNOERRORZNOACCESSZ	NOSERVICEz,Dynamic DNS is not turned on for this domainzILLEGAL INPUTzInvalid data has been sentZTOOSOON+Too frequent update requests have been sent)rT   r'   rW   ry   r0   r1   rz   r{   r   r|   r}   r   r   r   r   r   r   r   r>     s"   





z#DDNSProviderEasyDNS.update_protocolN)
r[   r\   r]   r   r   r   r<   ry   r^   r>   r   r   r   r   r     s    r   c                   @   s    e Zd ZdZdZdZdZdZdS )DDNSProviderDomopolizdomopoli.dezhttp://domopoli.de/r   z%https://dyndns.domopoli.de/nic/updateNr   r   r   r   r   r         r   c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dd Z
d	S )
DDNSProviderDynsNetzdyns.netZDyNSzhttp://www.dyns.net/r   Fz&https://www.dyns.net/postscript011.phpc                 C   s   |  || j| j| jd}| j| j|d}|  }|dr"d S |dr-t	t
d|dr4t|dr?t	t
d|d	rFttt
d
| )N)r   r   r0   r1   r   Z200Z400zMalformed request has been sentZ401Z402r   Z403rx   )rT   r'   r0   r1   rW   ry   rz   r{   r|   r   r   r}   r8   r   r   r   r   r   r>   )  s$   




z#DDNSProviderDynsNet.update_protocolN)r[   r\   r]   r   r   r   r<   r?   r^   ry   r>   r   r   r   r   r     s    r   c                   @   r   )
DDNSProviderEnomComzenom.comz	eNom Inc.zhttp://www.enom.com/r   z/https://dynamic.name-services.com/interface.aspFc                 C   sz   dd|  || j| jd}| j| j|d}|  }| |ddkr%d S | |d}|dkr1t|d	kr;t	t
d
t)NZ
setdnshostr   )r   ZresponsetyperZ   Zdomainpasswordr   r   ZErrCount0ResponseNumberZ304155Z304153Domain not found)rT   r1   r'   rW   ry   rz   r{   r   r}   r   r   r   )r   rC   ri   r   r   	errorcoder   r   r   r>   W  s    	z#DDNSProviderEnomCom.update_protocolNr   r   r   r   r   r   I  r   r   c                   @   r   )DDNSProviderEntryDNSzentrydns.netZEntryDNSzhttp://entrydns.net/r   z#https://entrydns.net/records/modifyFTc              
   C   s   d|  |i}d| j| jf }z	| j||d}W n! tjjy9 } z|jdkr)t|jdkr4t	t
d d }~ww |jdkrAd S t)Nr   %s/%sr   i  r   z#An invalid IP address was submittedr   )rT   ry   r2   rW   r   r   r   r   r}   r   r   r   )r   rC   ri   ry   r   r:   r   r   r   r>     s    




z$DDNSProviderEntryDNS.update_protocolNr   r   r   r   r   r   v  s    r   c                   @   s,   e Zd ZdZdZdZdZdZdZdd Z	dS )	DDNSProviderFreeDNSAfraidOrgzfreedns.afraid.orgzhttp://freedns.afraid.org/zhttps://sync.afraid.org/u/FTc                 C   sb   d| j | jf }| |}|  }|ds|drd S |dkr%td|v r/ttdt	)Nz%s%s/ZUpdatedzNo IP change detectedz#ERROR: Unable to locate this recordzis an invalid IP addressr   )
ry   r2   rW   rz   r{   r|   r}   r   r   r   )r   rC   ry   r   r   r   r   r   r>     s   
z,DDNSProviderFreeDNSAfraidOrg.update_protocolN)
r[   r\   r]   r   r   r   ry   r?   r^   r>   r   r   r   r   r     s    r   c                   @   s,   e Zd ZdZdZdZdZdZedd Z	dS )DDNSProviderHENetzhe.netzhttps://he.netr   z!https://dyn.dns.he.net/nic/updatec                 C   r-   Nr'   r.   r"   r   r   r   r0        
zDDNSProviderHENet.usernameN)
r[   r\   r]   r   r   r   r<   ry   r`   r0   r   r   r   r   r     s    r   c                   @   r   )DDNSProviderItsdnszinwx.comZINWXzhttps://www.inwx.comr   z"https://dyndns.inwx.com/nic/updateNr   r   r   r   r   r     r   r   c                   @   r   )r   z	itsdns.dezit's DNSzhttp://www.itsdns.de/r   z https://www.itsdns.de/update.phpNr   r   r   r   r   r     r   c                   @   r   )DDNSProviderJokerz	joker.comzJoker.com Dynamic DNSzhttps://joker.com/r   z https://svc.joker.com/nic/updateNr   r   r   r   r   r     r   r   c                   @   r   )
DDNSProviderKEYSYSTEMSzkey-systems.netzdynamicdns.key-systems.netzhttps://domaindiscount24.com/r   z-https://dynamicdns.key-systems.net/update.phpFc                 C   sr   |  |}| j| j|d}| j| j|d}|  }d|v r!d S d|v r'td|v r-td|v r7t	t
dt)N)r'   r1   r   r   z
code = 200zabuse prevention triggeredzinvalid passwordzAuthorization failedr   )rT   r'   r1   rW   ry   rz   r{   r~   r}   r   r   r   )r   rC   rZ   ri   r   r   r   r   r   r>   
  s    
z&DDNSProviderKEYSYSTEMS.update_protocolNr   r   r   r   r   r         r   c                   @   r   )DDNSProviderGooglezdomains.google.comzGoogle Domainszhttps://domains.google.com/r   z%https://domains.google.com/nic/updateNr   r   r   r   r   r  (  r   r  c                   @   r   )	DDNSProviderLightningWireLabszdns.lightningwirelabs.comzLightning Wire Labs DNS Servicez"https://dns.lightningwirelabs.com/Tz(https://dns.lightningwirelabs.com/updatec                 C   sN   | j st| j| j | dd| ddd}| j| j|d}|jdkr%d S t)Nr   r   r   )r'   r2   r   r   r   r   )r2   r   r'   rT   rW   ry   r   r   )r   ri   r   r   r   r   r   @  s   


z$DDNSProviderLightningWireLabs.updateN)	r[   r\   r]   r   r   r   r^   ry   r   r   r   r   r   r  4  s    r  c                   @   r   )DDNSProviderLoopiaz	loopia.sez	Loopia ABzhttps://www.loopia.comr   z/https://dns.loopia.se/XDynDNSServer/XDynDNS.phpNr   r   r   r   r   r  W  r   r  c                   @   s$   e Zd ZdZdZdZdZdd ZdS )DDNSProviderMyOnlinePortalzmyonlineportal.netzhttps:/myonlineportal.net/z%https://myonlineportal.net/updateddnsc                 C   rc   )N)r'   r   rg   rh   r   r   r   rj   m  rk   z/DDNSProviderMyOnlinePortal.prepare_request_dataNr[   r\   r]   r   r   r   ry   rj   r   r   r   r   r  c  s    r  c                   @   r   )
DDNSProviderNamecheapznamecheap.comZ	Namecheapzhttp://namecheap.comr   z.https://dynamicdns.park-your-domain.com/updateFc           	      C   s   | j dd\}}| |}|| j||d}| j| j|d}|  }| |d|kr.d S | |d}|dkr:t	|dkrDt
td	|d
krNt
td|dv rTtt)N.r   )r   r1   r   r   r   ZIPr   Z304156Z316153r   Z316154zDomain not active)Z380098Z380099)r'   r   rT   r1   rW   ry   rz   r{   r   r}   r   r   r8   r   )	r   rC   r   r   rZ   ri   r   r   r   r   r   r   r>     s*   
z%DDNSProviderNamecheap.update_protocolNr   r   r   r   r   r  v  r   r  c                   @   r   )	DDNSProviderNOIPz	no-ip.comZNoIPzhttp://www.noip.com/r   z%https://dynupdate.noip.com/nic/updatec                 C   rc   )N)r'   rZ   rg   rh   r   r   r   rj     s   z%DDNSProviderNOIP.prepare_request_dataN	r[   r\   r]   r   r   r   r<   ry   rj   r   r   r   r   r        r  c                   @   r   )DDNSProviderNowDNSznow-dns.comzNOW-DNSzhttp://now-dns.com/r   zhttps://now-dns.com/updateNr   r   r   r   r   r    r   r  c                   @   sL   e Zd ZdZdZdZdZdZdZdZ	dZ
edd	 Zed
d Zdd ZdS )DDNSProviderNsupdateINFOznsupdate.infozhttp://nsupdate.info/r   z https://nsupdate.info/nic/updateFTNc                 C   r-   r   r.   r"   r   r   r   r0     r   z!DDNSProviderNsupdateINFO.usernamec                 C   s   | j p| dS )Nr   )r2   r	   r"   r   r   r   r1        z!DDNSProviderNsupdateINFO.passwordc                 C   s   d|  |i}|S )Nrf   rY   rh   r   r   r   rj     s   
z-DDNSProviderNsupdateINFO.prepare_request_data)r[   r\   r]   r   r   r   r<   ry   r?   r^   rJ   r`   r0   r1   rj   r   r   r   r   r    s    

r  c                   @   s$   e Zd ZdZdZdZdZdd ZdS )DDNSProviderOpenDNSzopendns.comZOpenDNSzhttp://www.opendns.comz&https://updates.opendns.com/nic/updatec                 C   rc   rd   rg   rh   r   r   r   rj     rk   z(DDNSProviderOpenDNS.prepare_request_dataNr  r   r   r   r   r    s    r  c                   @   r   )	DDNSProviderOVHzovh.comZOVHzhttp://www.ovh.com/r   zhttps://www.ovh.com/nic/updatec                 C      t | |}|ddi |S )NrS   Zdyndnsrb   rj   r   rh   r   r   r   rj     
   z$DDNSProviderOVH.prepare_request_dataNr	  r   r   r   r   r    s    r  c                   @   r   )
DDNSProviderRegfishzregfish.comzRegfish GmbHzhttp://www.regfish.com/zhttps://dyndns.regfish.de/FTc                 C   s   d| j i}| d}|r||d< | d}|r||d< d|vr%d|vr%t| jr.| j|d< n| js:| js:ttd| jrF| j| j|d}n| j| j| j| j|d}|	 
 }d|v s`d	|v rbd S 	 t)
NZfqdnr   r   r2   zNo Auth details specifiedr   r   Z100Z101)r'   rT   r   r2   r0   r1   r   rW   ry   rz   r{   r}   r   r8   r   )r   ri   r   r   r   r   r   r   r   r   0  s,   

zDDNSProviderRegfish.updateN)
r[   r\   r]   r   r   r   ry   r?   r^   r   r   r   r   r   r  #  s    r  c                   @   r   )DDNSProviderSchokokeksDNSzschokokeks.orgZ
Schokokekszhttp://www.schokokeks.org/r   z(https://dyndns.schokokeks.org/nic/updateNr   r   r   r   r   r  k  s    r  c                   @   r   )	DDNSProviderSelfhostzselfhost.dezSelfhost.dezhttp://www.selfhost.de/r   z$https://carol.selfhost.de/nic/updatec                 C   r  )Nr'   r   r  rh   r   r   r   rj   ~  r  z)DDNSProviderSelfhost.prepare_request_dataNr	  r   r   r   r   r  v  s    r  c                   @   s0   e Zd ZdZdZdZdZdZdZdZ	dd Z
dS )	DDNSProviderServercowzservercow.dezhttps://servercow.de/)r   r   z-https://www.servercow.de/dnsupdate/update.phpFc                 C   sZ   |  || j| j| jd}| j| j|d}|  }|dr"d S |dr)t	t
|)N)Zipaddrr'   r0   passr   r   zFAILED - Authentication failed)rT   r'   r0   r1   rW   ry   rz   r{   r|   r}   r   r   r   r   r   r>     s   

z%DDNSProviderServercow.update_protocolNr   r   r   r   r   r    s    r  c                   @   s8   e Zd ZdZdZdZdZdZedd Z	edd	 Z
d
S )DDNSProviderSPDNSz	spdns.orgZSPDYNzhttps://www.spdyn.de/z"https://update.spdyn.de/nic/updateTc                 C      |  dp| jS )Nr0   )r	   r'   r"   r   r   r   r0     r  zDDNSProviderSPDNS.usernamec                 C   r  )Nr1   )r	   r2   r"   r   r   r   r1     r  zDDNSProviderSPDNS.passwordN)r[   r\   r]   r   r   r   ry   r^   r`   r0   r1   r   r   r   r   r    s    	
r  c                   @   r   )	DDNSProviderStratoz
strato.comz	Strato AGzhttp:/www.strato.com/r   z$https://dyndns.strato.com/nic/updatec                 C   s    t | |}|ddd |S )NZNOCHG)ZmxZbackupmxr  rh   r   r   r   rj     s   z'DDNSProviderStrato.prepare_request_dataNr	  r   r   r   r   r        r  c                   @   r   )	DDNSProviderTwoDNSz	twodns.deZTwoDNSzhttp://www.twodns.der   zhttps://update.twodns.de/updatec                 C   s   |  || jd}|S )N)r   r'   )rT   r'   rh   r   r   r   rj     s   z'DDNSProviderTwoDNS.prepare_request_dataNr	  r   r   r   r   r    r
  r  c                   @   r   )DDNSProviderUdmediaz
udmedia.dezUdmedia GmbHzhttp://www.udmedia.der   z!https://www.udmedia.de/nic/updateNr   r   r   r   r   r    r   r  c                   @   r   )	DDNSProviderVariomediazvariomedia.deZ
Variomediazhttp://www.variomedia.de/r   z'https://dyndns.variomedia.de/nic/updatec                 C   rc   rd   rg   rh   r   r   r   rj     rk   z+DDNSProviderVariomedia.prepare_request_dataNr	  r   r   r   r   r    r  r  c                   @   r   )DDNSProviderXLhostz	xlhost.deZXLhostzhttp://xlhost.de/r   zhttps://nsupdate.xlhost.de/Nr   r   r   r   r   r    r   r  c                   @   r   )
DDNSProviderZoneeditzzoneedit.comZZoneeditzhttp://www.zoneedit.comr   Fz.https://dynamic.zoneedit.com/auth/dynamic.htmlc                 C   s   |  || jd}| j| j| j| j|d}|  }|dr"d S |dr)t	|dr4t
td|dr?t
tdt)	N)Zdnstor   r   z<SUCCESSzinvalid loginz<ERROR CODE="704"rr   z<ERROR CODE="702"r   )rT   r'   rW   ry   r0   r1   rz   r{   r|   r}   r   r   r   r   r   r   r   r>   +  s   



z$DDNSProviderZoneedit.update_protocolN)
r[   r\   r]   r   r   r   r<   r^   ry   r>   r   r   r   r   r     s    r   c                   @   r   )
DDNSProviderDNSmadeEasyzdnsmadeeasy.comzDNSmadeEasy.comzhttp://www.dnsmadeeasy.com/r   z,https://cp.dnsmadeeasy.com/servlet/updateip?Fc                 C   s   |  || j| j| jd}| j| j|d}|  }|ds%|dr'd S |dr2t	t
d|dr=t	t
d|d	rHt	t
d
|drOttt
d| )N)r   r   r0   r1   r   rU   zerror-record-ip-samezerror-auth-suspendzAccount has been suspendedzerror-auth-voidedzAccount has been revokedzerror-record-invalidrt   z
error-authrx   )rT   r'   r0   r1   rW   ry   rz   r{   r|   r   r   r}   r   r   r   r   r   r>   U  s$   



z'DDNSProviderDNSmadeEasy.update_protocolNr   r   r   r   r   r!  G  r   r!  c                   @   r   )DDNSProviderZZZZzzzzz.ioZzzzzzhttps://zzzz.ior   zhttps://zzzz.io/api/v1/updateFTc                 C   s   |  || jd}|dkrd|d< | jdd\}}d| j|f }z	| j||d}W n ty7   ttd	w |j	d
kr?d S t
)N)r   r2   r   Zaaaar   r  r   r   r   r   r   )rT   r2   r'   r   ry   rW   ZDDNSNotFoundr   r   r   r   )r   rC   ri   r   r   ry   r   r   r   r   r>     s   
z DDNSProviderZZZZ.update_protocolNr   r   r   r   r   r"  x  r   r"  )ErL   Zloggingr   r   Zurllib.requestr   Zurllib.errorZurllib.parseZxml.dom.minidomr   Zi18nr   errorsZ	getLoggerr4   Z	propagater   r	   objectr
   rb   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r!  r"  r   r   r   r   <module>   s   
  +AT&A"18;&2.-*$.#6(H$+1