-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-api.openapi.yaml
More file actions
381 lines (379 loc) · 15.6 KB
/
Copy pathnode-api.openapi.yaml
File metadata and controls
381 lines (379 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
openapi: 3.0.3
info:
title: Erebrus Node API v2
version: 2.0.0
description: |
REST API served by every Erebrus VPN node. The only intended caller is the
Erebrus gateway (and node-local tooling); end users never talk to a node
directly. All /api/v2 routes require a gateway-issued, node-scoped PASETO
bearer token except /api/v2/status and /metrics. Drop routes additionally
require X-Erebrus-Node-Key and an exact-purpose token.
When Drop is enabled, CID reads use the authenticated Erebrus gateway-to-node
API. Kubo admin RPC `5001` and the raw Kubo gateway `8080` remain private.
FROZEN (v2.0): additive changes only. See ../../../erebrus-gateway/docs/v2/ws-protocol.md
for the WebSocket control plane.
servers:
- url: http://{host}:9080
variables:
host:
default: localhost
security:
- paseto: []
paths:
/api/v2/status:
get:
summary: Public node status (unauthenticated)
security: []
responses:
"200":
content:
application/json:
schema:
type: object
properties:
version: { type: string, example: "2.0.0" }
region: { type: string, example: "SG" }
zone: { type: string, example: "us-east", description: "Optional placement within region (e.g. east, west)" }
status: { type: string, enum: [online, draining] }
peer_id: { type: string }
did: { type: string, example: "did:erebrus:12D3KooW..." }
capabilities:
$ref: "#/components/schemas/Capabilities"
protocols:
type: array
items: { type: string, enum: [wireguard, vless_reality, hysteria2] }
readiness:
$ref: "#/components/schemas/Readiness"
description: Node identity and advertised protocols. No secrets, no peer data.
/api/v2/stats:
get:
summary: Coarse public stats for the local dashboard (unauthenticated)
security: []
responses:
"200":
content:
application/json:
schema:
type: object
properties:
status: { type: string, enum: [online, draining] }
version: { type: string }
region: { type: string }
zone: { type: string }
protocols: { type: array, items: { type: string } }
total_peers: { type: integer, description: Provisioned peers in the store }
connected_peers: { type: integer, description: WireGuard handshake in the last 3 minutes }
rx_bytes: { type: integer, format: int64 }
tx_bytes: { type: integer, format: int64 }
uptime_sec: { type: integer, format: int64 }
description: Aggregates only — never per-client rows.
/healthz:
get:
summary: Liveness probe (unauthenticated)
security: []
responses:
"200": { description: '{ "status": "ok" }' }
/metrics:
get:
summary: Prometheus metrics (unauthenticated, bind/firewall to taste)
security: []
responses:
"200": { description: Prometheus text exposition format }
/api/v2/drop/status:
get:
summary: Drop health and repository capacity
description: Requires a token with exact purpose `drop_status`.
security:
- dropPurpose: []
nodeKey: []
responses:
"200":
description: Current Drop state
content:
application/json:
schema: { $ref: "#/components/schemas/DropStatus" }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"503": { description: Drop is unavailable }
/api/v2/drop/uploads/{upload_id}:
parameters:
- { name: upload_id, in: path, required: true, schema: { type: string }, description: Gateway-generated idempotency and audit identifier }
put:
summary: Stream an object to Kubo and recursively pin it
description: |
Requires exact purpose `drop_upload`. The body is streamed and limited
while being read; the node does not buffer the complete object. The v1
per-object maximum is 1,000,000,000 bytes.
security:
- dropPurpose: []
nodeKey: []
parameters:
- { name: X-Erebrus-Declared-Size, in: header, required: true, schema: { type: integer, format: int64, minimum: 0, maximum: 1000000000 } }
- { name: X-Erebrus-SHA256, in: header, required: false, schema: { type: string, pattern: "^[0-9A-Fa-f]{64}$" }, description: Optional expected SHA-256 digest }
requestBody:
required: true
content:
application/octet-stream:
schema: { type: string, format: binary }
responses:
"200":
description: Object added and pinned
content:
application/json:
schema:
type: object
required: [cid, size_bytes, pinned]
properties:
cid: { $ref: "#/components/schemas/CID" }
size_bytes: { type: integer, format: int64 }
pinned: { type: boolean, enum: [true] }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"413": { description: Declared or streamed bytes exceed the limit }
"422": { description: Declared size or SHA-256 verification failed }
"507": { description: Drop storage reservation exceeds capacity }
/api/v2/drop/objects/{cid}:
parameters:
- { name: cid, in: path, required: true, schema: { $ref: "#/components/schemas/CID" } }
get:
summary: Stream one Drop object
description: Requires exact purpose `drop_read`. Response bytes are streamed and bounded to the v1 object limit.
security:
- dropPurpose: []
nodeKey: []
responses:
"200":
description: Object bytes
content:
application/octet-stream:
schema: { type: string, format: binary }
"400": { description: Invalid CID }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"413": { description: Kubo stream exceeds the object limit }
"502": { description: Generic Drop operation failure }
/api/v2/drop/pins/{cid}:
parameters:
- { name: cid, in: path, required: true, schema: { $ref: "#/components/schemas/CID" } }
get:
summary: Check recursive pin state
description: Requires exact purpose `drop_pin_check`.
security:
- dropPurpose: []
nodeKey: []
responses:
"200":
description: Pin state
content:
application/json:
schema:
type: object
required: [cid, pinned]
properties:
cid: { $ref: "#/components/schemas/CID" }
pinned: { type: boolean }
"400": { description: Invalid CID }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"502": { description: Generic Drop operation failure }
delete:
summary: Remove a recursive pin
description: Requires exact purpose `drop_unpin`. Absence is treated idempotently.
security:
- dropPurpose: []
nodeKey: []
responses:
"204": { description: Pin absent or removed }
"400": { description: Invalid CID }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"502": { description: Generic Drop operation failure }
/api/v2/drop/webui:
get:
summary: Private Kubo WebUI entry point
description: Requires exact purpose `drop_webui` and DROP_WEBUI_ENABLED on a private node.
security:
- dropPurpose: []
nodeKey: []
responses:
"200": { description: Proxied WebUI response }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"404": { description: Drop WebUI is disabled or unavailable }
"502": { description: Kubo WebUI is unavailable }
/api/v2/drop/webui/{path}:
parameters:
- { name: path, in: path, required: true, schema: { type: string }, description: Kubo WebUI path }
get:
summary: Private Kubo WebUI proxy
description: |
Requires exact purpose `drop_webui` and DROP_WEBUI_ENABLED on a private
node. Authorization, node-key, Origin, and Referer headers are removed
before proxying to Kubo.
security:
- dropPurpose: []
nodeKey: []
responses:
"200": { description: Proxied WebUI response }
"401": { $ref: "#/components/responses/DropUnauthorized" }
"404": { description: Drop WebUI is disabled or unavailable }
"502": { description: Kubo WebUI is unavailable }
/api/v2/peers:
get:
summary: List provisioned peers (ids and metadata only, no credentials)
responses:
"200":
description: Peer list
content:
application/json:
schema:
type: array
items: { $ref: "#/components/schemas/PeerInfo" }
/api/v2/peers/{id}:
parameters:
- { name: id, in: path, required: true, schema: { type: string, format: uuid }, description: Gateway-issued VPN client UUID }
put:
summary: Create or update a peer (idempotent upsert)
description: |
Provisions the peer across ALL protocols atomically: allocates a
WireGuard IP, generates VLESS UUID and Hysteria2 password, applies the
WireGuard peer via wgctrl, and rebuilds sing-box inbounds. Repeating
the call with the same id and public key returns the same bundle
(gateway retries are safe). Returns 409 while the node is draining.
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [name, wg_public_key]
properties:
name: { type: string, maxLength: 64 }
wallet: { type: string, description: Owner wallet address (informational) }
wg_public_key: { type: string, description: Client-generated Curve25519 public key, base64 }
wg_preshared_key: { type: string, description: Optional client-generated PSK, base64 }
expires_at: { type: integer, format: int64, description: Unix seconds; 0 = no expiry }
responses:
"200": { description: Peer upserted, content: { application/json: { schema: { $ref: "#/components/schemas/CredentialBundle" } } } }
"400": { description: Invalid key or body }
"409": { description: Node is draining or subnet exhausted }
delete:
summary: Remove a peer from all protocols
responses:
"204": { description: Peer removed (idempotent — also returned if absent) }
/api/v2/peers/{id}/credentials:
parameters:
- { name: id, in: path, required: true, schema: { type: string, format: uuid } }
get:
summary: Re-fetch the credential bundle for an existing peer
description: |
Same response as PUT. Used by the gateway's authenticated config
re-fetch (replaces the v1 Walrus blob flow). The WireGuard client_conf
contains a placeholder for the private key, which only the end client
ever held.
responses:
"200": { description: Bundle, content: { application/json: { schema: { $ref: "#/components/schemas/CredentialBundle" } } } }
"404": { description: Unknown peer }
components:
securitySchemes:
paseto:
type: http
scheme: bearer
description: Node-scoped PASETO issued by the gateway at node registration.
dropPurpose:
type: http
scheme: bearer
description: Gateway-issued PASETO targeted to this node with the exact Drop route purpose.
nodeKey:
type: apiKey
in: header
name: X-Erebrus-Node-Key
description: Per-node key required in addition to the exact-purpose bearer token.
responses:
DropUnauthorized:
description: Missing/invalid node key or bearer token, including target or exact-purpose mismatch
schemas:
Capabilities:
type: object
properties:
services:
type: object
additionalProperties:
type: string
description: Coarse service states; the `drop` value uses the DropStatus state enum.
drop:
$ref: "#/components/schemas/DropCapability"
DropCapability:
type: object
required: [enabled, accepts_public_uploads, webui_available]
properties:
enabled: { type: boolean }
accepts_public_uploads: { type: boolean }
webui_available: { type: boolean }
DropStatus:
type: object
required: [state, repo_size_bytes, storage_max_bytes, num_objects]
properties:
state: { type: string, enum: [disabled, starting, active, degraded, full, unreachable] }
kubo_version: { type: string, example: "0.42.0" }
repo_size_bytes: { type: integer, format: int64, minimum: 0 }
storage_max_bytes: { type: integer, format: int64, minimum: 0 }
num_objects: { type: integer, format: int64, minimum: 0 }
Readiness:
type: object
required: [ok, checks]
properties:
ok: { type: boolean, description: VPN readiness; optional Drop failures do not change this value }
checks:
type: array
items: { $ref: "#/components/schemas/ReadinessCheck" }
warnings:
type: array
items: { type: string }
ReadinessCheck:
type: object
required: [id, ok]
properties:
id: { type: string }
ok: { type: boolean }
detail: { type: string }
optional: { type: boolean }
CID:
type: string
description: Valid CIDv0 or CIDv1 accepted by go-cid
example: bafkreidy534f3mmy722yr73zat5nd65m22zbbir5vnmytafwu42bnnx4t4
PeerInfo:
type: object
properties:
id: { type: string, format: uuid }
name: { type: string }
wg_allowed_ip: { type: string, example: "10.0.0.7/32" }
enabled: { type: boolean }
created_at: { type: integer, format: int64 }
expires_at: { type: integer, format: int64 }
CredentialBundle:
type: object
description: Everything a client needs for every protocol, in one response.
properties:
id: { type: string, format: uuid }
wireguard:
type: object
properties:
client_conf:
type: string
description: |
Complete wg-quick [Interface]/[Peer] file with the literal
placeholder REPLACE_WITH_PRIVATE_KEY for the client's private
key (the node never sees it).
server_public_key: { type: string }
endpoint: { type: string, example: "203.0.113.10:51820" }
address: { type: string, example: "10.0.0.7/32" }
dns: { type: string, example: "10.0.0.1" }
vless_uri:
type: string
description: vless:// share URI (REALITY, flow=xtls-rprx-vision)
example: "vless://c0a4f1de-...@203.0.113.10:443?security=reality&pbk=...&sid=...&sni=www.microsoft.com&flow=xtls-rprx-vision&type=tcp#erebrus-sg"
hysteria2_uri:
type: string
example: "hysteria2://pw@203.0.113.10:443/?insecure=1&sni=node#erebrus-sg"
singbox_profile:
type: object
description: |
Complete sing-box client config fragment: outbounds for wg
(endpoint), vless and hysteria2, WITHOUT selector/urltest groups —
the gateway injects the "auto"/"stealth" groups before handing the
profile to end clients.