mount acp in the goosed server to migrate using acp protocols iteratively (#9097)

This commit is contained in:
Lifei Zhou
2026-05-18 09:43:30 +10:00
committed by GitHub
parent d04c882388
commit 1fafd74413
17 changed files with 1430 additions and 61 deletions
@@ -7,6 +7,7 @@ describe('buildConnectSrc', () => {
const result = buildConnectSrc(undefined);
expect(result).toContain("'self'");
expect(result).toContain('http://127.0.0.1:*');
expect(result).toContain('wss://127.0.0.1:*');
});
it('includes external backend origin when enabled', () => {
@@ -17,6 +18,18 @@ describe('buildConnectSrc', () => {
};
const result = buildConnectSrc(config);
expect(result).toContain('http://dev.company.net:12604');
expect(result).toContain('ws://dev.company.net:12604');
});
it('includes external secure WebSocket origin for HTTPS backends', () => {
const config: ExternalGoosedConfig = {
enabled: true,
url: 'https://secure.company.net:12604',
secret: 'test',
};
const result = buildConnectSrc(config);
expect(result).toContain('https://secure.company.net:12604');
expect(result).toContain('wss://secure.company.net:12604');
});
it('does not include external origin when disabled', () => {
+6
View File
@@ -4,8 +4,12 @@ const DEFAULT_CONNECT_SOURCES = [
"'self'",
'http://127.0.0.1:*',
'https://127.0.0.1:*',
'ws://127.0.0.1:*',
'wss://127.0.0.1:*',
'http://localhost:*',
'https://localhost:*',
'ws://localhost:*',
'wss://localhost:*',
'https://api.github.com',
'https://github.com',
'https://objects.githubusercontent.com',
@@ -18,6 +22,8 @@ export function buildConnectSrc(externalGoosed?: ExternalGoosedConfig): string {
try {
const externalUrl = new URL(externalGoosed.url);
sources.push(externalUrl.origin);
externalUrl.protocol = externalUrl.protocol === 'https:' ? 'wss:' : 'ws:';
sources.push(externalUrl.origin);
} catch {
console.warn('Invalid external goosed URL in settings, skipping CSP entry');
}