v1.0.19
This commit is contained in:
1 parent
4b430340db
commit
9c451aedf9
120 files changed
+7777
-6046
No files matched your search
@@ -113,7 +113,7 @@ export const POST: RequestHandler = async (event) => {
|
||||
await setEnvironmentPublicIp(env.id, data.publicIp);
|
||||
}
|
||||
|
||||
// Notify subprocesses to pick up the new environment
|
||||
// Notify event collectors to pick up the new environment
|
||||
refreshSubprocessEnvironments();
|
||||
|
||||
// Auto-assign Admin role to creator (Enterprise only)
|
||||
|
||||
@@ -91,7 +91,7 @@ export const PUT: RequestHandler = async (event) => {
|
||||
return json({ error: 'Environment not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
// Notify subprocesses if collectActivity or collectMetrics setting changed
|
||||
// Notify event collectors if collectActivity or collectMetrics setting changed
|
||||
if (data.collectActivity !== undefined || data.collectMetrics !== undefined) {
|
||||
refreshSubprocessEnvironments();
|
||||
}
|
||||
@@ -178,7 +178,7 @@ export const DELETE: RequestHandler = async (event) => {
|
||||
await deleteImagePruneSettings(id);
|
||||
unregisterSchedule(id, 'image_prune');
|
||||
|
||||
// Notify subprocesses to stop collecting from deleted environment
|
||||
// Notify event collectors to stop collecting from deleted environment
|
||||
refreshSubprocessEnvironments();
|
||||
|
||||
// Audit log
|
||||
|
||||
@@ -71,7 +71,7 @@ export const POST: RequestHandler = async ({ params }) => {
|
||||
}
|
||||
|
||||
// For Hawser Standard mode, fetch Docker info and Hawser info in parallel
|
||||
// (sequential calls can fail due to Bun TLS connection reuse issues)
|
||||
// (parallel calls are more efficient and avoid sequential connection issues)
|
||||
let info: any;
|
||||
let hawserInfo = null;
|
||||
if (env.connectionType === 'hawser-standard') {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from '$lib/server/db';
|
||||
import { refreshSchedulesForEnvironment } from '$lib/server/scheduler';
|
||||
|
||||
/** Map of modern IANA timezone names to their canonical equivalents recognized by Bun/ICU */
|
||||
/** Map of modern IANA timezone names to their canonical equivalents recognized by ICU */
|
||||
const TIMEZONE_ALIASES: Record<string, string> = {
|
||||
'Europe/Kyiv': 'Europe/Kiev',
|
||||
'Asia/Ho_Chi_Minh': 'Asia/Saigon',
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { unixSocketRequest, httpsAgentRequest } from '$lib/server/docker';
|
||||
import type { DockerClientConfig } from '$lib/server/docker';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
interface TestConnectionRequest {
|
||||
@@ -22,29 +24,19 @@ function cleanPem(pem: string): string {
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
function buildTlsOptions(config: TestConnectionRequest): Record<string, any> | undefined {
|
||||
function buildDockerClientConfig(config: TestConnectionRequest): DockerClientConfig | null {
|
||||
const protocol = config.protocol || 'http';
|
||||
if (protocol !== 'https') return undefined;
|
||||
if (protocol !== 'https') return null;
|
||||
|
||||
const tls: Record<string, any> = {
|
||||
sessionTimeout: 0,
|
||||
servername: config.host
|
||||
return {
|
||||
type: 'https',
|
||||
host: config.host || 'localhost',
|
||||
port: config.port || 2376,
|
||||
ca: config.tlsCa ? cleanPem(config.tlsCa) || undefined : undefined,
|
||||
cert: config.tlsCert ? cleanPem(config.tlsCert) || undefined : undefined,
|
||||
key: config.tlsKey ? cleanPem(config.tlsKey) || undefined : undefined,
|
||||
skipVerify: config.tlsSkipVerify || false
|
||||
};
|
||||
if (config.tlsSkipVerify) {
|
||||
tls.rejectUnauthorized = false;
|
||||
} else {
|
||||
tls.rejectUnauthorized = true;
|
||||
if (config.tlsCa) {
|
||||
tls.ca = [cleanPem(config.tlsCa)];
|
||||
}
|
||||
}
|
||||
if (config.tlsCert) {
|
||||
tls.cert = [cleanPem(config.tlsCert)];
|
||||
}
|
||||
if (config.tlsKey) {
|
||||
tls.key = cleanPem(config.tlsKey);
|
||||
}
|
||||
return tls;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,11 +51,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
|
||||
if (config.connectionType === 'socket') {
|
||||
const socketPath = config.socketPath || '/var/run/docker.sock';
|
||||
response = await fetch('http://localhost/info', {
|
||||
// @ts-ignore - Bun supports unix socket
|
||||
unix: socketPath,
|
||||
signal: AbortSignal.timeout(10000)
|
||||
});
|
||||
response = await unixSocketRequest(socketPath, '/info');
|
||||
} else if (config.connectionType === 'hawser-edge') {
|
||||
// Edge mode - cannot test directly, agent connects to us
|
||||
return json({
|
||||
@@ -83,7 +71,6 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
return json({ success: false, error: 'Host is required' }, { status: 400 });
|
||||
}
|
||||
|
||||
const url = `${protocol}://${host}:${port}/info`;
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
@@ -92,19 +79,17 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
headers['X-Hawser-Token'] = config.hawserToken;
|
||||
}
|
||||
|
||||
const fetchOptions: any = {
|
||||
headers,
|
||||
signal: AbortSignal.timeout(10000),
|
||||
keepalive: false
|
||||
};
|
||||
|
||||
const tls = buildTlsOptions(config);
|
||||
if (tls) {
|
||||
fetchOptions.tls = tls;
|
||||
if (process.env.DEBUG_TLS) fetchOptions.verbose = true;
|
||||
const tlsConfig = buildDockerClientConfig(config);
|
||||
if (tlsConfig) {
|
||||
response = await httpsAgentRequest(tlsConfig, '/info', {}, false, headers);
|
||||
} else {
|
||||
const url = `http://${host}:${port}/info`;
|
||||
response = await fetch(url, {
|
||||
headers,
|
||||
signal: AbortSignal.timeout(10000),
|
||||
keepalive: false
|
||||
});
|
||||
}
|
||||
|
||||
response = await fetch(url, fetchOptions);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -123,21 +108,19 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
if (config.hawserToken) {
|
||||
hawserHeaders['X-Hawser-Token'] = config.hawserToken;
|
||||
}
|
||||
const hawserUrl = `${protocol}://${config.host}:${config.port || 2375}/_hawser/info`;
|
||||
|
||||
const fetchOptions: any = {
|
||||
headers: hawserHeaders,
|
||||
signal: AbortSignal.timeout(5000),
|
||||
keepalive: false
|
||||
};
|
||||
|
||||
const tls = buildTlsOptions(config);
|
||||
if (tls) {
|
||||
fetchOptions.tls = tls;
|
||||
if (process.env.DEBUG_TLS) fetchOptions.verbose = true;
|
||||
let hawserResp: Response;
|
||||
const tlsConfig = buildDockerClientConfig(config);
|
||||
if (tlsConfig) {
|
||||
hawserResp = await httpsAgentRequest(tlsConfig, '/_hawser/info', {}, false, hawserHeaders);
|
||||
} else {
|
||||
const hawserUrl = `http://${config.host}:${config.port || 2375}/_hawser/info`;
|
||||
hawserResp = await fetch(hawserUrl, {
|
||||
headers: hawserHeaders,
|
||||
signal: AbortSignal.timeout(5000),
|
||||
keepalive: false
|
||||
});
|
||||
}
|
||||
|
||||
const hawserResp = await fetch(hawserUrl, fetchOptions);
|
||||
if (hawserResp.ok) {
|
||||
hawserInfo = await hawserResp.json();
|
||||
}
|
||||
@@ -182,6 +165,8 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
message = 'Connection failed - check host and port';
|
||||
} else if (rawMessage.includes('self signed certificate') || rawMessage.includes('UNABLE_TO_VERIFY_LEAF_SIGNATURE')) {
|
||||
message = 'TLS certificate error - provide CA certificate for self-signed certs';
|
||||
} else if (rawMessage.includes('CERT_ALTNAME_INVALID') || rawMessage.includes('ERR_TLS_CERT_ALTNAME_INVALID')) {
|
||||
message = 'Certificate hostname mismatch - your certificate\'s Subject Alternative Name (SAN) doesn\'t match the host. Regenerate with: -addext "subjectAltName=DNS:hostname,IP:x.x.x.x"';
|
||||
} else if (rawMessage.includes('certificate') || rawMessage.includes('SSL') || rawMessage.includes('TLS')) {
|
||||
message = 'TLS/SSL error - check certificate configuration';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user