easy_whitelist 1.0.44__tar.gz → 1.0.45__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/PKG-INFO +1 -1
  2. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/__init__.py +1 -1
  3. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/ip/ip.py +8 -4
  4. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/ip/url.py +3 -3
  5. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/.gitignore +0 -0
  6. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/CODE_OF_CONDUCT.md +0 -0
  7. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/LICENSE +0 -0
  8. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/README.md +0 -0
  9. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/SECURITY.md +0 -0
  10. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/__main__.py +0 -0
  11. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/config/__init__.py +0 -0
  12. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/config/arg.py +0 -0
  13. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/ip/__init__.py +0 -0
  14. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/ip/agent.py +0 -0
  15. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/ip/pattern.py +0 -0
  16. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/sample/common_client_sample.py +0 -0
  17. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/sample/cvm_sample_detail.py +0 -0
  18. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/sample/cvm_sample_simple.py +0 -0
  19. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/tcloud/__init__.py +0 -0
  20. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/tcloud/client.py +0 -0
  21. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/easy_whitelist/tcloud/template.py +0 -0
  22. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/pyproject.toml +0 -0
  23. {easy_whitelist-1.0.44 → easy_whitelist-1.0.45}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easy_whitelist
3
- Version: 1.0.44
3
+ Version: 1.0.45
4
4
  Summary: Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
5
5
  Keywords: automation,whitelist,acl,security-groups,alibaba-cloud,tencent-cloud,security-tools,security-group-rule
6
6
  Author: qiqilelebaobao
@@ -1,6 +1,6 @@
1
1
  r"""Easy_whitelist is a smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist. The tool is written in Python.
2
2
  """
3
- __version__ = '1.0.44'
3
+ __version__ = '1.0.45'
4
4
  # __author__ = 'qiqileleabaobao <qiqilelebaobao@163.com>'
5
5
 
6
6
  __all__ = []
@@ -7,11 +7,15 @@ import logging
7
7
 
8
8
  from . import url
9
9
 
10
- def get_local_ip_from_url_and_parse(u, patt, ag, proxy=None):
10
+ def get_local_ip_from_url_and_parse(u, patt, ag, if_enable, proxy=None):
11
11
  # 发送GET请求
12
12
  headers = {'user-agent': ag}
13
+
14
+ if not re.search('enable', if_enable, re.IGNORECASE):
15
+ return None
16
+
13
17
  try:
14
- logging.info(f'Starting fetch local ip from {u} with proxy {proxy}')
18
+ logging.info(f'Starting fetch local ip from {u} with proxy "{proxy}"')
15
19
 
16
20
  if proxy:
17
21
  response = requests.get(u, headers=headers, timeout=(3,5),
@@ -20,7 +24,7 @@ def get_local_ip_from_url_and_parse(u, patt, ag, proxy=None):
20
24
  })
21
25
  else:
22
26
  response = requests.get(u, headers=headers, timeout=(3, 5))
23
-
27
+
24
28
  # 获取响应内容
25
29
  respon = response.text
26
30
  l_ip = url.parse_ip_from_response(respon, patt)
@@ -48,7 +52,7 @@ def validate_ip(l_ip):
48
52
  def get_local_ips(proxy=None):
49
53
  ip_list = []
50
54
  for i, u in enumerate(url.detect_url, 1):
51
- l_ip = get_local_ip_from_url_and_parse(u[0], u[1], u[2], proxy)
55
+ l_ip = get_local_ip_from_url_and_parse(u[0], u[1], u[2], u[3], proxy)
52
56
  if l_ip and validate_ip(l_ip):
53
57
  ip_list.append(l_ip)
54
58
  return ip_list
@@ -10,7 +10,7 @@ def parse_ip_from_response(response, patt):
10
10
  return result.group(1)
11
11
 
12
12
  detect_url = [
13
- ['https://ifconfig.me', IFCONFIG_ME_PATTERN, random.choice(curl_user_agent)],
14
- ['http://cip.cc', CIP_CC_PATTERN, random.choice(chrome_user_agent)],
15
- ['https://tool.lu/ip/', TOOL_LU_PATTERN, random.choice(chrome_user_agent)]
13
+ ['https://ifconfig.me', IFCONFIG_ME_PATTERN, random.choice(curl_user_agent), 'enable'],
14
+ ['http://cip.cc', CIP_CC_PATTERN, random.choice(chrome_user_agent), 'DISABLE'],
15
+ ['https://tool.lu/ip/', TOOL_LU_PATTERN, random.choice(chrome_user_agent), 'enable']
16
16
  ]
File without changes