Environment:3641397194 wq Gpt6 Astra Network HTTPS
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Networking, Security |
| Last Updated | 2026-10-26 14:00 GMT |
Overview
HTTPS networking environment for relay API communication, toolbox network tools (DNS, port scan, HTTP crawl), and relay adapter requests with credential isolation and TLS enforcement.
Description
This environment provides the networking layer for the ColdBrew Zero workbench. The relay adapter (`relay-adapter.js`) enforces HTTPS for all remote API calls (HTTP only allowed for `localhost`/`127.0.0.1`/`[::1]` loopback), strips credentials from URLs, and requires `Authorization: Bearer` headers for authentication. The toolbox network module (`network.js`) uses Node.js built-in `http`/`https`/`net`/`dns` modules for DNS resolution, port scanning, and HTTP crawling. All network responses are hashed (SHA-256) and credential headers are redacted before return.
Usage
Use this environment for: RelayAdapter (three-mode relay: preview, OpenAI-compatible, remote), runAgent (AI agent loop submits tasks via the relay adapter), scopeCheck (validates that tool target URLs match the declared origin), and toolbox network tools (DNS query, port scan, HTTP inspect, web crawl, path discovery).
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any (Node.js cross-platform) | Network stack via Node.js built-ins |
| Network | Outbound HTTPS (port 443) | Required for relay API and toolbox web tools |
| DNS | UDP/TCP port 53 | For toolbox DNS resolution tools |
| TLS | Node.js built-in TLS | `rejectUnauthorized` defaults to true |
Dependencies
System Packages
- Node.js `node:http` module
- Node.js `node:https` module
- Node.js `node:net` module (raw TCP for port scanning)
- Node.js `node:dns` module (DNS resolution)
- Node.js `globalThis.fetch` (or custom transport function) for relay adapter
JavaScript Packages
No external networking packages — all HTTP/HTTPS/DNS via Node.js built-ins.
Credentials
- `authToken` — Relay API bearer token (passed via `Authorization: Bearer` header; never included in URLs, status output, or error messages)
- Custom `headers` — Optional additional headers injected into relay requests
Credentials are held in memory only and never included in `status()`, errors, or preview payloads.
Quick Install
# No additional install needed — uses Node.js built-in networking modules
# For the relay adapter, ensure globalThis.fetch is available (Node.js 18+) or provide a transport function
node -e "console.log(typeof globalThis.fetch)"
Code Evidence
HTTPS enforcement from `relay-adapter.js:203-218`:
function validateApiUrl(value, config = {}) {
let parsed;
try { parsed = new URL(value); }
catch { throw new RelayConfigError('API 地址格式无效'); }
if (parsed.username || parsed.password || parsed.search || parsed.hash) {
throw new RelayConfigError('API 地址仅填写协议、主机与路径;凭据请填写在 API Key 字段');
}
const exactLoopback = /^http:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(?::\d{1,5})?(?:\/|$)/i.test(value);
if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && exactLoopback)) {
throw new RelayConfigError('API 地址须使用 HTTPS;HTTP 仅供本机回环测试');
}
return parsed;
}
Network tool request from `network.js:9-22`:
function request(value, options = {}, signal) {
const url = asUrl(value);
const maxBytes = integer(options.maxBytes, 1024 * 1024, 256, 4 * 1024 * 1024, 'maxBytes');
const timeoutMs = integer(options.timeoutMs, 4000, 100, 60000, 'timeoutMs');
// ...
const req = (url.protocol === 'https:' ? https : http).request(url, {
method, headers: { 'user-agent': 'ColdCoffee-OriginalToolbox/1.0', 'accept-encoding': 'identity', ...(options.headers || {}) },
rejectUnauthorized: options.verifyTls !== false,
}, res => { /* ... */ });
}
Credential redaction in transport from `relay-adapter.js:587-595`:
_redact(value) {
let message = typeof value === 'string' ? value : String(value ?? '');
if (this.config.authToken) {
for (const secret of new Set([this.config.authToken, encodeURIComponent(this.config.authToken)])) {
message = message.split(secret).join('[REDACTED]');
}
}
return message;
}
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `API 地址须使用 HTTPS;HTTP 仅供本机回环测试` | Non-HTTPS URL for remote API | Use `https://` or loopback `http://localhost` |
| `API 地址中包含凭据` | Token embedded in URL query/fragment | Move credentials to `authToken` field |
| `冷咖啡 API 请求超时` | Request exceeded `timeoutMs` (default 45000ms) | Increase `timeoutMs` or check network connectivity |
| `中转接口返回重定向` | Server returned 3xx redirect | Configure the final endpoint URL directly |
Compatibility Notes
- Loopback HTTP: HTTP (non-TLS) is permitted only for `localhost`, `127.0.0.1`, or `[::1]` addresses; all other URLs require HTTPS.
- Custom transport: The relay adapter accepts an injectable `transport` function for testing; defaults to `globalThis.fetch`.
- Redirect rejection: Both relay and network tools set `redirect: 'error'` / reject 3xx responses to prevent credential leakage via redirects.
- TLS verification: Network tools default to `rejectUnauthorized: true`; can be disabled via `verifyTls: false` option.