B$dZddlZddlZddlZddlmZddlmZddlm Z m Z ddl m Z ddl mZejeZGdd e jZdS) zDPlugin that detects whether IDS has set on non-resident agent start.N)utils)safe_cancel_task)pluginsmessagesstrategy)configcleZdZdZfdZdZdZeje dZ dZ dZ xZ S)StrategyGetterz8Send StrategyChange message on non-resident agent start.c Htjdi|d|_dS)N)super__init___StrategyGetter__task)selfkwargs __class__s R/opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins/strategy_getter.pyrzStrategyGetter.__init__s+""6""" c~K||_||_|||_dSN)_loop_sink create_task_detect_strategy_changer)rloopsinks r create_sourcezStrategyGetter.create_sources9  &&t'C'C'E'EFF rcK|j|jrdSt|jd{VdSr)rdonerrs rshutdownzStrategyGetter.shutdownsN ; $+"2"2"4"4  Ft{+++++++++++rcKtjtj5 |d{Vtjt jjd{VD#1swxYwYdS)z+Check whether IDS has changed periodically.TN) contextlibsuppressasyncioCancelledError_refresh_strategysleepr SubsysTHIRD_PARTY_IDS_CHECK_TIMEOUTr!s rrz&StrategyGetter._detect_strategy_change!s !7 8 8   ,,.........mM?           sAA''A+.A+c4K tj}|tjjkr||d{VdSdS#t j$rYdSt$r&}t d|Yd}~dSd}~wwxYw)NzFailed to get strategy, %s) rStrategygetcurrent_on_strategy_changedr&r' Exceptionloggererror)r new_strategyes rr(z StrategyGetter._refresh_strategy+s >#,0022L x0888// ===========98 %    DD : : : LL5q 9 9 9 9 9 9 9 9 9 :sAB( B1BBcKtdtjj||tj_|jtj |d{VdS)NzGot new strategy: %s -> %sr) r2inforr-r/rprocess_messager MessageTypeStrategyChange)rr4s rr0z#StrategyGetter._on_strategy_changed6s (   %    %1!j((  / / / F F           r)__name__ __module__ __qualname____doc__rrr"rabort_agent_onr1rr(r0 __classcell__)rs@rr r sBBGGG ,,, U)$$%$ > > >        rr )r>r&r$loggingdefence360agentrdefence360agent.utilsrdefence360agent.contractsrrim360.internalsrim360.contractsr getLoggerr;r2 MessageSourcer r rrrIsJJ!!!!!!22222277777777$$$$$$""""""  8 $ $0 0 0 0 0 W*0 0 0 0 0 r