Skip to main content

A smart tool that detects the local Internet IP address and automatically updates the local Internet IP address to the cloud security group whitelist.

Project description

EasyWhitelist

PyPI version Python License GitHub stars

EasyWhitelist 是一个自动探测本机公网 IP 地址,并将其更新到云安全组白名单的命令行工具,使用 Python 编写。

EasyWhitelist is a CLI tool that detects the local public IP address and automatically updates cloud security group whitelists. Written in Python.

主要功能 / Features

  • 自动探测本机公网 IP(多源并发,自动去重)
  • 支持腾讯云地址模板(Address Template)和阿里云前缀列表(Prefix List)
  • 区域缓存:将 region 列表和安全组信息本地缓存到 SQLite,加速后续操作
  • 支持通过本地 HTTP 代理访问云 API
  • Auto-detects local public IP via multiple sources concurrently
  • Supports Tencent Cloud Address Templates and Alibaba Cloud Prefix Lists
  • Caches region / security-group info in local SQLite for faster subsequent runs
  • Supports routing cloud API calls through a local HTTP proxy

适用场景 / Applicable Scenarios

  • 场景一:不知道如何探测本机的公网IP的用户,通过本工具自动探测公网 IP,并添加云安全组白名单

  • 场景二:IP 地址因为 NAT 环境经常变化,包括家庭环境或者公司无固定出口 IP 的宽带环境,需要安全的使用云环境资源

  • 场景三:测试场景,频繁变换客户端环境,需要安全的使用云环境资源

  • Scene 1: Users who do not know how to detect the public IP of their local machine can use this tool to automatically detect the public IP and add it to the cloud security group whitelist

  • Scene 2: IP addresses often change due to NAT environments, including home environments or broadband environments without fixed export IPs in companies, which require safe use of cloud environment resources

  • Scene 3: Test scenarios, frequent changes in client environments, which require safe use of cloud environment resources

安装指南 Installation Guide

需要 Python 3.8+ 环境。Python 3.8+ is required.

pip install EasyWhitelist

凭据配置 Credentials

工具通过环境变量读取云厂商密钥,无需配置文件。 Credentials are read from environment variables; no config file is needed.

腾讯云 Tencent Cloud

export TENCENTCLOUD_SECRET_ID=your_secret_id
export TENCENTCLOUD_SECRET_KEY=your_secret_key

阿里云 Alibaba Cloud

export ALIBABA_CLOUD_ACCESS_KEY_ID=your_access_key_id
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=your_access_key_secret

使用说明 Basic Usage

ew [-t | -a] [-p PORT] [-v] <init | list | set> [target_id]

选项 Options

参数 说明
-t, --tencent 使用腾讯云(默认) / Use Tencent Cloud (default)
-a, --alibaba 使用阿里云 / Use Alibaba Cloud
-p PORT, --proxy PORT 本地 HTTP 代理端口(1-65535)/ Local HTTP proxy port
-v, --verbose 增加日志详细程度 / Increase log verbosity

操作 Actions

命令 说明
init [target_id] 初始化:绑定地址模板或前缀列表到安全组规则 / Initialize and bind template/prefix to security group
list 列出已有模板或前缀列表,交互式选择 / List and interactively select existing template/prefix
set 探测当前公网 IP 并更新所有已绑定的模板 / Detect current public IP and update all bound templates

示例 Examples

# 腾讯云:初始化并绑定安全组规则
ew init sg-xxxxxxxx

# 腾讯云:查看地址模板列表并选择
ew list

# 腾讯云:更新所有已绑定模板为当前公网 IP
ew set

# 阿里云:初始化并绑定前缀列表
ew -a init sg-xxxxxxxx

# 阿里云:更新前缀列表
ew -a set

# 通过本地代理端口 7890 访问云 API
ew -p 7890 set

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easywhitelist-1.1.1.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easywhitelist-1.1.1-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

File details

Details for the file easywhitelist-1.1.1.tar.gz.

File metadata

  • Download URL: easywhitelist-1.1.1.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for easywhitelist-1.1.1.tar.gz
Algorithm Hash digest
SHA256 774caee09d53fedd0202861484960afbfc4dc33f2bcfbf6a2badc1a428df0dc8
MD5 53635f0ae5755b1fb19dfbde71f9a476
BLAKE2b-256 e87721dd69ba58c0ee93724c937c48756905bc1ee9a12b7f1643164113ef63f1

See more details on using hashes here.

File details

Details for the file easywhitelist-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: easywhitelist-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for easywhitelist-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8db7819cf8808d9e2f24654fe8affcb7785f63a671154ff4b7f9eddf2650f5
MD5 886f539bc00c9a384e8a91b8d5780085
BLAKE2b-256 ceb6a458260737089726c10754e90664b42ed93bdf0ee7344edca59dd49cb9af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page