diff --git a/apps/blockchain-node/src/aitbc_chain/app.py b/apps/blockchain-node/src/aitbc_chain/app.py index 2a67cb1b..9c12a33d 100755 --- a/apps/blockchain-node/src/aitbc_chain/app.py +++ b/apps/blockchain-node/src/aitbc_chain/app.py @@ -35,7 +35,8 @@ class RateLimitMiddleware(BaseHTTPMiddleware): async def dispatch(self, request: Request, call_next): client_ip = request.client.host if request.client else "unknown" # Bypass rate limiting for localhost and internal network (sync/health internal traffic) - if client_ip in {"127.0.0.1", "::1", "10.1.223.93", "10.1.223.40"}: + trusted_ips = os.getenv("AITBC_TRUSTED_IPS", "127.0.0.1,::1").split(",") + if client_ip in trusted_ips: return await call_next(request) now = time.time() # Clean old entries diff --git a/apps/blockchain-node/src/aitbc_chain/sync_cli.py b/apps/blockchain-node/src/aitbc_chain/sync_cli.py index 4ea5299f..df137f27 100644 --- a/apps/blockchain-node/src/aitbc_chain/sync_cli.py +++ b/apps/blockchain-node/src/aitbc_chain/sync_cli.py @@ -6,6 +6,7 @@ Usage: python -m aitbc_chain.sync_cli --source http://10.1.223.40:8006 [--batch- import argparse import asyncio +import os import sys from pathlib import Path @@ -19,8 +20,8 @@ from aitbc_chain.sync import ChainSync async def main() -> None: parser = argparse.ArgumentParser(description="Bulk import blocks from a leader to catch up quickly") - parser.add_argument("--source", default="http://10.1.223.40:8006", help="Source RPC URL") - parser.add_argument("--import-url", default="http://127.0.0.1:8006", help="Local RPC URL for import") + parser.add_argument("--source", default=os.getenv("AITBC_SYNC_SOURCE", "http://127.0.0.1:8006"), help="Source RPC URL") + parser.add_argument("--import-url", default=os.getenv("AITBC_SYNC_IMPORT_URL", "http://127.0.0.1:8006"), help="Local RPC URL for import") parser.add_argument("--batch-size", type=int, default=100, help="Blocks per batch") parser.add_argument("--poll-interval", type=float, default=0.2, help="Seconds between batches") args = parser.parse_args() diff --git a/apps/coordinator-api/src/app/routers/client.py b/apps/coordinator-api/src/app/routers/client.py index cc5af88f..d9432c24 100755 --- a/apps/coordinator-api/src/app/routers/client.py +++ b/apps/coordinator-api/src/app/routers/client.py @@ -230,7 +230,7 @@ async def get_blocks( client = AITBCHTTPClient(timeout=5.0) try: blocks_data = client.get( - "http://10.1.223.93:8082/rpc/blocks-range", params={"start": offset, "end": offset + limit} + f"{settings.blockchain_rpc_url}/rpc/blocks-range", params={"start": offset, "end": offset + limit} ) return { "blocks": blocks_data.get("blocks", []), diff --git a/cli/aitbc_cli.py b/cli/aitbc_cli.py index e3630645..9a994111 100755 --- a/cli/aitbc_cli.py +++ b/cli/aitbc_cli.py @@ -2849,7 +2849,9 @@ def legacy_main(): elif args.network_action == "peers": print("Network peers:") print(" - genesis (localhost:8006) - Connected") - print(" - aitbc1 (10.1.223.40:8007) - Connected") + follower_host = os.getenv("AITBC_FOLLOWER_HOST", "aitbc1") + follower_port = os.getenv("AITBC_FOLLOWER_PORT", "8007") + print(f" - {follower_host} ({follower_host}:{follower_port}) - Connected") elif args.network_action == "sync": if args.status: print("Network sync status:") diff --git a/dev/scripts/dev_heartbeat.py b/dev/scripts/dev_heartbeat.py index 7e81fcdf..fd5fe427 100755 --- a/dev/scripts/dev_heartbeat.py +++ b/dev/scripts/dev_heartbeat.py @@ -14,8 +14,8 @@ REPO_ROOT = Path("/opt/aitbc") LOGS_DIR = REPO_ROOT / "logs" # AITBC blockchain config -LOCAL_RPC = "http://localhost:8006" -GENESIS_RPC = "http://10.1.223.93:8006" +LOCAL_RPC = os.getenv("AITBC_LOCAL_RPC", "http://localhost:8006") +GENESIS_RPC = os.getenv("AITBC_GENESIS_RPC", "http://localhost:8006") MAX_HEIGHT_DIFF = 10 # acceptable block height difference between nodes def sh(cmd, cwd=REPO_ROOT):