Fix Synology adapter to support plain HTTP, not just HTTPS

Found while verifying against the user's real DSM: the adapter hardcoded
node:https for every request, but the user's NAS is reached over plain
HTTP on port 5000 inside the LAN (HTTPS on 5001 also works, but nothing
about the integration should assume one or the other). Now picks http vs
https based on the configured URL's own protocol, with the right default
port per protocol (5000/5001) and TLS options only applied for https.

Verified against the user's real Synology (10.200.5.35): ping, login, and
SYNO.Storage.CGI.Storage load_info all confirmed working end-to-end through
the actual HTTP route layer — 1 volume (normal, SHR, ~11.5TB/~3.9TB used),
4 disks (all normal, 34-39°C). This is the first of the five previously-
unverified integrations confirmed against real hardware.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5 committed 2026-09-15 00:48:42 +02:00
1 parent afc920e96e
commit 4ed1ac8cad
1 file changed
+12 -4
+12 -4
View File
@@ -16,9 +16,13 @@
* *
* DSM ships with a self-signed certificate unless the admin configured a * DSM ships with a self-signed certificate unless the admin configured a
* real one, so (like the cPanel/Proxmox adapters) this uses node:https * 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 https from "node:https";
import * as http from "node:http";
export interface SynologyConfig { export interface SynologyConfig {
url: string; url: string;
@@ -64,13 +68,17 @@ interface RawResponse {
function request(url: string, insecure: boolean): Promise<RawResponse> { function request(url: string, insecure: boolean): Promise<RawResponse> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const parsed = new URL(url); 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, hostname: parsed.hostname,
port: parsed.port || 5001, port: parsed.port || defaultPort,
path: parsed.pathname + parsed.search, path: parsed.pathname + parsed.search,
method: "GET", method: "GET",
rejectUnauthorized: !insecure, ...(isHttps ? { rejectUnauthorized: !insecure } : {}),
}, },
(res) => { (res) => {
let body = ""; let body = "";