mirror of https://github.com/openclaw/openclaw.git
fix(matrix): honor canonical private-network opt-in
This commit is contained in:
parent
c6d3ee70e2
commit
54ad458267
|
|
@ -718,6 +718,15 @@ describe("resolveMatrixConfig", () => {
|
|||
"Matrix homeserver must use https:// unless it targets a private or loopback host",
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts internal http hostnames when the private-network opt-in is explicit", async () => {
|
||||
await expect(
|
||||
resolveValidatedMatrixHomeserverUrl("http://localhost.localdomain:8008", {
|
||||
dangerouslyAllowPrivateNetwork: true,
|
||||
lookupFn: createLookupFn([{ address: "127.0.0.1", family: 4 }]),
|
||||
}),
|
||||
).resolves.toBe("http://localhost.localdomain:8008");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveMatrixAuth", () => {
|
||||
|
|
|
|||
|
|
@ -510,10 +510,16 @@ export async function resolveValidatedMatrixHomeserverUrl(
|
|||
lookupFn?: LookupFn;
|
||||
},
|
||||
): Promise<string> {
|
||||
const normalized = validateMatrixHomeserverUrl(homeserver, opts);
|
||||
const allowPrivateNetwork =
|
||||
typeof opts?.dangerouslyAllowPrivateNetwork === "boolean"
|
||||
? opts.dangerouslyAllowPrivateNetwork
|
||||
: opts?.allowPrivateNetwork;
|
||||
const normalized = validateMatrixHomeserverUrl(homeserver, {
|
||||
allowPrivateNetwork,
|
||||
});
|
||||
await assertHttpUrlTargetsPrivateNetwork(normalized, {
|
||||
dangerouslyAllowPrivateNetwork: opts?.dangerouslyAllowPrivateNetwork,
|
||||
allowPrivateNetwork: opts?.allowPrivateNetwork,
|
||||
allowPrivateNetwork,
|
||||
lookupFn: opts?.lookupFn,
|
||||
errorMessage: MATRIX_HTTP_HOMESERVER_ERROR,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue