mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
type checker no trust functions as type guards
This commit is contained in:
@ -385,7 +385,7 @@ function getIpFromRequest(req) {
|
|||||||
let clientIp = req.connection.remoteAddress;
|
let clientIp = req.connection.remoteAddress;
|
||||||
let ip = ipaddr.parse(clientIp);
|
let ip = ipaddr.parse(clientIp);
|
||||||
// Check if the IP address is IPv4-mapped IPv6 address
|
// Check if the IP address is IPv4-mapped IPv6 address
|
||||||
if (ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) {
|
if (ip.kind() === 'ipv6' && ip instanceof ipaddr.IPv6 && ip.isIPv4MappedAddress()) {
|
||||||
const ipv4 = ip.toIPv4Address().toString();
|
const ipv4 = ip.toIPv4Address().toString();
|
||||||
clientIp = ipv4;
|
clientIp = ipv4;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user