def waf_update_ip_set(ip_set_id, source_ip):
waf = boto3.client('waf')
for attempt in range(API_CALL_NUM_RETRIES):
try:
response = waf.update_ip_set(IPSetId=ip_set_id,
ChangeToken=waf.get_change_token()['ChangeToken'],
Updates=[{
'Action': 'INSERT',
'IPSetDescriptor': {
'Type': 'IPV4',
'Value': "%s/32"%source_ip
}
}]
)
except Exception, e:
delay = math.pow(2, attempt)
print "[waf_update_ip_set] Retrying in %d seconds..." % (delay)
time.sleep(delay)
else:
break
else:
print "[waf_update_ip_set] Failed ALL attempts to call API"
access-handler.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录