Skip to content

Commit 2fec200

Browse files
authored
Merge pull request #270 from blacklanternsecurity/blasthttp-update
Replace httpx with blasthttp, update workflows
2 parents b46dad0 + 9e2fa0a commit 2fec200

18 files changed

Lines changed: 175 additions & 124 deletions

.github/workflows/daily-update.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ jobs:
1919
contents: write
2020

2121
steps:
22+
- name: Generate app token
23+
id: app-token
24+
uses: actions/create-github-app-token@v1
25+
with:
26+
app-id: ${{ secrets.CLOUDCHECK_APP_ID }}
27+
private-key: ${{ secrets.CLOUDCHECK_APP_PRIVATE_KEY }}
28+
2229
- name: Checkout stable branch
2330
uses: actions/checkout@v6
2431
with:
2532
ref: stable
33+
token: ${{ steps.app-token.outputs.token }}
2634

2735
- name: Set up Python
2836
uses: actions/setup-python@v6

.github/workflows/python-tests.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
18+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1919

2020
steps:
2121
- uses: actions/checkout@v6
@@ -47,8 +47,19 @@ jobs:
4747
runs-on: ubuntu-latest
4848
needs: test
4949
if: github.event_name == 'push' && github.ref == 'refs/heads/stable'
50+
permissions:
51+
contents: write
5052
steps:
53+
- name: Generate app token
54+
id: app-token
55+
uses: actions/create-github-app-token@v1
56+
with:
57+
app-id: ${{ secrets.CLOUDCHECK_APP_ID }}
58+
private-key: ${{ secrets.CLOUDCHECK_APP_PRIVATE_KEY }}
5159
- uses: actions/checkout@v6
60+
with:
61+
fetch-depth: 0
62+
token: ${{ steps.app-token.outputs.token }}
5263
- name: Set up Python
5364
uses: actions/setup-python@v6
5465
with:
@@ -57,10 +68,33 @@ jobs:
5768
uses: dtolnay/rust-toolchain@stable
5869
- name: Set up uv
5970
uses: astral-sh/setup-uv@v7
71+
- name: Get current version
72+
id: get_version
73+
run: |
74+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
75+
echo "VERSION=v${VERSION}" >> $GITHUB_OUTPUT
76+
- name: Check for version change
77+
id: version_check
78+
run: |
79+
git fetch --tags
80+
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "none")
81+
CURRENT="${{ steps.get_version.outputs.VERSION }}"
82+
if [ "$LATEST_TAG" = "$CURRENT" ]; then
83+
echo "changed=false" >> $GITHUB_OUTPUT
84+
else
85+
echo "changed=true" >> $GITHUB_OUTPUT
86+
fi
6087
- name: Build PyPi package
6188
run: uv run maturin build --release --out dist
6289
- name: Publish PyPi package
6390
run: uv run maturin publish --skip-existing --username __token__ --password ${{ secrets.PYPI_TOKEN }}
91+
- name: Tag release
92+
if: steps.version_check.outputs.changed == 'true'
93+
run: |
94+
git config user.name "github-actions[bot]"
95+
git config user.email "github-actions[bot]@users.noreply.github.com"
96+
git tag -a "${{ steps.get_version.outputs.VERSION }}" -m "Release ${{ steps.get_version.outputs.VERSION }}"
97+
git push origin "refs/tags/${{ steps.get_version.outputs.VERSION }}"
6498
linux:
6599
runs-on: ${{ matrix.platform.runner }}
66100
needs: publish

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cloudcheck"
3-
version = "10.0.1"
3+
version = "11.0.0"
44
edition = "2024"
55
description = "CloudCheck is a simple Rust tool to check whether an IP address or hostname belongs to a cloud provider."
66
license = "GPL-3.0"

cloudcheck/helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import ipaddress
22
import os
33
import sys
4-
import httpx
4+
import asyncio
5+
import blasthttp
56
from pathlib import Path
67
from typing import List, Set, Union
78

@@ -204,6 +205,9 @@ def strings_to_cidrs(
204205
}
205206

206207

208+
_client = blasthttp.BlastHTTP()
209+
210+
207211
def request(url, include_api_key=False, browser_headers=False, timeout=60, **kwargs):
208212
global _warned_missing_api_key
209213
headers = kwargs.get("headers", {})
@@ -224,7 +228,8 @@ def request(url, include_api_key=False, browser_headers=False, timeout=60, **kwa
224228
kwargs["headers"] = headers
225229
kwargs["timeout"] = timeout
226230
kwargs.setdefault("follow_redirects", True)
227-
return httpx.get(url, **kwargs)
231+
kwargs.setdefault("verify_certs", True)
232+
return asyncio.run(_client.request(url, **kwargs))
228233

229234

230235
def parse_v2fly_domain_file(file_path: Path) -> Set[str]:

cloudcheck/providers/bunnycdn.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from cloudcheck.providers.base import BaseProvider
2+
from typing import List
3+
4+
5+
class Bunnycdn(BaseProvider):
6+
tags: List[str] = ["cdn"]
7+
short_description: str = "Bunny CDN"
8+
long_description: str = "A global content delivery network and edge platform."
9+
# {"org_id": "ORG-BISD2-RIPE", "org_name": "BUNNYWAY, informacijske storitve d.o.o.", "country": "SI", "asns": [200325]}
10+
asns: List[int] = [200325]
11+
org_ids: List[str] = [
12+
"ORG-BISD2-RIPE",
13+
]

cloudcheck/providers/gabia.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Gabia(BaseProvider):
77
short_description: str = "Gabia (가비아)"
88
long_description: str = "A Korean cloud hosting and infrastructure provider."
99
# {"org_id": "@aut-17589-APNIC", "org_name": null, "country": null, "asns": [17589]}
10+
asns: List[int] = [17589]
1011
org_ids: List[str] = [
1112
"@aut-17589-APNIC",
1213
]

cloudcheck/providers/hostway.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Hostway(BaseProvider):
88
long_description: str = "A Korean cloud hosting and infrastructure provider."
99
# {"org_id": "@aut-9952-APNIC", "org_name": null, "country": null, "asns": [9952]}
1010
# {"asn":9952,"asn_name":"HOSTWAY-AS-KR","org_id":"@aut-9952-APNIC"}
11+
asns: List[int] = [9952]
1112
org_ids: List[str] = [
1213
"@aut-9952-APNIC",
1314
]

cloudcheck/providers/kinx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Kinx(BaseProvider):
99
"A Korean content delivery network and cloud infrastructure provider."
1010
)
1111
# {"org_id": "@aut-9286-APNIC", "org_name": null, "country": null, "asns": [9286,9957,17604]}
12+
asns: List[int] = [9286, 9957, 17604]
1213
org_ids: List[str] = [
1314
"@aut-9286-APNIC",
1415
]

cloudcheck/providers/ktcloud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Ktcloud(BaseProvider):
99
"A Korean cloud computing service provided by KT Corporation."
1010
)
1111
# {"asn":9947,"asn_name":"KTC-AS-KR","country":null,"org":null,"org_id":"@aut-152232-APNIC","rir":null,"subnets":["61.100.71.0/24","61.100.72.0/24"]}
12+
asns: List[int] = [9947]
1213
org_ids: List[str] = [
1314
"@aut-152232-APNIC",
1415
]

cloudcheck/providers/lgtelecom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Lgtelecom(BaseProvider):
88
long_description: str = "A Korean telecommunications company offering CDN services."
99
# {"org_id": "@aut-17853-APNIC", "org_name": null, "country": null, "asns": [17853]}
1010
# {"asn":17853,"asn_name":"LGTELECOM-AS-KR","org_id":"@aut-17853-APNIC"}
11+
asns: List[int] = [17853]
1112
org_ids: List[str] = [
1213
"@aut-17853-APNIC",
1314
]

0 commit comments

Comments
 (0)