mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
fix: prefer ipv4 when resolving ssh host names (#1365)
This commit is contained in:
1 parent
4076eb66ab
commit
e88df7827b
4 files changed
+72
-6
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
pickSshAddress,
|
||||
resolveHostForSshConnect,
|
||||
} from "../../src/backend/helpers.js";
|
||||
|
||||
describe("resolveHostForSshConnect", () => {
|
||||
it("prefers IPv4 over IPv6", async () => {
|
||||
const lookup = vi.fn().mockResolvedValue([
|
||||
{ address: "fe80::1", family: 6 },
|
||||
{ address: "192.168.1.20", family: 4 },
|
||||
]);
|
||||
const result = await resolveHostForSshConnect("nas", lookup);
|
||||
expect(result.host).toBe("192.168.1.20");
|
||||
});
|
||||
|
||||
it("keeps an IPv6-only answer", () => {
|
||||
expect(pickSshAddress({ address: "2001:db8::5", family: 6 })).toBe(
|
||||
"2001:db8::5",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user