3 !g$@sddlmZedskr&ddZeZ[n"edtkr@ddZeZ[nddlZ[yeZWnek rfYnXy ddlZ Wne k rddl Z YnXdud d Z d d Z ddZ ddZy eZd ZWn(e jk rGdddZdZYnXddlZy ddlZWne k rddl ZYnXdekr.eZddZddZejZejZejZejZejZejZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$ej%Z%ej&Z&ej'Z'ej(Z(ej)Z)ej*Z*ej+Z+ej,Z,ej-Z-ej.Z.ej/Z/ej0Z0ej1Z1ej2Z2ej3Z3ej4Z4ej5Z5ej6Z6ej7Z7ej8Z8ej9Z9ej:Z:ej;Z;ejZ>ej?Z?ej@Z@ejAZAejBZBejCZCejDZDejEZEejFZFejGZGejHZHejIZIejJZJejKZKejLZLejMZMejNZNejOZOejPZPejQZQejRZRejSZSejTZTejUZUejVZVejWZWejXZXejYZYejZZZej[Z[ej\Z\ej]Z]ddZ^ej^Z^ej_Z_ej`Z`ejaZaejbZbejcZcejdZdejeZeejfZfejgZgejhZhejiZiGdddZjejkZkejlZlejmZmejnZnejoZoejpZpGdddeZqejrZrereqejsZsejtZtejuZuejvZvejwZwejxZxejyZyejzZzej{Z{ej|Z|ej}Z}dd Z~ej~Z~d!d"ZejZd#d$ZejZd%d&ZejZd'd(ZejZd)d*ZejZd+d,ZejZd-d.ZejZd/d0ZejZd1d2ZejZd3d4ZejZd5d6ZejZd7d8ZejZd9d:ZejZd;d<ZejZd=d>ZejZd?d@ZejZdAdBZejZdCdDZejZdEdFZejZdGdHZejZdIdJZejZdKdLZejZdMdNZejZdOdPZejZdQdRZejZdSdTZejZdUdVZejZdWdXZejZdYdZZejZd[d\ZejZGd]d^d^eZejZeeGd_d`d`eZejZeeGdadbdbeZejZeeejZejZejZejZejZejZGdcddddeZejZeeGdedfdfeZejZeeGdgdhdheZejZeedidjZejZdkdlZejZejZdmdnZdodpZdqdrZdS)v) version_infoc CsTddl}tjdd}dj|dfjd}y |j|Stk rN|jdSXdS)Nr._unbound) importlib__name__ rpartitionjoinlstrip import_module ImportError)rZpkgZmnamer/usr/lib64/python3.6/unbound.pyswig_import_helper s rcCs~ddlm}ddl}d}y|jd|tg\}}}Wntk rPddl}|SXz|jd|||}Wd|dk rx|jX|S)Nr)dirnamer) Zos.pathrimp find_module__file__r r load_moduleclose)rrfppathname descriptionrZ_modrrrrs  NcCs|dkr|jj|S|dkr8t|jdkr8||j|<dS|jj|d}|rT|||S|sxtrltj |||q||j|<n t d|dS)NthisownthisZ SwigPyObjectzYou cannot add attributes to %s) rowntyper__dict____swig_setmethods__get _newclassobject __setattr__AttributeError)self class_typenamevalueZstaticmethodrrr_swig_setattr_nondynamic3s    r,cCst||||dS)Nr)r,)r'r(r)r*rrr _swig_setattrFsr-cCsB|dkr|jjS|jj|d}|r,||Std|j|fdS)Nrz!'%s' object has no attribute '%s')rr__swig_getmethods__r"r&r)r'r(r)r+rrr _swig_getattrJs  r/c CsDyd|jj}Wntjk r,d}YnXd|jj|jj|fS)Nz proxy of z <%s.%s; %s >)r__repr__ __builtin__ Exception __class__ __module__r)r'Zstrthisrrr _swig_reprSs  r6c@s eZdZdS)_objectN)rr5 __qualname__rrrrr7^sr7bytescCst|tr|Stj|S)N) isinstanceintbuiltinsord)srrrr=ms r=cCs tj|S)N)rub_ctx_free_dbg)crrrr?ssr?cCs tj|S)N)rub_resolve_free_dbg)rrrrrAsrAc@seZdZdZddZddZedddZd d Ze ed d Z d dZ e e dd Z ddZ e e dd ZddZe edd ZddZe edd ZddZe edd ZdS)ub_dataz3Class which makes the resolution results accessiblecCs|dkrtd||_dS)zZCreates ub_data class :param data: a list of the result data in RAW format Nzub_data init: No data)r3data)r'rDrrr__init__szub_data.__init__cCsdjdd|jDS)zRepresents data as string;cSs g|]}djtdd|qS) cSs dt|S)Nz%02X)r=)xrrrsz,ub_data.__str__...)r map).0arrr sz#ub_data.__str__..)r rD)r'rrr__str__szub_data.__str__rcCsz|sgSg}t|}|dkr&t||}|}xJ||krtt||}|jt||d|d|j||d7}q,W|S)zParses DNAME and produces a list of labels :param ofs: where the conversion should start to parse data :param maxlen: maximum length (0 means parse to the end) :returns: list of labels (string) rr)lenminr=appendstrdecode)r>ZofsmaxlenresZslenidxZcomplenrrr dname2strs   &zub_data.dname2strcCs|jS)zReturns a list of RAW strings)rD)r'rrr as_raw_dataszub_data.as_raw_datazLReturns RAW data (a list of binary encoded strings). See :meth:`as_raw_data`)doccsfddjDS)zzRepresents data as a list of MX records (query for RR_TYPE_MX) :returns: list of tuples (priority, dname) csDg|]<}dt|dt|ddjddj|dDfqS)rrrcSsg|]}|qSrr)rKrLrrrrMsz1ub_data.as_mx_list...r)r=r rW)rKrdf)r'rrrMsz&ub_data.as_mx_list..)rD)r'r)r'r as_mx_listszub_data.as_mx_listzUReturns a list of tuples containing priority and domain names. See :meth:`as_mx_list`csfddjDS)zRepresents data as a list of MX records (query for RR_TYPE_MX) :returns: list of tuples (priority, unicode dname) csDg|]<}dt|dt|ddjddj|dDfqS)rZrrrcSsg|]}tjj|qSr) encodingsidna ToUnicode)rKrLrrrrMsz5ub_data.as_idn_mx_list...r)r=r rW)rKr[)r'rrrMsz*ub_data.as_idn_mx_list..)rD)r'r)r'ras_idn_mx_listszub_data.as_idn_mx_listz]Returns a list of tuples containing priority and IDN domain names. See :meth:`as_idn_mx_list`cCsdd|jDS)zlRepresents data as a list of IP addresses (query for RR_TYPE_PTR) :returns: list of strings cSs g|]}djtdd|qS)rcSs tt|S)N)rRr=)rHrrrrIsz4ub_data.as_address_list...)r rJ)rKrLrrrrMsz+ub_data.as_address_list..)rD)r'rrras_address_list szub_data.as_address_listz;Returns a list of IP addresses. See :meth:`as_address_list`cstfddjS)zjRepresents data as a list of domain names (query for RR_TYPE_A) :returns: list of strings csdjj|S)Nr)r rW)rH)r'rrrIsz(ub_data.as_domain_list..)rJrD)r'r)r'ras_domain_listszub_data.as_domain_listz:Returns a list of domain names. See :meth:`as_domain_list`cstfddjS)zrRepresents data as a list of unicode domain names (query for RR_TYPE_A) :returns: list of strings csdjddj|DS)NrcSsg|]}tjj|qSr)r]r^r_)rKrLrrrrM sz@ub_data.as_idn_domain_list....)r rW)rH)r'rrrI sz,ub_data.as_idn_domain_list..)rJrD)r'r)r'ras_idn_domain_listszub_data.as_idn_domain_listzBReturns a list of IDN domain names. See :meth:`as_idn_domain_list`N)rr)rr5r8__doc__rErN staticmethodrWrXpropertyrawr\Zmx_listr`Z mx_list_idnraZ address_listrbZ domain_listrcZdomain_list_idnrrrrrCs"      rCc@s8eZdZdZiZddZiZddZddZe Z e j ed<e j ed<erVee j e j Ze jed<e jed<er|ee je jZe jed <e jed <eree je jZe jed <e jed <eree je jZe jed <e jed <eree je jZe jed <e jed <eree je jZe j ed <e j!ed <er>ee j!e j Z"e j#ed<e j$ed<erfee j$e j#Z%e j&ed<e j'ed<eree j'e j&Z(e j)ed<e j*ed<eree j*e j)Z+e j,ed<e j-ed<eree j-e j,Z.e j/ed<e j0ed<eree j0e j/Z1e j2ed<e j3ed<er.ee j3e j2Z4e j5ed<e j6ed<erVee j6e j5Z7e j8ed<e j9ed<er~ee j9e j8Z:e j;ed<e jddZ?ddZe j@ZAeBdeCdeDdeEdeFd eGd!eHd"eId#eJd$eKd%eLd&i ZMd'd(ZNeOeNZPd)d*ZQeOeQd+d,ZRd-d.ZSeOe?ZTeOeSd/d,ZUd0S)1 ub_resultz&The validation and resolution results.cCst|t||S)N)r-rh)r'r)r*rrrrI.szub_result.cCs t|t|S)N)r/rh)r'r)rrrrI0scOs tddS)NzNo constructor defined)r&)r'argskwargsrrrrE2szub_result.__init__qnameqtypeqclass_datarO canonnamercode answer_packet answer_lenhavedatanxdomainsecurebogus why_bogusttlwas_ratelimitedcCs tj||S)N)rZub_result__ub_result_data)r'resultrrr_ub_result_datavszub_result._ub_result_datacCs tj|S)N)rZub_result__packet)r'rrr_packetyszub_result._packetcCs tddS)Nz%This class can't be created directly.)r3)r'rrrrE|szno errorz form errorz serv failz nx domainznot implementedZrefusedZyxdomainZyxrrsetZnxrrsetznot authznot zonecCs |j|jS)zRReturns rcode in display representation form :returns: string ) rcode2strrp)r'rrr_get_rcode_strszub_result._get_rcode_strcCs |j|S)a Result data, a list of network order DNS rdata items. Data are represented as a list of strings. To decode RAW data to the list of IP addresses use :attr:`data` attribute which returns an :class:`ub_data` instance containing conversion function. )r{)r'rrr _get_raw_dataszub_result._get_raw_datazReturns raw data, a list of rdata items. To decode RAW data use the :attr:`data` attribute which returns an instance of :class:`ub_data` containing the conversion functions.)rYcCs|js dSt|j|S)N)rsrCr{)r'rrr _get_dataszub_result._get_datazOReturns :class:`ub_data` instance containing various decoding functions or NoneN)Vrr5r8rdr!r%r. __getattr__rEr6r1rZub_result_qname_setZub_result_qname_getr#_swig_propertyrkZub_result_qtype_setZub_result_qtype_getrlZub_result_qclass_setZub_result_qclass_getrmZub_result__data_setZub_result__data_getrnZub_result_len_setZub_result_len_getrOZub_result_canonname_setZub_result_canonname_getroZub_result_rcode_setZub_result_rcode_getrpZub_result_answer_packet_setZub_result_answer_packet_getrqZub_result_answer_len_setZub_result_answer_len_getrrZub_result_havedata_setZub_result_havedata_getrsZub_result_nxdomain_setZub_result_nxdomain_getrtZub_result_secure_setZub_result_secure_getruZub_result_bogus_setZub_result_bogus_getrvZub_result_why_bogus_setZub_result_why_bogus_getrwZub_result_ttl_setZub_result_ttl_getrxZub_result_was_ratelimited_setZub_result_was_ratelimited_getryr{r|_ub_resolve_free__swig_destroy__ RCODE_NOERROR RCODE_FORMERRRCODE_SERVFAILRCODE_NXDOMAIN RCODE_NOTIMPL RCODE_REFUSEDRCODE_YXDOMAIN RCODE_YXRRSET RCODE_NXRRSET RCODE_NOTAUTH RCODE_NOTZONEr}r~rfZ rcode_strrZrawdatarZpacketrDrrrrrh*s                                0 rhcCstjS)N)r ub_ctx_createrrrrrsrcCs tj|S)N)r_ub_ctx_delete)ctxrrrrsrcCstj|||S)N)rub_ctx_set_option)roptvalrrrrsrcCstj|||S)N)rub_ctx_get_option)rrrRrrrrsrcCs tj||S)N)r ub_ctx_config)rfnamerrrrsrcCs tj||S)N)rub_ctx_set_fwd)raddrrrrrsrcCs tj||S)N)rub_ctx_set_tls)rZtlsrrrrsrcCstj||||S)N)rub_ctx_set_stub)rZzonerZisprimerrrrsrcCs tj||S)N)rub_ctx_resolvconf)rrrrrrsrcCs tj||S)N)r ub_ctx_hosts)rrrrrrsrcCs tj||S)N)r ub_ctx_add_ta)rtarrrrsrcCs tj||S)N)rub_ctx_add_ta_file)rrrrrrsrcCs tj||S)N)rub_ctx_add_ta_autr)rrrrrrsrcCs tj||S)N)rub_ctx_trustedkeys)rrrrrrsrcCs tj||S)N)rub_ctx_debuglevel)rdrrrrsrcCs tj||S)N)r ub_ctx_async)rdothreadrrrrsrcCs tj|S)N)rub_poll)rrrrrsrcCs tj|S)N)rub_wait)rrrrrsrcCs tj|S)N)rub_fd)rrrrrsrcCs tj|S)N)r ub_process)rrrrrsrcCstj||||S)N)r ub_resolve)rr)rrtyperrclassrrrrsrcCstj|||||||S)N)rub_resolve_async)rr)rrmydatacallbackasync_idrrrrsrcCs tj||S)N)r ub_cancel)rrrrrrsrcCs tj|S)N)rr)rzrrrr srcCs tj|S)N)r ub_strerror)errrrrrsrcCs tj|S)N)rub_ctx_print_local_zones)rrrrrsrcCstj|||S)N)rub_ctx_zone_add)r zone_nameZ zone_typerrrrsrcCs tj||S)N)rub_ctx_zone_remove)rrrrrrsrcCs tj||S)N)rub_ctx_data_add)rrDrrrrsrcCs tj||S)N)rub_ctx_data_remove)rrDrrrr#srcCstjS)N)r ub_versionrrrrr'src@seZdZiZddZiZddZeZe j ed<e j ed<e rJe e j e j Ze jed<e rbe e jZe jed<e rze e jZddZe jZd dZd S) ub_shm_stat_infocCst|t||S)N)r-r)r'r)r*rrrrI,szub_shm_stat_info.cCs t|t|S)N)r/r)r'r)rrrrI.s num_threadstimememc Cs:tj}y|jj|Wntjk r4||_YnXdS)N)rZnew_ub_shm_stat_inforrQr2r3)r'rrrrrE;s zub_shm_stat_info.__init__cCsdS)Nr)r'rrrrIBsN)rr5r8r!r%r.rr6r1rZ ub_shm_stat_info_num_threads_setZ ub_shm_stat_info_num_threads_getr#rrZub_shm_stat_info_time_getrZub_shm_stat_info_mem_getrrEZdelete_ub_shm_stat_infor__del__rrrrr*s$      rc@seZdZiZddZiZddZeZe j ed<e j ed<e rJe e j e j Ze jed<e jed<e rpe e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed <e jed <e r e e je jZe jed <e jed <e r2e e je jZ e j!ed <e j"ed <e rZe e j"e j!Z#e j$ed <e j%ed <e re e j%e j$Z&e j'ed <e j(ed <e re e j(e j'Z)ddZ*e j+Z,ddZ-dS)ub_shm_stat_info_memcCst|t||S)N)r-r)r'r)r*rrrrIHszub_shm_stat_info_mem.cCs t|t|S)N)r/r)r'r)rrrrIJsmsgrrsetritersubnetipsecmodrespipdnscrypt_shared_secretdnscrypt_noncedynlibc Cs:tj}y|jj|Wntjk r4||_YnXdS)N)rZnew_ub_shm_stat_info_memrrQr2r3)r'rrrrrEus zub_shm_stat_info_mem.__init__cCsdS)Nr)r'rrrrI|sN).rr5r8r!r%r.rr6r1rZub_shm_stat_info_mem_msg_setZub_shm_stat_info_mem_msg_getr#rrZub_shm_stat_info_mem_rrset_setZub_shm_stat_info_mem_rrset_getrZub_shm_stat_info_mem_val_setZub_shm_stat_info_mem_val_getrZub_shm_stat_info_mem_iter_setZub_shm_stat_info_mem_iter_getrZub_shm_stat_info_mem_subnet_setZub_shm_stat_info_mem_subnet_getrZ!ub_shm_stat_info_mem_ipsecmod_setZ!ub_shm_stat_info_mem_ipsecmod_getrZub_shm_stat_info_mem_respip_setZub_shm_stat_info_mem_respip_getrZ/ub_shm_stat_info_mem_dnscrypt_shared_secret_setZ/ub_shm_stat_info_mem_dnscrypt_shared_secret_getrZ'ub_shm_stat_info_mem_dnscrypt_nonce_setZ'ub_shm_stat_info_mem_dnscrypt_nonce_getrZub_shm_stat_info_mem_dynlib_setZub_shm_stat_info_mem_dynlib_getrrEZdelete_ub_shm_stat_info_memrrrrrrrFs`                    rc@s$eZdZiZddZiZddZeZe j ed<e j ed<e rJe e j e j Ze jed<e jed<e rpe e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed <e jed <e r e e je jZd d Ze jZ d dZ!d S)ub_shm_stat_info_timecCst|t||S)N)r-r)r'r)r*rrrrIszub_shm_stat_info_time.cCs t|t|S)N)r/r)r'r)rrrrIsnow_secnow_usecup_secup_usec elapsed_sec elapsed_usecc Cs:tj}y|jj|Wntjk r4||_YnXdS)N)rZnew_ub_shm_stat_info_timerrQr2r3)r'rrrrrEs zub_shm_stat_info_time.__init__cCsdS)Nr)r'rrrrIsN)"rr5r8r!r%r.rr6r1rZ!ub_shm_stat_info_time_now_sec_setZ!ub_shm_stat_info_time_now_sec_getr#rrZ"ub_shm_stat_info_time_now_usec_setZ"ub_shm_stat_info_time_now_usec_getrZ ub_shm_stat_info_time_up_sec_setZ ub_shm_stat_info_time_up_sec_getrZ!ub_shm_stat_info_time_up_usec_setZ!ub_shm_stat_info_time_up_usec_getrZ%ub_shm_stat_info_time_elapsed_sec_setZ%ub_shm_stat_info_time_elapsed_sec_getrZ&ub_shm_stat_info_time_elapsed_usec_setZ&ub_shm_stat_info_time_elapsed_usec_getrrEZdelete_ub_shm_stat_info_timerrrrrrrs@            rc@s eZdZiZddZiZddZeZe j ed<e j ed<e rJe e j e j Ze jed<e jed<e rpe e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed <e jed <e r e e je jZe jed <e jed <e r2e e je jZ e j!ed <e j"ed <e rZe e j"e j!Z#e j$ed <e j%ed <e re e j%e j$Z&e j'ed <e j(ed <e re e j(e j'Z)e j*ed<e j+ed<e re e j+e j*Z,e j-ed<e j.ed<e re e j.e j-Z/e j0ed<e j1ed<e r"e e j1e j0Z2e j3ed<e j4ed<e rJe e j4e j3Z5e j6ed<e j7ed<e rre e j7e j6Z8e j9ed<e j:ed<e re e j:e j9Z;e je j?ed<e j@ed<e re e j@e j?ZAe jBed<e jCed<e re e jCe jBZDe jEed<e jFed<e r:e e jFe jEZGe jHed<e jIed<e rbe e jIe jHZJe jKed<e jLed<e re e jLe jKZMe jNed<e jOed<e re e jOe jNZPe jQed<e jRed<e re e jRe jQZSe jTed<e jUed<e re e jUe jTZVe jWed<e jXed<e r*e e jXe jWZYe jZed<e j[ed<e rRe e j[e jZZ\e j]ed<e j^ed<e rze e j^e j]Z_e j`ed <e jaed <e re e jae j`Zbe jced!<e jded!<e re e jde jcZee jfed"<e jged"<e re e jge jfZhe jied#<e jjed#<e re e jje jiZke jled$<e jmed$<e rBe e jme jlZne joed%<e jped%<e rje e jpe joZqe jred&<e jsed&<e re e jse jrZte jued'<e jved'<e re e jve juZwe jxed(<e jyed(<e re e jye jxZze j{ed)<e j|ed)<e r e e j|e j{Z}e j~ed*<e jed*<e r2e e je j~Ze jed+<e jed+<e rZe e je jZe jed,<e jed,<e re e je jZe jed-<e jed-<e re e je jZe jed.<e jed.<e re e je jZe jed/<e jed/<e re e je jZe jed0<e jed0<e r"e e je jZe jed1<e jed1<e rJe e je jZe jed2<e jed2<e rre e je jZe jed3<e jed3<e re e je jZe jed4<e jed4<e re e je jZe jed5<e jed5<e re e je jZe jed6<e jed6<e re e je jZe jed7<e jed7<e r:e e je jZe jed8<e jed8<e rbe e je jZe jed9<e jed9<e re e je jZe jed:<e jed:<e re e je jZe jed;<e jed;<e re e je jZe jed<<e jed<<e re e je jZe jed=<e jed=<e r*e e je jZe jed><e jed><e rRe e je jZe jed?<e jed?<e rze e je jZe jed@<e jed@<e re e je jZe jedA<e jedA<e re e je jÃZdBdCZe jZdDdZdES)Fub_server_statscCst|t||S)N)r-r)r'r)r*rrrrIszub_server_stats.cCs t|t|S)N)r/r)r'r)rrrrIs num_queriesnum_queries_ip_ratelimitednum_queries_missed_cachenum_queries_prefetchsum_query_list_sizemax_query_list_sizeextendedrl qtype_bigrm qclass_bigqopcodeqtcp qtcp_outgoing qudp_outgoingqtlsqhttpsqipv6qbit_QRqbit_AAqbit_TCqbit_RDqbit_RAqbit_Zqbit_ADqbit_CDqEDNSqEDNS_DO ans_rcodeans_rcode_nodata ans_secure ans_bogus rrset_bogusqueries_ratelimitedunwanted_repliesunwanted_queriestcp_accept_usage ans_expiredhistmsg_cache_countrrset_cache_countinfra_cache_countkey_cache_countnum_query_dnscrypt_cryptednum_query_dnscrypt_certnum_query_dnscrypt_cleartext$num_query_dnscrypt_crypted_malformed&num_query_dnscrypt_secret_missed_cacheshared_secret_cache_countnum_query_dnscrypt_replaynonce_cache_countnum_query_authzone_upnum_query_authzone_downnum_neg_cache_noerrornum_neg_cache_nxdomainnum_query_subnetnum_query_subnet_cachemem_stream_waitmem_http2_query_buffermem_http2_response_buffer qtls_resume rpz_actionc Cs:tj}y|jj|Wntjk r4||_YnXdS)N)rZnew_ub_server_statsrrQr2r3)r'rrrrrEs zub_server_stats.__init__cCsdS)Nr)r'rrrrIsN)rr5r8r!r%r.rr6r1rZub_server_stats_num_queries_setZub_server_stats_num_queries_getr#rrZ.ub_server_stats_num_queries_ip_ratelimited_setZ.ub_server_stats_num_queries_ip_ratelimited_getrZ,ub_server_stats_num_queries_missed_cache_setZ,ub_server_stats_num_queries_missed_cache_getrZ(ub_server_stats_num_queries_prefetch_setZ(ub_server_stats_num_queries_prefetch_getrZ'ub_server_stats_sum_query_list_size_setZ'ub_server_stats_sum_query_list_size_getrZ'ub_server_stats_max_query_list_size_setZ'ub_server_stats_max_query_list_size_getrZub_server_stats_extended_setZub_server_stats_extended_getrZub_server_stats_qtype_setZub_server_stats_qtype_getrlZub_server_stats_qtype_big_setZub_server_stats_qtype_big_getrZub_server_stats_qclass_setZub_server_stats_qclass_getrmZub_server_stats_qclass_big_setZub_server_stats_qclass_big_getrZub_server_stats_qopcode_setZub_server_stats_qopcode_getrZub_server_stats_qtcp_setZub_server_stats_qtcp_getrZ!ub_server_stats_qtcp_outgoing_setZ!ub_server_stats_qtcp_outgoing_getrZ!ub_server_stats_qudp_outgoing_setZ!ub_server_stats_qudp_outgoing_getrZub_server_stats_qtls_setZub_server_stats_qtls_getrZub_server_stats_qhttps_setZub_server_stats_qhttps_getrZub_server_stats_qipv6_setZub_server_stats_qipv6_getrZub_server_stats_qbit_QR_setZub_server_stats_qbit_QR_getrZub_server_stats_qbit_AA_setZub_server_stats_qbit_AA_getrZub_server_stats_qbit_TC_setZub_server_stats_qbit_TC_getrZub_server_stats_qbit_RD_setZub_server_stats_qbit_RD_getrZub_server_stats_qbit_RA_setZub_server_stats_qbit_RA_getrZub_server_stats_qbit_Z_setZub_server_stats_qbit_Z_getrZub_server_stats_qbit_AD_setZub_server_stats_qbit_AD_getrZub_server_stats_qbit_CD_setZub_server_stats_qbit_CD_getrZub_server_stats_qEDNS_setZub_server_stats_qEDNS_getrZub_server_stats_qEDNS_DO_setZub_server_stats_qEDNS_DO_getrZub_server_stats_ans_rcode_setZub_server_stats_ans_rcode_getrZ$ub_server_stats_ans_rcode_nodata_setZ$ub_server_stats_ans_rcode_nodata_getrZub_server_stats_ans_secure_setZub_server_stats_ans_secure_getrZub_server_stats_ans_bogus_setZub_server_stats_ans_bogus_getrZub_server_stats_rrset_bogus_setZub_server_stats_rrset_bogus_getrZ'ub_server_stats_queries_ratelimited_setZ'ub_server_stats_queries_ratelimited_getrZ$ub_server_stats_unwanted_replies_setZ$ub_server_stats_unwanted_replies_getrZ$ub_server_stats_unwanted_queries_setZ$ub_server_stats_unwanted_queries_getrZ$ub_server_stats_tcp_accept_usage_setZ$ub_server_stats_tcp_accept_usage_getrZub_server_stats_ans_expired_setZub_server_stats_ans_expired_getrZub_server_stats_hist_setZub_server_stats_hist_getrZ#ub_server_stats_msg_cache_count_setZ#ub_server_stats_msg_cache_count_getrZ%ub_server_stats_rrset_cache_count_setZ%ub_server_stats_rrset_cache_count_getrZ%ub_server_stats_infra_cache_count_setZ%ub_server_stats_infra_cache_count_getrZ#ub_server_stats_key_cache_count_setZ#ub_server_stats_key_cache_count_getrZ.ub_server_stats_num_query_dnscrypt_crypted_setZ.ub_server_stats_num_query_dnscrypt_crypted_getrZ+ub_server_stats_num_query_dnscrypt_cert_setZ+ub_server_stats_num_query_dnscrypt_cert_getrZ0ub_server_stats_num_query_dnscrypt_cleartext_setZ0ub_server_stats_num_query_dnscrypt_cleartext_getrZ8ub_server_stats_num_query_dnscrypt_crypted_malformed_setZ8ub_server_stats_num_query_dnscrypt_crypted_malformed_getrZ:ub_server_stats_num_query_dnscrypt_secret_missed_cache_setZ:ub_server_stats_num_query_dnscrypt_secret_missed_cache_getrZ-ub_server_stats_shared_secret_cache_count_setZ-ub_server_stats_shared_secret_cache_count_getrZ-ub_server_stats_num_query_dnscrypt_replay_setZ-ub_server_stats_num_query_dnscrypt_replay_getrZ%ub_server_stats_nonce_cache_count_setZ%ub_server_stats_nonce_cache_count_getrZ)ub_server_stats_num_query_authzone_up_setZ)ub_server_stats_num_query_authzone_up_getrZ+ub_server_stats_num_query_authzone_down_setZ+ub_server_stats_num_query_authzone_down_getrZ)ub_server_stats_num_neg_cache_noerror_setZ)ub_server_stats_num_neg_cache_noerror_getrZ*ub_server_stats_num_neg_cache_nxdomain_setZ*ub_server_stats_num_neg_cache_nxdomain_getrZ$ub_server_stats_num_query_subnet_setZ$ub_server_stats_num_query_subnet_getr Z*ub_server_stats_num_query_subnet_cache_setZ*ub_server_stats_num_query_subnet_cache_getr Z#ub_server_stats_mem_stream_wait_setZ#ub_server_stats_mem_stream_wait_getr Z*ub_server_stats_mem_http2_query_buffer_setZ*ub_server_stats_mem_http2_query_buffer_getr Z-ub_server_stats_mem_http2_response_buffer_setZ-ub_server_stats_mem_http2_response_buffer_getr Zub_server_stats_qtls_resume_setZub_server_stats_qtls_resume_getrZub_server_stats_rpz_action_setZub_server_stats_rpz_action_getrrEZdelete_ub_server_statsrrrrrrrs                                                                                                                            rc@seZdZiZddZiZddZeZe j ed<e j ed<e rJe e j e j Ze jed<e jed<e rpe e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed<e jed<e re e je jZe jed <e jed <e r e e je jZe jed <e jed <e r2e e je jZ e j!ed <e j"ed <e rZe e j"e j!Z#e j$ed <e j%ed <e re e j%e j$Z&d dZ'e j(Z)ddZ*dS) ub_stats_infocCst|t||S)N)r-r)r'r)r*rrrrIszub_stats_info.cCs t|t|S)N)r/r)r'r)rrrrIssvrmesh_num_statesmesh_num_reply_states mesh_jostled mesh_droppedmesh_replies_sentmesh_replies_sum_wait_secmesh_replies_sum_wait_usecmesh_time_medianc Cs:tj}y|jj|Wntjk r4||_YnXdS)N)rZnew_ub_stats_inforrQr2r3)r'rrrrrEs zub_stats_info.__init__cCsdS)Nr)r'rrrrIsN)+rr5r8r!r%r.rr6r1rZub_stats_info_svr_setZub_stats_info_svr_getr#rrZ!ub_stats_info_mesh_num_states_setZ!ub_stats_info_mesh_num_states_getrZ'ub_stats_info_mesh_num_reply_states_setZ'ub_stats_info_mesh_num_reply_states_getrZub_stats_info_mesh_jostled_setZub_stats_info_mesh_jostled_getrZub_stats_info_mesh_dropped_setZub_stats_info_mesh_dropped_getrZ#ub_stats_info_mesh_replies_sent_setZ#ub_stats_info_mesh_replies_sent_getrZ+ub_stats_info_mesh_replies_sum_wait_sec_setZ+ub_stats_info_mesh_replies_sum_wait_sec_getrZ,ub_stats_info_mesh_replies_sum_wait_usec_setZ,ub_stats_info_mesh_replies_sum_wait_usec_getrZ"ub_stats_info_mesh_time_median_setZ"ub_stats_info_mesh_time_median_getrrEZdelete_ub_stats_inforrrrrrrsX                  rc@seZdZdZiZddZiZddZddZe Z ddZe j Z dd Zd d Zd d ZddZddZd;ddZddZd>> import unbound >>> ctx = unbound.ub_ctx() >>> ctx.resolvconf("/etc/resolv.conf") >>> status, result = ctx.resolve("www.google.com", unbound.RR_TYPE_A, unbound.RR_CLASS_IN) >>> if status==0 and result.havedata: >>> print "Result:",result.data.address_list Result: ['74.125.43.147', '74.125.43.99', '74.125.43.103', '74.125.43.104'] cCst|t||S)N)r-r)r'r)r*rrrrIszub_ctx.cCs t|t|S)N)r/r)r'r)rrrrIscOs tddS)NzNo constructor defined)r&)r'rirjrrrrEszub_ctx.__init__cCstj|_|jstddS)zCreates a resolving and validation context. An exception is invoked if the process of creation an ub_ctx instance fails. z2Fatal error: unbound context initialization failedN)rrrr3)r'rrrrE s cCs tj||S)aPAdd a trust anchor to the given context. The trust anchor is a string, on one line, that holds a valid DNSKEY or DS RR. :param ta: string, with zone-format RR on one line. [domainname] [TTL optional] [type] [class optional] [rdata contents] :returns: (int) 0 if OK, else error. )rr)r'rrrradd_tas z ub_ctx.add_tacCs tj||S)aAdd trust anchors to the given context. Pass name of a file with DS and DNSKEY records (like from dig or drill). :param fname: filename of file with keyfile with trust anchors. :returns: (int) 0 if OK, else error. )rr)r'rrrr add_ta_file%s zub_ctx.add_ta_filecCs tj||S)a\setup configuration for the given context. :param fname: unbound config file (not all settings applicable). This is a power-users interface that lets you specify all sorts of options. For some specific options, such as adding trust anchors, special routines exist. :returns: (int) 0 if OK, else error. )rr)r'rrrrconfig2sz ub_ctx.configcCs tj||S)zSet debug verbosity for the context Output is directed to stderr. :param d: debug level, 0 is off, 1 is very minimal, 2 is detailed, and 3 is lots. :returns: (int) 0 if OK, else error. )rr)r'rrrr debuglevel=szub_ctx.debuglevelcCs tj||S)aSet debug output (and error output) to the specified stream. Pass None to disable. Default is stderr. :param out: File stream to log to. :returns: (int) 0 if OK, else error. **Usage:** In order to log into file, use :: ctx = unbound.ub_ctx() fw = fopen("debug.log") ctx.debuglevel(3) ctx.debugout(fw) Another option is to print the debug information to stderr output :: ctx = unbound.ub_ctx() ctx.debuglevel(10) ctx.debugout(sys.stderr) )rub_ctx_debugout)r'outrrrdebugoutHszub_ctx.debugout /etc/hostscCs tj||S)a"Read list of hosts from the filename given. Usually "/etc/hosts". These addresses are not flagged as DNSSEC secure when queried for. :param fname: file name string. If None "/etc/hosts" is used. :returns: (int) 0 if OK, else error. )rr)r'rrrrhostshs z ub_ctx.hostscCs tj|S)zPrint the local zones and their content (RR data) to the debug output. :returns: (int) 0 if OK, else error. )rr)r'rrrprint_local_zonesuszub_ctx.print_local_zones/etc/resolv.confcCs tj||S)aRead list of nameservers to use from the filename given. Usually "/etc/resolv.conf". Uses those nameservers as caching proxies. If they do not support DNSSEC, validation may fail. Only nameservers are picked up, the searchdomain, ndots and other settings from resolv.conf(5) are ignored. :param fname: file name string. If None "/etc/resolv.conf" is used. :returns: (int) 0 if OK, else error. )rr)r'rrrr resolvconf~s zub_ctx.resolvconfcCs tj||S)aSet a context behaviour for asynchronous action. :param dothread: if True, enables threading and a call to :meth:`resolve_async` creates a thread to handle work in the background. If False, a process is forked to handle work in the background. Changes to this setting after :meth:`async` calls have been made have no effect (delete and re-create the context to change). :returns: (int) 0 if OK, else error. )rr)r'rrrr set_asyncs zub_ctx.set_asynccCs tj||S)aoSet machine to forward DNS queries to, the caching resolver to use. IP4 or IP6 address. Forwards all DNS requests to that machine, which is expected to run a recursive resolver. If the is not DNSSEC-capable, validation may fail. Can be called several times, in that case the addresses are used as backup servers. To read the list of nameservers from /etc/resolv.conf (from DHCP or so), use the call :meth:`resolvconf`. :param addr: address, IP4 or IP6 in string format. If the addr is None, forwarding is disabled. :returns: (int) 0 if OK, else error. )rr)r'rrrrset_fwds zub_ctx.set_fwdcCstj|||S)aSet an option for the context. Changes to the options after :meth:`resolve`, :meth:`resolve_async`, :meth:`zone_add`, :meth:`zone_remove`, :meth:`data_add` or :meth:`data_remove` have no effect (you have to delete and re-create the context). :param opt: option name from the unbound.conf config file format. (not all settings applicable). The name includes the trailing ':' for example set_option("logfile:", "mylog.txt"); This is a power-users interface that lets you specify all sorts of options. For some specific options, such as adding trust anchors, special routines exist. :param val: value of the option. :returns: (int) 0 if OK, else error. )rr)r'rrrrr set_options zub_ctx.set_optioncCs tj||S)aAdd trust anchors to the given context. Pass the name of a bind-style config file with trusted-keys{}. :param fname: filename of file with bind-style config entries with trust anchors. :returns: (int) 0 if OK, else error. )rr)r'rrrr trustedkeyss zub_ctx.trustedkeyscCstj|dS)z Print local zones using debugoutN)rr)r'rrr zone_printszub_ctx.zone_printcCstj|||S)zAdd new local zone :param zonename: zone domain name (e.g. myzone.) :param zonetype: type of the zone ("static",...) :returns: (int) 0 if OK, else error. )rr)r'zonenameZzonetyperrrzone_addszub_ctx.zone_addcCs tj||S)zRemove local zone If exists, removes local zone with all the RRs. :param zonename: zone domain name :returns: (int) 0 if OK, else error. )rr)r'r,rrr zone_removeszub_ctx.zone_removecCs tj||S)aAdd new local RR data :param rrdata: string, in zone-format on one line. [domainname] [TTL optional] [type] [class optional] [rdata contents] :returns: (int) 0 if OK, else error. **Usage** The local data ... :: >>> ctx = unbound.ub_ctx() >>> ctx.zone_add("mydomain.net.","static") 0 >>> status = ctx.data_add("test.mydomain.net. IN A 192.168.1.1") 0 >>> status, result = ctx.resolve("test.mydomain.net") >>> if status==0 and result.havedata: >>> print "Result:",result.data.address_list Result: ['192.168.1.1'] )rr)r'rrdatarrrdata_addszub_ctx.data_addcCs tj||S)aRemove local RR data If exists, remove resource record from local zone :param rrdata: string, in zone-format on one line. [domainname] [TTL optional] [type] [class optional] [rdata contents] :returns: (int) 0 if OK, else error. )rr)r'r/rrr data_removeszub_ctx.data_removecCs tj||S)zCancel an async query in progress. Its callback will not be called. :param async_id: which query to cancel. :returns: (int) 0 if OK, else error. )rr)r'rrrrcancels z ub_ctx.cancelcCs tj|S)ajGet file descriptor. Wait for it to become readable, at this point answers are returned from the asynchronous validating resolver. Then call the ub_process to continue processing. This routine works immediately after context creation, the fd does not change. :returns: (int) -1 on error, or file descriptor to use select(2) with. )rr)r'rrrget_fdsz ub_ctx.get_fdcCs tj|S)a:Poll a context to see if it has any new results Do not poll in a loop, instead extract the fd below to poll for readiness, and then check, or wait using the wait routine. :returns: (int) 0 if nothing to read, or nonzero if a result is available. If nonzero, call ctx_process() to do callbacks. )rr)r'rrrpoll sz ub_ctx.pollcCs tj|S)zCall this routine to continue processing results from the validating resolver (when the fd becomes readable). Will perform necessary callbacks. :returns: (int) 0 if OK, else error. )rr)r'rrrprocess)szub_ctx.processcCs2t|trtj||||Stj|t|||SdS)aPerform resolution and validation of the target name. :param name: domain name in text format (a string or unicode string). IDN domain name have to be passed as a unicode string. :param rrtype: type of RR in host order (optional argument). Default value is RR_TYPE_A (A class). :param rrclass: class of RR in host order (optional argument). Default value is RR_CLASS_IN (for internet). :returns: * (int) 0 if OK, else error. * (:class:`ub_result`) the result data is returned in a newly allocated result structure. May be None on return, return value is set to an error in that case (out of memory). N)r:r9rr idn2dname)r'r)rrrrrresolve4s zub_ctx.resolvecCs:t|trtj||||||Stj|t|||||SdS)aKPerform resolution and validation of the target name. Asynchronous, after a while, the callback will be called with your data and the result. If an error happens during processing, your callback will be called with error set to a nonzero value (and result==None). :param name: domain name in text format (a string or unicode string). IDN domain name have to be passed as a unicode string. :param mydata: this data is your own data (you can pass arbitrary python object or None) which are passed on to the callback function. :param callback: call-back function which is called on completion of the resolution. :param rrtype: type of RR in host order (optional argument). Default value is RR_TYPE_A (A class). :param rrclass: class of RR in host order (optional argument). Default value is RR_CLASS_IN (for internet). :returns: * (int) 0 if OK, else error. * (int) async_id, an identifier number is returned for the query as it is in progress. It can be used to cancel the query. **Call-back function:** The call-back function looks as the follows:: def call_back(mydata, status, result): pass **Parameters:** * `mydata` - mydata object * `status` - 0 when a result has been found * `result` - the result structure. The result may be None, in that case err is set. N)r:r9r_ub_resolve_asyncr6)r'r)rrrrrrr resolve_asyncGs zub_ctx.resolve_asynccCs tj|S)zWait for a context to finish with results. Calls after the wait for you. After the wait, there are no more outstanding asynchronous queries. :returns: (int) 0 if OK, else error. )rr)r'rrrwaitmsz ub_ctx.waitN)r")r%)(rr5r8rdr!r%r.rrEr6r1rrrrrrrr!r#r$r&r'r(r)r*r+r-r.r0r1r2r3r4r5 RR_TYPE_A RR_CLASS_INr7r9r:rrrrrsB               &rcGs tj|S)N)rr)rirrrr~srcCstj||||||S)N)rr8)rr)rrrZpyfuncrrrr8sr8cCs$djdd|jdDdddS)zbReverse domain name Usable for reverse lookups when the IP address should be reversed rcSsg|]}|qSrr)rKrLrrrrMszreverse..Nr)r split)Zdomainrrrreversesr?cCsdjdd|jdDS)zConverts domain name in IDN format to canonic domain name :param idnname: (unicode string) IDN name :returns: (string) domain name rcSs g|]}|rtjj|ndqS)r0)r]r^ZToASCII)rKrLrrrrMszidn2dname..)r r>)Zidnnamerrrr6sr6cCsdjdd|jdDS)zConverts canonic domain name in IDN format to unicode string :param name: (string) domain name :returns: (unicode string) domain name rcSsg|]}tjj|qSr)r]r^r_)rKrLrrrrMszdname2idn..)r r>)r)rrr dname2idnsr@)rrr)rrr)r)sysrZ_swig_python_version_inforrrfr NameErrorr<r2r r,r-r/r6r$r7r#r3Zencodings.idnar]varsrRr9r=r?r;Z RR_TYPE_NSZ RR_TYPE_MDZ RR_TYPE_MFZ RR_TYPE_CNAMEZ RR_TYPE_SOAZ RR_TYPE_MBZ RR_TYPE_MGZ RR_TYPE_MRZ RR_TYPE_NULLZ RR_TYPE_WKSZ RR_TYPE_PTRZ RR_TYPE_HINFOZ RR_TYPE_MINFOZ RR_TYPE_MXZ RR_TYPE_TXTZ RR_TYPE_RPZ RR_TYPE_AFSDBZ RR_TYPE_X25Z RR_TYPE_ISDNZ RR_TYPE_RTZ RR_TYPE_NSAPZRR_TYPE_NSAP_PTRZ RR_TYPE_SIGZ RR_TYPE_KEYZ RR_TYPE_PXZ RR_TYPE_GPOSZ RR_TYPE_AAAAZ RR_TYPE_LOCZ RR_TYPE_NXTZ RR_TYPE_EIDZRR_TYPE_NIMLOCZ RR_TYPE_SRVZ RR_TYPE_ATMAZ RR_TYPE_NAPTRZ RR_TYPE_KXZ RR_TYPE_CERTZ RR_TYPE_A6Z RR_TYPE_DNAMEZ RR_TYPE_SINKZ RR_TYPE_OPTZ RR_TYPE_APLZ RR_TYPE_DSZ RR_TYPE_SSHFPZRR_TYPE_IPSECKEYZ RR_TYPE_RRSIGZ RR_TYPE_NSECZRR_TYPE_DNSKEYZ RR_TYPE_DHCIDZ RR_TYPE_NSEC3ZRR_TYPE_NSEC3PARAMSZ RR_TYPE_UINFOZ RR_TYPE_UIDZ RR_TYPE_GIDZRR_TYPE_UNSPECZ RR_TYPE_TSIGZ RR_TYPE_IXFRZ RR_TYPE_AXFRZ RR_TYPE_MAILBZ RR_TYPE_MAILAZ RR_TYPE_ANYZ RR_TYPE_CAAZ RR_TYPE_DLVr<Z RR_CLASS_CHZ RR_CLASS_HSZ RR_CLASS_NONEZ RR_CLASS_ANYrArrrrrrrrrrrrCZUNBOUND_VERSION_MAJORZUNBOUND_VERSION_MINORZUNBOUND_VERSION_MICROZUNBOUND_VERSION_MAJOR_REALZUNBOUND_VERSION_MINOR_REALZUNBOUND_VERSION_MICRO_REALrhZub_result_swigregisterZ UB_NOERRORZ UB_SOCKETZUB_NOMEMZ UB_SYNTAXZ UB_SERVFAILZ UB_FORKFAILZ UB_AFTERFINALZ UB_INITFAILZUB_PIPEZ UB_READFILEZUB_NOIDrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrZub_shm_stat_info_swigregisterrZ!ub_shm_stat_info_mem_swigregisterrZ"ub_shm_stat_info_time_swigregisterZUB_STATS_QTYPE_NUMZUB_STATS_QCLASS_NUMZUB_STATS_RCODE_NUMZUB_STATS_OPCODE_NUMZUB_STATS_BUCKET_NUMZUB_STATS_RPZ_ACTION_NUMrZub_server_stats_swigregisterrZub_stats_info_swigregisterrZub_ctx_swigregisterrr8r?r6r@rrrrs       Zv7' 3