sandcovery 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/sandcovery-docker.mjs +1 -1
- package/dist/cli/sandcovery-kubectl.mjs +1 -1
- package/dist/{handlers-U3pqRNro.mjs → handlers-CpLa3dvg.mjs} +349 -92
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{port-forwarder-Du1VlKxg.mjs → port-forwarder-DvSPr-Tg.mjs} +313 -45
- package/dist/{src-lrpT0LG_.mjs → src-BqfeIyqj.mjs} +6 -1
- package/dist/{start-Dg7sRQ28.mjs → start-D1LPu-aN.mjs} +3 -3
- package/dist/{types-C7lGEXT5.d.mts → types-C4amb2QE.d.mts} +3 -1
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as FileList,
|
|
1
|
+
import { $ as FileList, An as XAccountStatus, B as DetachedExec, C as CiJob, Cn as UsageShareList, Ct as PortPreview, Dt as ProblemReportRequest, Ft as ProviderCatalog, I as CredentialFields, J as ExecEvent, K as EstimateList, L as CreditCheckout, Lt as ProviderCredential, M as CreateSandboxRequest, Mt as Provider, N as CreateUsageShareRequest, Nt as ProviderBoard, Ot as Process, P as CreatedKey, Pt as ProviderBoardEntry, R as CreditPurchaseRequest, Rt as ProviderCredentialList, S as CiInstallationList, T as CiJobList, Tn as UsageTotals, V as DetachedExecRequest, X as ExecResult, Y as ExecRequest, Z as FileEntry, Zt as Sandbox, _n as UpdateKeyRequest, c as AutoTopUpRequest, en as SandboxList, fn as Stats, ht as MonthlyCostList, i as ActivityList, in as SharedUsage, j as CreateKeyRequest, jn as XPostRequest, kn as XAccountLink, kt as ProcessRequest, o as AutoTopUp, pt as LiveUsage, q as EstimateRequest, s as AutoTopUpChange, sn as Snapshot, st as Key, tn as SandboxStatus, u as Billing, ut as KeyList, vn as Usage, vt as Offer, wt as Pricing, xn as UsageShare } from "./types-C4amb2QE.mjs";
|
|
2
2
|
interface ProcessExit {
|
|
3
3
|
readonly code: number;
|
|
4
4
|
readonly signal: string | null;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Sandcovery } from "./src-
|
|
1
|
+
export { t as Sandcovery } from "./src-BqfeIyqj.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bn as TaggedError, Br as isString, Ct as fail, E as decodeUnknownSync, En as ClockRef, Hn as seconds, Ir as hasProperty, Jn as isSuccess, O as fromJsonString, Qt as tapError, Tt as flatMap, Un as toMillis, Ut as retry, Vn as millis, Xt as sync, Yn as try_, Yt as suspend, _ as String$1, an as void_, ar as getOrThrowWith, cr as isSome, g as Record, gt as catchDefect, h as Number$1, kn as currentTimeMillis$1, ln as spaced, lt as acquireUseRelease, m as NullOr, n as Boolean, rr as getOrElse, sr as isNone, t as ArraySchema, u as Literals, un as upTo, ur as map, v as Struct, vt as catchTag, w as decodeUnknownOption, xt as die } from "./Schema-CoX0a2_o.mjs";
|
|
2
|
-
import { A as NO_MARKUP_TERMS, B as DEFAULT_SLUG, C as AUTO_TOP_UP_THRESHOLD_MIN_MICRO_USD, E as CREDIT_PURCHASE_MIN_MICRO_USD, F as Unauthorized, H as Forbidden, I as NotFound, P as Unsupported, S as AUTO_TOP_UP_THRESHOLD_MAX_MICRO_USD, T as CREDIT_PURCHASE_MAX_MICRO_USD, U as Conflict, V as ProviderSort, _ as KeyKind, h as SANDCOVERY_X_HANDLE, k as MICRO_USD_PER_DOLLAR, l as MONTH_TEXT, t as Sandcovery, v as SpendLimit, w as CARD_FEE_TERMS, z as SandboxStatus } from "./src-
|
|
2
|
+
import { A as NO_MARKUP_TERMS, B as DEFAULT_SLUG, C as AUTO_TOP_UP_THRESHOLD_MIN_MICRO_USD, E as CREDIT_PURCHASE_MIN_MICRO_USD, F as Unauthorized, H as Forbidden, I as NotFound, P as Unsupported, S as AUTO_TOP_UP_THRESHOLD_MAX_MICRO_USD, T as CREDIT_PURCHASE_MAX_MICRO_USD, U as Conflict, V as ProviderSort, _ as KeyKind, h as SANDCOVERY_X_HANDLE, k as MICRO_USD_PER_DOLLAR, l as MONTH_TEXT, t as Sandcovery, v as SpendLimit, w as CARD_FEE_TERMS, z as SandboxStatus } from "./src-BqfeIyqj.mjs";
|
|
3
3
|
import { WebSocket } from "node:http";
|
|
4
4
|
import net from "node:net";
|
|
5
5
|
import readline from "node:readline";
|
|
@@ -10,6 +10,7 @@ import fs from "node:fs";
|
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { text } from "node:stream/consumers";
|
|
12
12
|
import os from "node:os";
|
|
13
|
+
import dgram from "node:dgram";
|
|
13
14
|
// ../../node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Clock.js
|
|
14
15
|
/**
|
|
15
16
|
* Context reference for the active time service in the environment.
|
|
@@ -1123,7 +1124,7 @@ const withFileLock = ({ bin, file, work }) => {
|
|
|
1123
1124
|
}), () => work, (own) => removeIf(lock, sameAs(own)));
|
|
1124
1125
|
};
|
|
1125
1126
|
// package.json
|
|
1126
|
-
var version = "0.6.
|
|
1127
|
+
var version = "0.6.2";
|
|
1127
1128
|
// ../format/src/display.ts
|
|
1128
1129
|
const LOCALE = "en-US";
|
|
1129
1130
|
const UTC = "UTC";
|
|
@@ -1165,6 +1166,15 @@ const monthName = new Intl.DateTimeFormat(LOCALE, {
|
|
|
1165
1166
|
timeZone: UTC
|
|
1166
1167
|
});
|
|
1167
1168
|
Array.from({ length: 12 }, (_, month) => monthName.format(Date.UTC(2e3, month)));
|
|
1169
|
+
new Intl.DateTimeFormat(LOCALE, {
|
|
1170
|
+
day: "numeric",
|
|
1171
|
+
hour: "2-digit",
|
|
1172
|
+
hourCycle: "h23",
|
|
1173
|
+
minute: "2-digit",
|
|
1174
|
+
month: "short",
|
|
1175
|
+
timeZone: "Asia/Seoul",
|
|
1176
|
+
year: "numeric"
|
|
1177
|
+
});
|
|
1168
1178
|
new Intl.DateTimeFormat(LOCALE, {
|
|
1169
1179
|
day: "numeric",
|
|
1170
1180
|
hour: "numeric",
|
|
@@ -2016,8 +2026,9 @@ const docker = {
|
|
|
2016
2026
|
notes: [
|
|
2017
2027
|
"Runs the Docker CLI in a sandbox with every word after docker, streams its stdout and stderr to this terminal's, and exits with its exit code.",
|
|
2018
2028
|
"The first command starts a sandbox on a provider that runs Docker, as Sandcovery CI runners do, and later commands reuse it until it ends at its TTL, so images, containers, and volumes carry over between commands. sandcovery sandboxes destroy ends it sooner.",
|
|
2019
|
-
"Before docker runs, the command copies the local files it reads into the sandbox at the same absolute paths, up to 100 MiB packed, and runs docker in the same working directory there, so relative and absolute paths resolve as they do here. Those files are the build context of build and bake without what .dockerignore leaves out, the files of a build's -f, --build-context, and --secret, the bind mount sources and env files of run and create, and the file that cp, load -i, or import reads.",
|
|
2020
|
-
"
|
|
2029
|
+
"Before docker runs, the command copies the local files it reads into the sandbox at the same absolute paths, up to 100 MiB packed, and runs docker in the same working directory there, so relative and absolute paths resolve as they do here. Those files are the build context of build and bake without what .dockerignore leaves out, the files of a build's -f, --build-context, and --secret, the bind mount sources and env files of run and create, the env files of exec, the files that BUILDX_BAKE_FILE and EXPERIMENTAL_BUILDKIT_SOURCE_POLICY name, and the file that cp, load -i, or import reads.",
|
|
2030
|
+
"The variables docker reads come from this computer's environment: a name given to -e or --env with no value on run, create, or exec, a name alone on a line of their --env-file, a name given to build --build-arg with no value, the variable an env --secret reads, and docker's own CLI, Build, and Compose variables, such as DOCKER_DEFAULT_PLATFORM. A name unset here stays unset in the container. The command sends the sandbox only those names and values, and never a variable that picks a daemon, context, builder, or proxy, or names a local config, credential, or certificate path, such as DOCKER_HOST, DOCKER_CONTEXT, DOCKER_CONFIG, or HTTP_PROXY, even one the command names, since the sandbox runs its own Docker daemon.",
|
|
2031
|
+
"compose copies its Compose files and env files and, for commands that build or start containers, each build context and each bind-mounted file or directory. ps, logs, down, and other commands that only read the project copy only the Compose files and env files. Variables in Compose files come from this shell first, then from .env, --env-file, or COMPOSE_ENV_FILES, as with docker compose, and the command sends the sandbox only the shell variables the Compose files and env files name. ~ in a Compose file names the home folder of the sandbox.",
|
|
2021
2032
|
"Only paths under your home folder or the working directory are copied, a symlink arrives as the link itself, and a path through a symlinked folder fails. What containers wrote stays in the sandbox and never comes back here, and a file deleted here since the last copy is deleted there.",
|
|
2022
2033
|
"When stdin is not a terminal and docker reads it, as with -i on run or exec without -d, start -i, login --password-stdin, load, import -, build -, or cp -, the command streams stdin to docker as it reads it.",
|
|
2023
2034
|
"When stdout is not a terminal and docker writes an archive there, as with save or export without -o, cp to -, or build -o -, the archive arrives byte for byte. save and export without -o refuse a terminal, as docker does.",
|
|
@@ -3233,6 +3244,10 @@ const billing = {
|
|
|
3233
3244
|
name: "billing.plan",
|
|
3234
3245
|
type: "\"free\" | \"pro\" | \"enterprise\""
|
|
3235
3246
|
},
|
|
3247
|
+
{
|
|
3248
|
+
name: "billing.plan_billers",
|
|
3249
|
+
type: "array"
|
|
3250
|
+
},
|
|
3236
3251
|
{
|
|
3237
3252
|
name: "billing.credit_balance_micro_usd",
|
|
3238
3253
|
type: "number"
|
|
@@ -4440,6 +4455,7 @@ const RELAY_TOKEN_HEADER = "x-sandcovery-relay-token";
|
|
|
4440
4455
|
const RELAY_SOURCE = String.raw`import base64
|
|
4441
4456
|
import hashlib
|
|
4442
4457
|
import hmac
|
|
4458
|
+
import ipaddress
|
|
4443
4459
|
import json
|
|
4444
4460
|
import os
|
|
4445
4461
|
import socket
|
|
@@ -4451,6 +4467,7 @@ GUID = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
|
|
4451
4467
|
HEADER_LIMIT = 16384
|
|
4452
4468
|
CHUNK = 65536
|
|
4453
4469
|
KEEPALIVE_SECONDS = 30
|
|
4470
|
+
POLL_SECONDS = 1
|
|
4454
4471
|
TEXT, BINARY, CLOSE, PING, PONG = 1, 2, 8, 9, 10
|
|
4455
4472
|
EVENTS = [
|
|
4456
4473
|
"docker", "events", "--format", "{{.Actor.ID}}",
|
|
@@ -4458,6 +4475,14 @@ EVENTS = [
|
|
|
4458
4475
|
"--filter", "event=start",
|
|
4459
4476
|
"--filter", "event=die",
|
|
4460
4477
|
]
|
|
4478
|
+
INSPECT = "{{.Id}} {{.HostConfig.NetworkMode}} {{json .NetworkSettings.Ports}}"
|
|
4479
|
+
PROTOCOLS = {"tcp": ("0A", socket.SOCK_STREAM), "udp": ("07", socket.SOCK_DGRAM)}
|
|
4480
|
+
SERVED = {
|
|
4481
|
+
"0.0.0.0": ("0.0.0.0",),
|
|
4482
|
+
"127.0.0.1": ("127.0.0.1",),
|
|
4483
|
+
"::": ("::", "0.0.0.0"),
|
|
4484
|
+
"::1": ("::1",),
|
|
4485
|
+
}
|
|
4461
4486
|
|
|
4462
4487
|
|
|
4463
4488
|
def shut(sock, how=socket.SHUT_RDWR):
|
|
@@ -4591,29 +4616,159 @@ def pipe(peer, upstream):
|
|
|
4591
4616
|
pass
|
|
4592
4617
|
|
|
4593
4618
|
|
|
4594
|
-
def
|
|
4619
|
+
def send_datagrams(peer, upstream, finished):
|
|
4620
|
+
try:
|
|
4621
|
+
while True:
|
|
4622
|
+
try:
|
|
4623
|
+
data = upstream.recv(CHUNK)
|
|
4624
|
+
except ConnectionRefusedError:
|
|
4625
|
+
continue
|
|
4626
|
+
if finished.is_set():
|
|
4627
|
+
return
|
|
4628
|
+
peer.send(BINARY, data)
|
|
4629
|
+
except OSError:
|
|
4630
|
+
shut(peer.conn)
|
|
4631
|
+
|
|
4632
|
+
|
|
4633
|
+
def datagrams(peer, upstream):
|
|
4634
|
+
finished = threading.Event()
|
|
4635
|
+
with upstream:
|
|
4636
|
+
threading.Thread(
|
|
4637
|
+
target=send_datagrams, args=(peer, upstream, finished), daemon=True
|
|
4638
|
+
).start()
|
|
4639
|
+
try:
|
|
4640
|
+
while True:
|
|
4641
|
+
opcode, payload = peer.message()
|
|
4642
|
+
if opcode == CLOSE:
|
|
4643
|
+
return
|
|
4644
|
+
try:
|
|
4645
|
+
upstream.send(payload)
|
|
4646
|
+
except ConnectionRefusedError:
|
|
4647
|
+
pass
|
|
4648
|
+
finally:
|
|
4649
|
+
finished.set()
|
|
4650
|
+
shut(upstream)
|
|
4651
|
+
try:
|
|
4652
|
+
peer.send(CLOSE)
|
|
4653
|
+
except OSError:
|
|
4654
|
+
pass
|
|
4655
|
+
|
|
4656
|
+
|
|
4657
|
+
def sockets(kind):
|
|
4658
|
+
found = []
|
|
4659
|
+
for table in (kind, kind + "6"):
|
|
4660
|
+
try:
|
|
4661
|
+
with open("/proc/net/" + table) as file:
|
|
4662
|
+
rows = file.read().splitlines()[1:]
|
|
4663
|
+
except OSError:
|
|
4664
|
+
continue
|
|
4665
|
+
for row in rows:
|
|
4666
|
+
fields = row.split()
|
|
4667
|
+
if fields[3] != PROTOCOLS[kind][0]:
|
|
4668
|
+
continue
|
|
4669
|
+
hexed, port = fields[1].split(":")
|
|
4670
|
+
address = ipaddress.ip_address(
|
|
4671
|
+
b"".join(
|
|
4672
|
+
int(hexed[at:at + 8], 16).to_bytes(4, sys.byteorder)
|
|
4673
|
+
for at in range(0, len(hexed), 8)
|
|
4674
|
+
)
|
|
4675
|
+
)
|
|
4676
|
+
mapped = getattr(address, "ipv4_mapped", None)
|
|
4677
|
+
shown = str(address if mapped is None else mapped)
|
|
4678
|
+
found.append((shown, int(port, 16), "socket:[" + fields[9] + "]"))
|
|
4679
|
+
return found
|
|
4680
|
+
|
|
4681
|
+
|
|
4682
|
+
def dialed(kind, number):
|
|
4683
|
+
bound = {address for address, port, _ in sockets(kind) if port == number}
|
|
4684
|
+
only_ipv6 = bound & {"::", "::1"} and not bound & {"0.0.0.0", "127.0.0.1"}
|
|
4685
|
+
for address in ("::1", "127.0.0.1") if only_ipv6 else ("127.0.0.1", "::1"):
|
|
4686
|
+
family = socket.AF_INET6 if ":" in address else socket.AF_INET
|
|
4687
|
+
try:
|
|
4688
|
+
upstream = socket.socket(family, PROTOCOLS[kind][1])
|
|
4689
|
+
except OSError:
|
|
4690
|
+
continue
|
|
4691
|
+
try:
|
|
4692
|
+
upstream.connect((address, number))
|
|
4693
|
+
except OSError:
|
|
4694
|
+
upstream.close()
|
|
4695
|
+
continue
|
|
4696
|
+
return upstream
|
|
4697
|
+
return None
|
|
4698
|
+
|
|
4699
|
+
|
|
4700
|
+
def owned(hosted):
|
|
4701
|
+
links = set()
|
|
4702
|
+
for name in os.listdir("/proc"):
|
|
4703
|
+
if not name.isdigit():
|
|
4704
|
+
continue
|
|
4705
|
+
try:
|
|
4706
|
+
with open("/proc/" + name + "/cgroup") as file:
|
|
4707
|
+
groups = file.read()
|
|
4708
|
+
inside = any(ident in groups for ident in hosted)
|
|
4709
|
+
descriptors = os.listdir("/proc/" + name + "/fd") if inside else []
|
|
4710
|
+
except OSError:
|
|
4711
|
+
continue
|
|
4712
|
+
for descriptor in descriptors:
|
|
4713
|
+
try:
|
|
4714
|
+
links.add(os.readlink("/proc/" + name + "/fd/" + descriptor))
|
|
4715
|
+
except OSError:
|
|
4716
|
+
pass
|
|
4717
|
+
return links
|
|
4718
|
+
|
|
4719
|
+
|
|
4720
|
+
def listening(hosted):
|
|
4721
|
+
if not hosted:
|
|
4722
|
+
return []
|
|
4723
|
+
links = owned(hosted)
|
|
4724
|
+
found = {
|
|
4725
|
+
(host, port, kind)
|
|
4726
|
+
for kind in PROTOCOLS
|
|
4727
|
+
for address, port, link in sockets(kind)
|
|
4728
|
+
if link in links
|
|
4729
|
+
for host in SERVED.get(address, ())
|
|
4730
|
+
}
|
|
4731
|
+
return [
|
|
4732
|
+
{"host": host, "port": port, "protocol": kind}
|
|
4733
|
+
for host, port, kind in sorted(found)
|
|
4734
|
+
]
|
|
4735
|
+
|
|
4736
|
+
|
|
4737
|
+
def containers():
|
|
4595
4738
|
ids = subprocess.run(
|
|
4596
4739
|
["docker", "ps", "--quiet", "--no-trunc"], capture_output=True, text=True
|
|
4597
4740
|
).stdout.split()
|
|
4598
4741
|
if not ids:
|
|
4599
|
-
return "[]"
|
|
4742
|
+
return "[]", []
|
|
4600
4743
|
shown = subprocess.run(
|
|
4601
|
-
["docker", "inspect", "--format",
|
|
4744
|
+
["docker", "inspect", "--format", INSPECT, *ids],
|
|
4602
4745
|
capture_output=True,
|
|
4603
4746
|
text=True,
|
|
4604
4747
|
).stdout
|
|
4605
|
-
|
|
4748
|
+
rows = [row for row in (line.split(" ", 2) for line in shown.splitlines()) if len(row) == 3]
|
|
4749
|
+
ports = "[" + ",".join(row[2] for row in rows) + "]"
|
|
4750
|
+
return ports, [row[0] for row in rows if row[1] == "host"]
|
|
4606
4751
|
|
|
4607
4752
|
|
|
4608
4753
|
def events(peer, key):
|
|
4609
4754
|
accept(peer, key)
|
|
4610
4755
|
lock = threading.Lock()
|
|
4756
|
+
state = {"hosted": [], "listening": [], "ports": "[]"}
|
|
4611
4757
|
watcher = subprocess.Popen(EVENTS, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
|
4612
4758
|
|
|
4759
|
+
def send(tag):
|
|
4760
|
+
shown = (
|
|
4761
|
+
'{"listening":' + json.dumps(state["listening"])
|
|
4762
|
+
+ ',"ports":' + state["ports"]
|
|
4763
|
+
+ ',"tag":' + json.dumps(tag) + "}"
|
|
4764
|
+
)
|
|
4765
|
+
peer.send(TEXT, shown.encode())
|
|
4766
|
+
|
|
4613
4767
|
def snapshot(tag=None):
|
|
4614
4768
|
with lock:
|
|
4615
|
-
|
|
4616
|
-
|
|
4769
|
+
state["ports"], state["hosted"] = containers()
|
|
4770
|
+
state["listening"] = listening(state["hosted"])
|
|
4771
|
+
send(tag)
|
|
4617
4772
|
|
|
4618
4773
|
def watch():
|
|
4619
4774
|
try:
|
|
@@ -4623,8 +4778,20 @@ def events(peer, key):
|
|
|
4623
4778
|
pass
|
|
4624
4779
|
shut(peer.conn)
|
|
4625
4780
|
|
|
4781
|
+
def poll():
|
|
4782
|
+
try:
|
|
4783
|
+
while not peer.done.wait(POLL_SECONDS):
|
|
4784
|
+
with lock:
|
|
4785
|
+
found = listening(state["hosted"])
|
|
4786
|
+
if found != state["listening"]:
|
|
4787
|
+
state["listening"] = found
|
|
4788
|
+
send(None)
|
|
4789
|
+
except OSError:
|
|
4790
|
+
shut(peer.conn)
|
|
4791
|
+
|
|
4626
4792
|
try:
|
|
4627
4793
|
threading.Thread(target=watch, daemon=True).start()
|
|
4794
|
+
threading.Thread(target=poll, daemon=True).start()
|
|
4628
4795
|
snapshot()
|
|
4629
4796
|
while True:
|
|
4630
4797
|
opcode, payload = peer.message()
|
|
@@ -4655,16 +4822,17 @@ def handle(conn, token):
|
|
|
4655
4822
|
target = request[1].split("?")[0]
|
|
4656
4823
|
if target.endswith("/events"):
|
|
4657
4824
|
return events(peer, key)
|
|
4658
|
-
|
|
4659
|
-
|
|
4825
|
+
parts = target.rsplit("/", 2)
|
|
4826
|
+
kind, digits = parts[1:] if len(parts) == 3 else ("", "")
|
|
4827
|
+
known = kind in PROTOCOLS and digits.isascii() and digits.isdigit()
|
|
4828
|
+
number = int(digits) if known else 0
|
|
4660
4829
|
if not 0 < number < 65536:
|
|
4661
4830
|
return refuse(peer, "404 Not Found")
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
except OSError:
|
|
4831
|
+
upstream = dialed(kind, number)
|
|
4832
|
+
if upstream is None:
|
|
4665
4833
|
return refuse(peer, "502 Bad Gateway")
|
|
4666
4834
|
accept(peer, key)
|
|
4667
|
-
pipe(peer, upstream)
|
|
4835
|
+
(pipe if kind == "tcp" else datagrams)(peer, upstream)
|
|
4668
4836
|
except (EOFError, OSError, ValueError):
|
|
4669
4837
|
pass
|
|
4670
4838
|
finally:
|
|
@@ -4712,11 +4880,18 @@ const RETRY_MS = [
|
|
|
4712
4880
|
1e4,
|
|
4713
4881
|
3e4
|
|
4714
4882
|
];
|
|
4883
|
+
const UDP_IDLE_MS = 9e4;
|
|
4884
|
+
const QUEUED_DATAGRAMS = 256;
|
|
4715
4885
|
const ANY_IPV4 = "0.0.0.0";
|
|
4716
4886
|
const HIGHEST_PORT = 65535;
|
|
4717
|
-
const
|
|
4887
|
+
const PROTOCOLS = ["tcp", "udp"];
|
|
4888
|
+
const PublishedSchema = Struct({
|
|
4718
4889
|
host: String$1,
|
|
4719
4890
|
port: Number$1,
|
|
4891
|
+
protocol: Literals(PROTOCOLS)
|
|
4892
|
+
});
|
|
4893
|
+
const UnforwardedSchema = Struct({
|
|
4894
|
+
...PublishedSchema.fields,
|
|
4720
4895
|
reason: Literals(["busy", "denied"])
|
|
4721
4896
|
});
|
|
4722
4897
|
const decodeRequest = decodeUnknownOption(fromJsonString(Struct({
|
|
@@ -4731,6 +4906,7 @@ const decodeRequest = decodeUnknownOption(fromJsonString(Struct({
|
|
|
4731
4906
|
})));
|
|
4732
4907
|
const decodeReply = decodeUnknownOption(fromJsonString(Struct({ unforwarded: ArraySchema(UnforwardedSchema) })));
|
|
4733
4908
|
const SnapshotSchema = Struct({
|
|
4909
|
+
listening: ArraySchema(PublishedSchema),
|
|
4734
4910
|
ports: ArraySchema(NullOr(Record(String$1, NullOr(ArraySchema(Struct({
|
|
4735
4911
|
HostIp: String$1,
|
|
4736
4912
|
HostPort: String$1
|
|
@@ -4738,16 +4914,32 @@ const SnapshotSchema = Struct({
|
|
|
4738
4914
|
tag: NullOr(String$1)
|
|
4739
4915
|
});
|
|
4740
4916
|
const decodeSnapshot = decodeUnknownOption(fromJsonString(SnapshotSchema));
|
|
4741
|
-
const keyOf = ({ host, port }) => `${host} ${String(port)}`;
|
|
4917
|
+
const keyOf = ({ host, port, protocol }) => `${protocol} ${host} ${String(port)}`;
|
|
4742
4918
|
const isPort = (port) => Number.isInteger(port) && port > 0 && port <= HIGHEST_PORT;
|
|
4743
|
-
const
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
port
|
|
4748
|
-
|
|
4749
|
-
|
|
4919
|
+
const protocolOf = (target) => PROTOCOLS.find((protocol) => target.endsWith(`/${protocol}`));
|
|
4920
|
+
const publishedIn = (ports) => ports.flatMap((container) => Object.entries(container ?? {}).flatMap(([target, bindings]) => {
|
|
4921
|
+
const protocol = protocolOf(target);
|
|
4922
|
+
return protocol === void 0 ? [] : (bindings ?? []).flatMap(({ HostIp, HostPort }) => {
|
|
4923
|
+
const port = Number(HostPort);
|
|
4924
|
+
return isPort(port) ? [{
|
|
4925
|
+
host: HostIp === "" ? ANY_IPV4 : HostIp,
|
|
4926
|
+
port,
|
|
4927
|
+
protocol
|
|
4928
|
+
}] : [];
|
|
4929
|
+
});
|
|
4930
|
+
}));
|
|
4750
4931
|
const errorCode = (error) => error.code ?? "";
|
|
4932
|
+
const refusalOf = (published, error) => {
|
|
4933
|
+
const code = errorCode(error);
|
|
4934
|
+
if (code === "EADDRINUSE") return {
|
|
4935
|
+
...published,
|
|
4936
|
+
reason: "busy"
|
|
4937
|
+
};
|
|
4938
|
+
return code === "EACCES" ? {
|
|
4939
|
+
...published,
|
|
4940
|
+
reason: "denied"
|
|
4941
|
+
} : null;
|
|
4942
|
+
};
|
|
4751
4943
|
const cancel = (timer) => {
|
|
4752
4944
|
if (timer !== null) clearTimeout(timer);
|
|
4753
4945
|
return null;
|
|
@@ -4805,6 +4997,62 @@ const carry = (local, remote) => {
|
|
|
4805
4997
|
remote.close();
|
|
4806
4998
|
});
|
|
4807
4999
|
};
|
|
5000
|
+
const datagramsOf = ({ dial, port, socket }) => {
|
|
5001
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
5002
|
+
const end = (sender, session) => {
|
|
5003
|
+
if (sessions.get(sender) === session) sessions.delete(sender);
|
|
5004
|
+
clearTimeout(session.idle);
|
|
5005
|
+
session.remote?.close();
|
|
5006
|
+
};
|
|
5007
|
+
const opened = (sender, from) => {
|
|
5008
|
+
const session = {
|
|
5009
|
+
idle: setTimeout(() => {
|
|
5010
|
+
end(sender, session);
|
|
5011
|
+
}, UDP_IDLE_MS),
|
|
5012
|
+
queue: [],
|
|
5013
|
+
remote: null
|
|
5014
|
+
};
|
|
5015
|
+
const listen = (remote) => {
|
|
5016
|
+
if (sessions.get(sender) !== session) {
|
|
5017
|
+
remote.close();
|
|
5018
|
+
return;
|
|
5019
|
+
}
|
|
5020
|
+
session.remote = remote;
|
|
5021
|
+
remote.addEventListener("open", () => {
|
|
5022
|
+
for (const datagram of session.queue.splice(0)) remote.send(datagram);
|
|
5023
|
+
});
|
|
5024
|
+
remote.addEventListener("message", ({ data }) => {
|
|
5025
|
+
if (data instanceof ArrayBuffer) {
|
|
5026
|
+
session.idle.refresh();
|
|
5027
|
+
socket.send(new Uint8Array(data), from.port, from.address);
|
|
5028
|
+
}
|
|
5029
|
+
});
|
|
5030
|
+
remote.addEventListener("close", () => {
|
|
5031
|
+
end(sender, session);
|
|
5032
|
+
});
|
|
5033
|
+
};
|
|
5034
|
+
const connected = async () => {
|
|
5035
|
+
const outcome = await dial(`/udp/${String(port)}`, listen);
|
|
5036
|
+
if (outcome === null || outcome instanceof Error) end(sender, session);
|
|
5037
|
+
};
|
|
5038
|
+
sessions.set(sender, session);
|
|
5039
|
+
connected();
|
|
5040
|
+
return session;
|
|
5041
|
+
};
|
|
5042
|
+
socket.on("message", (datagram, from) => {
|
|
5043
|
+
const sender = `${from.address} ${String(from.port)}`;
|
|
5044
|
+
const session = sessions.get(sender) ?? opened(sender, from);
|
|
5045
|
+
const { remote } = session;
|
|
5046
|
+
session.idle.refresh();
|
|
5047
|
+
if (remote?.readyState === WebSocket.OPEN) {
|
|
5048
|
+
if (remote.bufferedAmount <= BUFFERED_LIMIT) remote.send(datagram);
|
|
5049
|
+
} else if (session.queue.length < QUEUED_DATAGRAMS) session.queue.push(datagram);
|
|
5050
|
+
});
|
|
5051
|
+
return { close: () => {
|
|
5052
|
+
for (const [sender, session] of sessions) end(sender, session);
|
|
5053
|
+
socket.close();
|
|
5054
|
+
} };
|
|
5055
|
+
};
|
|
4808
5056
|
const forwarderSocket = (settingsFile) => socketOf({
|
|
4809
5057
|
name: "docker-ports",
|
|
4810
5058
|
settingsFile
|
|
@@ -4840,7 +5088,7 @@ const forwardPorts = async (socketPath) => {
|
|
|
4840
5088
|
};
|
|
4841
5089
|
const listener = net.createServer({ allowHalfOpen: true });
|
|
4842
5090
|
const release = () => {
|
|
4843
|
-
for (const
|
|
5091
|
+
for (const listening of state.bound.values()) listening.close();
|
|
4844
5092
|
state.bound.clear();
|
|
4845
5093
|
state.notices.clear();
|
|
4846
5094
|
state.latest = null;
|
|
@@ -4904,15 +5152,18 @@ const forwardPorts = async (socketPath) => {
|
|
|
4904
5152
|
throw error;
|
|
4905
5153
|
}
|
|
4906
5154
|
};
|
|
5155
|
+
const dial = async (target, listen) => {
|
|
5156
|
+
const { attachment } = state;
|
|
5157
|
+
return attachment === null ? null : await attempted(attachment, target, listen);
|
|
5158
|
+
};
|
|
4907
5159
|
const tunnel = async (local, port) => {
|
|
4908
5160
|
local.on("error", noop);
|
|
4909
|
-
const
|
|
4910
|
-
const outcome = attachment === null ? null : await attempted(attachment, `/tcp/${String(port)}`, (remote) => {
|
|
5161
|
+
const outcome = await dial(`/tcp/${String(port)}`, (remote) => {
|
|
4911
5162
|
carry(local, remote);
|
|
4912
5163
|
});
|
|
4913
5164
|
if (outcome === null || outcome instanceof Error) local.destroy();
|
|
4914
5165
|
};
|
|
4915
|
-
const
|
|
5166
|
+
const listenTcp = async (published) => {
|
|
4916
5167
|
const { host, port } = published;
|
|
4917
5168
|
const server = net.createServer({
|
|
4918
5169
|
allowHalfOpen: true,
|
|
@@ -4922,18 +5173,7 @@ const forwardPorts = async (socketPath) => {
|
|
|
4922
5173
|
});
|
|
4923
5174
|
const { promise, resolve } = Promise.withResolvers();
|
|
4924
5175
|
server.once("error", (error) => {
|
|
4925
|
-
|
|
4926
|
-
if (code === "EADDRINUSE") resolve({
|
|
4927
|
-
host,
|
|
4928
|
-
port,
|
|
4929
|
-
reason: "busy"
|
|
4930
|
-
});
|
|
4931
|
-
else if (code === "EACCES") resolve({
|
|
4932
|
-
host,
|
|
4933
|
-
port,
|
|
4934
|
-
reason: "denied"
|
|
4935
|
-
});
|
|
4936
|
-
else resolve(null);
|
|
5176
|
+
resolve(refusalOf(published, error));
|
|
4937
5177
|
});
|
|
4938
5178
|
server.listen({
|
|
4939
5179
|
host,
|
|
@@ -4946,10 +5186,38 @@ const forwardPorts = async (socketPath) => {
|
|
|
4946
5186
|
});
|
|
4947
5187
|
return await promise;
|
|
4948
5188
|
};
|
|
5189
|
+
const listenUdp = async (published) => {
|
|
5190
|
+
const { host, port } = published;
|
|
5191
|
+
const ipv6 = host.includes(":");
|
|
5192
|
+
const socket = dgram.createSocket({
|
|
5193
|
+
ipv6Only: ipv6,
|
|
5194
|
+
type: ipv6 ? "udp6" : "udp4"
|
|
5195
|
+
});
|
|
5196
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
5197
|
+
socket.once("error", (error) => {
|
|
5198
|
+
socket.close();
|
|
5199
|
+
resolve(refusalOf(published, error));
|
|
5200
|
+
});
|
|
5201
|
+
socket.bind({
|
|
5202
|
+
address: host,
|
|
5203
|
+
port
|
|
5204
|
+
}, () => {
|
|
5205
|
+
socket.removeAllListeners("error");
|
|
5206
|
+
socket.on("error", noop);
|
|
5207
|
+
state.bound.set(keyOf(published), datagramsOf({
|
|
5208
|
+
dial,
|
|
5209
|
+
port,
|
|
5210
|
+
socket
|
|
5211
|
+
}));
|
|
5212
|
+
resolve(null);
|
|
5213
|
+
});
|
|
5214
|
+
return await promise;
|
|
5215
|
+
};
|
|
5216
|
+
const bind = async (published) => published.protocol === "udp" ? await listenUdp(published) : await listenTcp(published);
|
|
4949
5217
|
const apply = async (published) => {
|
|
4950
5218
|
const wanted = new Map(published.map((entry) => [keyOf(entry), entry]));
|
|
4951
|
-
for (const [key,
|
|
4952
|
-
|
|
5219
|
+
for (const [key, listening] of state.bound) if (!wanted.has(key)) {
|
|
5220
|
+
listening.close();
|
|
4953
5221
|
state.bound.delete(key);
|
|
4954
5222
|
}
|
|
4955
5223
|
for (const key of state.notices.keys()) if (!wanted.has(key)) state.notices.delete(key);
|
|
@@ -4973,9 +5241,9 @@ const forwardPorts = async (socketPath) => {
|
|
|
4973
5241
|
for (const tag of next.tags) state.syncs.get(tag)?.();
|
|
4974
5242
|
await applyLatest();
|
|
4975
5243
|
};
|
|
4976
|
-
const received = ({ ports, tag }) => {
|
|
5244
|
+
const received = ({ listening, ports, tag }) => {
|
|
4977
5245
|
state.latest = {
|
|
4978
|
-
published: publishedIn(ports),
|
|
5246
|
+
published: [...publishedIn(ports), ...listening.filter(({ port }) => isPort(port))],
|
|
4979
5247
|
tags: [...state.latest?.tags ?? [], ...tag === null ? [] : [tag]]
|
|
4980
5248
|
};
|
|
4981
5249
|
applyLatest();
|
|
@@ -866,9 +866,13 @@ const Plan = Literals([
|
|
|
866
866
|
"pro",
|
|
867
867
|
ENTERPRISE_PLAN
|
|
868
868
|
]).annotate({
|
|
869
|
-
description: "The organization plan:
|
|
869
|
+
description: "The organization plan: the higher of the plan of its Stripe subscription while that subscription is active, trialing, or past due, and the plan of a GitHub Marketplace purchase by a GitHub account it connected to Sandcovery CI, otherwise `free`. `enterprise` is Pro for an organization that connects a GitHub account a GitHub Enterprise owns.",
|
|
870
870
|
identifier: "Plan"
|
|
871
871
|
});
|
|
872
|
+
const PlanBiller = Literals(["github_marketplace", "stripe"]).annotate({
|
|
873
|
+
description: "Who bills a paid plan: `stripe` for a Stripe subscription, and `github_marketplace` for a GitHub Marketplace purchase, which an owner of the buying GitHub organization changes or cancels in its settings under Billing and licensing.",
|
|
874
|
+
identifier: "PlanBiller"
|
|
875
|
+
});
|
|
872
876
|
const ProInterval = Literals([
|
|
873
877
|
"day",
|
|
874
878
|
"month",
|
|
@@ -903,6 +907,7 @@ const Billing = Struct({
|
|
|
903
907
|
enterprise_price: EnterprisePrice,
|
|
904
908
|
github_enterprise: Boolean.annotate({ description: "Whether a GitHub Enterprise owns a GitHub account this organization connected to Sandcovery CI, so that its jobs run only on the Enterprise plan." }),
|
|
905
909
|
plan: Plan,
|
|
910
|
+
plan_billers: ArraySchema(PlanBiller).annotate({ description: "Who bills each paid plan the organization holds, each biller once: `stripe` while its Stripe subscription grants `plan` or a lower paid plan, and `github_marketplace` while a GitHub Marketplace purchase does. Empty on `free`." }),
|
|
906
911
|
pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
|
|
907
912
|
}).annotate({ identifier: "Billing" });
|
|
908
913
|
const CreditTerms = Struct({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Br as isString, E as decodeUnknownSync, Ir as hasProperty, Jn as isSuccess, O as fromJsonString, V as optional, Yn as try_, _ as String$1, c as Json, g as Record, n as Boolean, or as getOrUndefined, qn as isFailure, v as Struct, w as decodeUnknownOption } from "./Schema-CoX0a2_o.mjs";
|
|
2
|
-
import { $ as exitCodeOf, A as isOptionValue, B as plainPrefix, C as enabledVariable, D as closest, E as productVariable, F as rerunArgv, G as remoteLine, H as theme, J as isDigit, K as remoteText, L as clearLine, M as parseFailure, N as parseLeaf, O as flagOf, P as readOptionToken, Q as CliFailure, R as ellipsis, S as writePrivateFile, T as modeOf, U as escapeUnprintable, V as spinnerFrame, W as remoteCell, X as isUpper, Z as isWordCharacter, b as configDirectory, d as BIN, et as statusOf$1, it as IDLE_WATCHER_ENV, j as lastValue, k as isOptionToken, l as setupDropIns, nt as Canceled, ot as watchIdle, p as CLI, q as consistsOf, r as forwardPorts, st as noop, t as FORWARDER_ENV, tt as usageFailure, w as guidanceOn, y as version, z as glyph } from "./port-forwarder-
|
|
3
|
-
import { m as SANDCOVERY_ORIGIN } from "./src-
|
|
2
|
+
import { $ as exitCodeOf, A as isOptionValue, B as plainPrefix, C as enabledVariable, D as closest, E as productVariable, F as rerunArgv, G as remoteLine, H as theme, J as isDigit, K as remoteText, L as clearLine, M as parseFailure, N as parseLeaf, O as flagOf, P as readOptionToken, Q as CliFailure, R as ellipsis, S as writePrivateFile, T as modeOf, U as escapeUnprintable, V as spinnerFrame, W as remoteCell, X as isUpper, Z as isWordCharacter, b as configDirectory, d as BIN, et as statusOf$1, it as IDLE_WATCHER_ENV, j as lastValue, k as isOptionToken, l as setupDropIns, nt as Canceled, ot as watchIdle, p as CLI, q as consistsOf, r as forwardPorts, st as noop, t as FORWARDER_ENV, tt as usageFailure, w as guidanceOn, y as version, z as glyph } from "./port-forwarder-DvSPr-Tg.mjs";
|
|
3
|
+
import { m as SANDCOVERY_ORIGIN } from "./src-BqfeIyqj.mjs";
|
|
4
4
|
import { n as sendTelemetry$1, t as loopbackOrigin } from "./telemetry-DBPKT8Ap.mjs";
|
|
5
5
|
import "./posthog-project-CdWw_ofg.mjs";
|
|
6
6
|
import http from "node:http";
|
|
@@ -1340,7 +1340,7 @@ const runCommand = async ({ invocation, session }) => {
|
|
|
1340
1340
|
try {
|
|
1341
1341
|
const local = LOCAL_COMMANDS.get(key);
|
|
1342
1342
|
if (local !== void 0) return await local(context);
|
|
1343
|
-
const { HANDLERS } = await import("./handlers-
|
|
1343
|
+
const { HANDLERS } = await import("./handlers-CpLa3dvg.mjs");
|
|
1344
1344
|
const handler = HANDLERS.get(key);
|
|
1345
1345
|
if (handler === void 0) throw internalFailure(invocation.path);
|
|
1346
1346
|
return await handler(context);
|
|
@@ -44,6 +44,7 @@ interface Billing {
|
|
|
44
44
|
readonly enterprise_price: ProPrice | null;
|
|
45
45
|
readonly github_enterprise: boolean;
|
|
46
46
|
readonly plan: Plan;
|
|
47
|
+
readonly plan_billers: readonly PlanBiller[];
|
|
47
48
|
readonly pro_price: ProPrice | null;
|
|
48
49
|
}
|
|
49
50
|
interface BrandImage {
|
|
@@ -367,6 +368,7 @@ interface Offer {
|
|
|
367
368
|
readonly x_post_counted: boolean;
|
|
368
369
|
}
|
|
369
370
|
type Plan = "free" | "pro" | "enterprise";
|
|
371
|
+
type PlanBiller = "github_marketplace" | "stripe";
|
|
370
372
|
interface PortPreview {
|
|
371
373
|
readonly expires_at: string | null;
|
|
372
374
|
readonly headers: Readonly<Record<string, string>>;
|
|
@@ -788,4 +790,4 @@ interface XPostRequest {
|
|
|
788
790
|
readonly url: string;
|
|
789
791
|
}
|
|
790
792
|
type ApiError = ConcurrencyLimitReachedError | ConflictError | ForbiddenError | InvalidRequestError | NoProviderAvailableError | NotFoundError | ProviderError | RateLimitedError | SpendLimitReachedError | UnauthorizedError | UnsupportedError;
|
|
791
|
-
export { FileList as $,
|
|
793
|
+
export { FileList as $, SandboxEndReason as $t, CreateFailureReason as A, XAccountStatus as An, ProcessStatus as At, DetachedExec as B, ProviderFeatures as Bt, CiJob as C, UsageShareList as Cn, PortPreview as Ct, ConcurrencyLimitReachedError as D, VendorIncidentRead as Dn, ProblemReportRequest as Dt, CiJobStatus as E, VendorIncident as En, ProPrice as Et, CredentialField as F, ProviderCatalog as Ft, Estimate as G, Provider_1 as Gt, EGRESS_MODES as H, ProviderSecurity as Ht, CredentialFields as I, ProviderCatalogEntry as It, ExecEvent as J, Region as Jt, EstimateList as K, REGIONS as Kt, CreditCheckout as L, ProviderCredential as Lt, CreateSandboxRequest as M, Provider as Mt, CreateUsageShareRequest as N, ProviderBoard as Nt, ConflictError as O, XAccount as On, Process as Ot, CreatedKey as P, ProviderBoardEntry as Pt, FileEntryType as Q, SandboxCost as Qt, CreditPurchaseRequest as R, ProviderCredentialList as Rt, CiInstallationList as S, UsageShareFigure as Sn, PlanBiller as St, CiJobList as T, UsageTotals as Tn, ProInterval as Tt, EgressMode as U, ProviderSort as Ut, DetachedExecRequest as V, ProviderPreferences as Vt, EgressPolicy as W, ProviderStatus as Wt, ExecResult as X, STANDARD_SIZES as Xt, ExecRequest as Y, SLUGS as Yt, FileEntry as Z, Sandbox as Zt, CatalogLimit as _, UpdateKeyRequest as _n, NotFoundError as _t, ApiError as a, SharedUsageFigure as an, IncidentImpact as at, CatalogText as b, UsagePeriod as bn, PROVIDER_1S as bt, AutoTopUpRequest as c, SpendLimit as cn, KeyKind as ct, BrandImage as d, StandardSize as dn, LiveSandboxStatus as dt, SandboxList as en, ForbiddenError as et, CI_JOB_CONCLUSIONS as f, Stats as fn, LiveSandboxes as ft, CatalogGpus as g, UnsupportedError as gn, NoProviderAvailableError as gt, CatalogFlag as h, UnauthorizedError as hn, MonthlyCostList as ht, ActivityList as i, SharedUsage as in, Health as it, CreateKeyRequest as j, XPostRequest as jn, ProcessTerminal as jt, CreateAttempt as k, XAccountLink as kn, ProcessRequest as kt, Badge as l, SpendLimitPeriod as ln, KeyKind_1 as lt, CatalogBrandTerms as m, ThemedBrandImage as mn, MonthlyCost as mt, ActivityAction as n, SecurityList as nn, Gpu as nt, AutoTopUp as o, Slug as on, InvalidRequestError as ot, CatalogBenchmarkTerms as p, StatsDay as pn, LiveUsage as pt, EstimateRequest as q, RateLimitedError as qt, ActivityEvent as r, SecurityText as rn, GpuType as rt, AutoTopUpChange as s, Snapshot as sn, Key as st, ACTIVITY_ACTIONS as t, SandboxStatus as tn, GPU_TYPES as tt, Billing as u, SpendLimitReachedError as un, KeyList as ut, CatalogList as v, Usage as vn, Offer as vt, CiJobConclusion as w, UsageTotal as wn, Pricing as wt, CiInstallation as x, UsageShare as xn, Plan as xt, CatalogMeasurement as y, UsageDay as yn, PROVIDERS as yt, CreditTerms as z, ProviderError as zt };
|