
    Y0j                        S SK r S SKrS SKJr  S SKJr  S SKJr  S SKJ	r	J
r
JrJrJrJr  \ R                  R!                  \5      r\ R                  R%                  \5      r\ R(                  " \5        \ " S S5      5       rS\4S	 jr\S
:X  Ga=  \" 5       rSr\R4                   GH  r\" \R9                  5       \R;                  5       S9r\\R>                  :X  a  \R@                  (       d  MJ  \" S\R>                   S\ S35        \(       d(  \" \RB                  \RD                  \RF                  5      r\(       d  \" SSS9  \$" 5         \" S\RB                   35        \" \S5      r%Sr&\" \%5        \%S    H  r'\'S   \RP                  :X  d  M  \'S    H  r)\)S   \RU                  5       :X  d  M  \)S   \RV                  :X  d  M1  \)S   r&\" S\& 35        \)S   \R>                  :X  d  MV  \R@                  (       a  Mi  \" S\& S\R9                  5        S\R>                   S35        \$" 5         M       O   \" S\RP                   S 35        \$" 5         \" \\\&5        \&(       d'  \" S!\RV                   S"\R9                  5        S#35        \," \	S$5       r-\-R]                  \/" \R>                  5      5        SSS5        GM     \$" 5         gg! , (       d  f       GM9  = f)%    N)	dataclass)login)
log_output)IP_FILE	DnsRecordget_external_ip
get_dns_ipget_dns_entriessubmit_dns_entry_updatec                   l    \ rS rSr% \\S'   \\S'   \\S'   \\   \S'   \\S'   \\S'   \\S'   \\S	'   S
r	g)Config   usernamepasswordtotp_secretdns_records
cookiefileipv4_apiipv6_apiforce N)
__name__
__module____qualname____firstlineno__str__annotations__listr   bool__static_attributes__r       ;/mnt/mint/home/seanl/public/Repos/hover-dyn-dns/__main__.pyr   r      s0    MMi OMMKr!   r   returnc                     [         R                  " SS9n U R                  SSS9  U R                  SSS9  U R                  SS	S9  U R                  S
SSS9  U R                  SSS9  U R                  SSSS9  U R                  SSSSS9  U R                  SSSSS9  U R                  SSSSS9  U R                  SSSSS9  U R                  SS S!S"9  U R                  5       n/ nUR                  c  S#Ul        UR                  R                  S$5       HT  nUR                  R                  S$5       H2  nUR                  [        UR                  UUR                  US%95        M4     MV     [        UR                  UR                  UR                  UUR                  UR                   UR"                  UR$                  S&9nUR&                   H  n[(        R+                  UR                  S'S(5      Ul	        [(        R+                  UR                  S)S(5      Ul	        UR,                  (       a  Mb  UR/                  5       (       a  UR0                  OUR2                  n[5        U5      Ul        M     U$ )*NzHover DNS Update Script)descriptionz
--usernamezhover.com user ID)helpz
--passwordzhover.com user passwordz--totp_secretz)TOTP shared secret from you hover accountz--addr?zFIP address for the new DNS record, will use current address by default)nargsr&   z--domainz>Your "naked" domain name (i.e example.com) registered at Hoverz--hostz~Comma-seperated list of hostnames (i.e @,www,mail) for the updated record(s). A hostname of @ refers to the naked domain name.z--typeAzDNS record type (A, AAAA, CNAME, etc.) for the updated record(s). Usage of 'A,AAAA' will update all IPv4 and IPv6 records for the provided host(s).)r(   defaultr&   z--cookiefilezcookies.jsonzFile path of the cookie storez	--ip4_urlzhttps://api.ipify.orgziURL for obtaining the public IP4 address automatically. If not supplied, your URL must return text/plain.z	--ip6_urlzhttps://api6.ipify.orgziURL for obtaining the public IP6 address automatically. If not supplied, your URL must return text/plain.z--force
store_truez4Forces DNS updates, even if they are already current)actionr&   @,)domainhostvaluerecord_type)r   r   r   r   r   r   r   r   zhttp:// zhttps://)argparseArgumentParseradd_argument
parse_argsr0   splittypeappendr   r/   addrr   r   r   r   r   ip4_urlip6_urlr   r   r   replacer1   is_ip6r   r   r   )parserargsrecordsr0   r2   configrecordapis           r"   load_configrF      sU   $$1JKF
+>?
+DE
.YZ
2z{

)kl
  3s  t
S  @U  V
c>Pop
38O  WB  C
38P  XC  D
	,=stDGyy			$99??3/KNN![[ II"-	 0 % ====&&__<<<<

	F $$FMM9bAFMM:rB|||%+]]__&//&//C*3/FL % Mr!   __main__)use_ipv6zCurrent IP of z does not match DNS record of z, performing update...zLogin did not succeed, exiting.T)is_errorzUsing username: domainsdomain_nameentriesnamer9   idzDNS record ID is contentzDNS entry with ID z (z() already matches current IP address of zS. DNS up to date, waiting until the record replicates to local nameserver. exiting.zDomain z+ does not seem to be on your Hover account.zCould not find a z DNS record for z. Creating a new one...zw+)0osr4   dataclassesr   authenticationr   logging_outr   dnsr   r   r   r	   r
   r   pathabspath__file__dirnamednamechdirr   rF   r   rC   cookiesr   rD   get_fqdnr?   dns_ipr1   r   r   r   r   exitexisting_dns_entriesdns_idregisted_domainr/   entryget_hostr2   openfilewriter   r   r!   r"   <module>rg      s   	  !   " i i
''//(
#
  
  0V 0d z]FG$$FOO-HV\\!&,,^FLL>1OPVxWmnoFOOV__f>P>PQG84HF%foo%678.w='(3I>O}->,Y7EV}(99eFmvOaOa>a!&t"%6vh#?@ +v||;FLLL&);F82fooFWEX  YA  BH  BN  BN  AO  Ob  (c  d F 8   ? /Z[\F8*6+=+=*>>NvO`Naaxyz'4 DJJs6<<() ! E %J 	FU N ! s   "K
K	