1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-11-24 08:32:23 +02:00

Add test cases for IPv6 addresses in getClientIP

This commit is contained in:
nthumann 2023-07-08 17:46:26 +02:00
parent cdf6922bdd
commit d55794e1a5
No known key found for this signature in database
GPG Key ID: 91AE26F52DE54B76

View File

@ -306,6 +306,16 @@ describe("Test uptimeKumaServer.getClientIP()", () => {
ip = await server.getClientIP(fakeSocket); ip = await server.getClientIP(fakeSocket);
expect(ip).toBe("203.0.113.195"); expect(ip).toBe("203.0.113.195");
fakeSocket.client.conn.remoteAddress = "2001:db8::1";
fakeSocket.client.conn.request.headers = {};
ip = await server.getClientIP(fakeSocket);
expect(ip).toBe("2001:db8::1");
fakeSocket.client.conn.remoteAddress = "::ffff:127.0.0.1";
fakeSocket.client.conn.request.headers = {};
ip = await server.getClientIP(fakeSocket);
expect(ip).toBe("127.0.0.1");
await Database.close(); await Database.close();
}, 120000); }, 120000);
}); });