diff --git a/server/src/integrations/synology/adapter.ts b/server/src/integrations/synology/adapter.ts index c1d6bb1..d544222 100644 --- a/server/src/integrations/synology/adapter.ts +++ b/server/src/integrations/synology/adapter.ts @@ -16,9 +16,13 @@ * * DSM ships with a self-signed certificate unless the admin configured a * real one, so (like the cPanel/Proxmox adapters) this uses node:https - * directly to support an "insecure" opt-out of certificate verification. + * directly to support an "insecure" opt-out of certificate verification — + * but DSM is just as commonly reached over plain HTTP (default port 5000) + * inside a trusted LAN, so the request helper picks http vs https from the + * configured URL's own protocol rather than assuming HTTPS. */ import * as https from "node:https"; +import * as http from "node:http"; export interface SynologyConfig { url: string; @@ -64,13 +68,17 @@ interface RawResponse { function request(url: string, insecure: boolean): Promise { return new Promise((resolve, reject) => { const parsed = new URL(url); - const req = https.request( + const isHttps = parsed.protocol === "https:"; + const lib = isHttps ? https : http; + const defaultPort = isHttps ? 5001 : 5000; + + const req = lib.request( { hostname: parsed.hostname, - port: parsed.port || 5001, + port: parsed.port || defaultPort, path: parsed.pathname + parsed.search, method: "GET", - rejectUnauthorized: !insecure, + ...(isHttps ? { rejectUnauthorized: !insecure } : {}), }, (res) => { let body = "";