mirror of
https://github.com/anthropics/claude-code.git
synced 2026-05-05 21:52:41 +00:00
Add GitHub API caching to prevent rate limiting
- Create GitHub API caching script that handles authenticated and unauthenticated requests - Update Dockerfile to include the script in the container - Update init-firewall.sh to use cached GitHub API data - Modify devcontainer.json to run cache script before build and mount cache directory 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -27,16 +27,20 @@ iptables -A OUTPUT -o lo -j ACCEPT
|
||||
# Create ipset with CIDR support
|
||||
ipset create allowed-domains hash:net
|
||||
|
||||
# Fetch GitHub meta information and aggregate + add their IP ranges
|
||||
echo "Fetching GitHub IP ranges..."
|
||||
gh_ranges=$(curl -s https://api.github.com/meta)
|
||||
if [ -z "$gh_ranges" ]; then
|
||||
echo "ERROR: Failed to fetch GitHub IP ranges"
|
||||
exit 1
|
||||
fi
|
||||
# Use cached GitHub meta information from mounted volume
|
||||
CACHE_FILE="/github-meta-cache/meta.json"
|
||||
|
||||
if ! echo "$gh_ranges" | jq -e '.web and .api and .git' >/dev/null; then
|
||||
echo "ERROR: GitHub API response missing required fields"
|
||||
echo "Using cached GitHub IP ranges..."
|
||||
if [ -f "${CACHE_FILE}" ]; then
|
||||
gh_ranges=$(cat "${CACHE_FILE}")
|
||||
|
||||
# Verify the cached data is valid
|
||||
if ! echo "$gh_ranges" | jq -e '.web and .api and .git' >/dev/null; then
|
||||
echo "ERROR: Cached GitHub API data is invalid"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "ERROR: No cached GitHub IP ranges found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user