elʝ$gddlmZddlmcmZddlmZmZddlm Z m Z ddl m Z ddl mZddlmZmZddlmZmZdd lmZd ZGd d ejZdS) ) DoesNotExistN)ValidationErrorlookup)generate_warningsrun_in_executor_decorator)Scope) CountryAPI)WhitelistCacheUpdate IpsetUpdate)Country CountryListsend_to_socketcfd}|S)Ncfd}|S)Nc`K|g|Ri|d{V}tdid{V|S)Nmethod)msgr)selfargskwargsresultfuncrs O/opt/imunify360/venv/lib/python3.11/site-packages/im360/simple_rpc/countries.pywrapperzDnotify_resident_part.._notify_resident_part..wrapperse46t666v66666666F h%7888 8 8 8 8 8 8 8M)rrrs` r_notify_resident_partz3notify_resident_part.._notify_resident_parts)      rr)rrs` rnotify_resident_partrs$ ! rceZdZejZejdddeddZ ejdddddZ ejdddd Z ejddd e e jd Zejd ddedd Zejd dde ejdZejd dde ejddZejd dd e ejdZedZdZdZdZdZdS)CountriesEndpoints blacklistcountrylistNc dtjdi|tjd||tjgd|fSN)limitoffsetby_listr)r fetch_countfetchBLACKrr'r(rs rblacklist_country_listz)CountriesEndpoints.blacklist_country_list!U  # - -f - -   $*+       raddcTK|tj||d{VSN) _country_addr r,ritemscomments rblacklist_country_addz(CountriesEndpoints.blacklist_country_add.s3&&{'8%IIIIIIIIIreditcTK|tj||d{VSr2) _country_editr r,r4s rblacklist_country_editz)CountriesEndpoints.blacklist_country_edit2s3'' (95'JJJJJJJJJrdeletecRK|tj|d{VSr2)_country_deleter r,rr5s rblacklist_country_deletez+CountriesEndpoints.blacklist_country_delete63))+*;UCCCCCCCCCr whitelistc dtjdi|tjd||tjgd|fSr&)r r*r+WHITEr-s rwhitelist_country_listz)CountriesEndpoints.whitelist_country_list;r/rcTK|tj||d{VSr2)r:r rDr4s rwhitelist_country_editz)CountriesEndpoints.whitelist_country_editHs5'' (95'JJJJJJJJJrcTK|tj||d{VSr2)r3r rDr4s rwhitelist_country_addz(CountriesEndpoints.whitelist_country_addMs5&&{'8%IIIIIIIIIrcRK|tj|d{VSr2)r>r rDr?s rwhitelist_country_deletez+CountriesEndpoints.whitelist_country_deleteRrArcV tj|n#t$rYdSwxYwdS)N)codeFT)r getr)r country_codes r _get_countryzCountriesEndpoints._get_countryWsD  K\ * * * * *   55 ts  &&cKg}|D]3}||d{Vs||4|r5tdd|dS)N)rOzCountry does not exist {}z, )rPappendrformatjoin)r country_listwarning_countriesrOs r_check_countries_existsz*CountriesEndpoints._check_countries_exists_s( 7 7L+++FFFFFFFF 7!((666  !+22II/00   rc K||d{Vtj||d{V\}}t||||dddS)N)r6z){}/{} country(s) were successfully editedzNoop: unable to edit {} in {} Country {} is already in {} list dest_listnameall_listsuccess_warningfailure_warningin_another_list_warning)rWr r8rrlistnamer5r6affected not_affecteds rr:z CountriesEndpoints._country_editls**5111111111'1ug'N'N'N!N!N!N!N!N!N,  "G;$F    rc K||d{Vtj|||d{V\}}|tjkr|rt jd{Vt||||dddS)z0Add Country to appropriate ipset and CountryListN)rar6z#{}/{} ip(s) were successfully addedzNoop: unable to add {} from {}rYrZ)rWr blockr r, webshieldupdate_country_blacklist_configrr`s rr3zCountriesEndpoints._country_addys**5111111111'1'7 Hg( ( ( " " " " " " , {( ( (X (;== = = = = = = =  "A<$F    rc K||d{Vtj||d{V\}}|tjkr|rt jd{Vt||||dddS)N)raz%{}/{} ip(s) were successfully deletedz!Noop: unable to delete {} from {}rYrZ)rWr unblockr r,rfrgr)rrar5rbrcs rr>z"CountriesEndpoints._country_deletes**5111111111'1'9 H( ( ( " " " " " " , {( ( (X (;== = = = = = = =  "C?$F    r)NNr2)__name__ __module__ __qualname__rIM360SCOPErbindrr.r7r;rr DEFAULT_METHODr@rEr rGrIrKrPrWr:r3r>rrrr!r!sv KEV[i00    10  V[i//JJJ0/JV[i00KK10KV[i22+455DD6532DV[i00    10  V[i00.=>>KK?>10KV[i//.=>>JJJ?>0/JV[i22.=>>DD?>32D          (     rr!)peeweerim360.subsys.webshieldsubsysrfdefence360agent.rpc_toolsrrdefence360agent.rpc_tools.utilsrrdefence360agent.utilsr im360.api.ipsr im360.contracts.messagesr r im360.model.countryr r im360.simple_rpc.resident_socketrr RootEndpointsr!rrrr|s**********========('''''$$$$$$FFFFFFFF44444444;;;;;; ! ! !     -     r