Fix exception matching IPv6 against IPv4 CIDR
This commit is contained in:
1 parent
5806fe2df6
commit
d91be02599
1 file changed
+4
-2
+4
-2
@@ -111,8 +111,10 @@ export function getRequestOrigin(request: IncomingMessage): RequestOrigin {
|
|||||||
|
|
||||||
const header = request.headers["forwarded"];
|
const header = request.headers["forwarded"];
|
||||||
if (header) {
|
if (header) {
|
||||||
const ip = parse(socketEndpoints.remoteAddress) as IPv4;
|
const ip = parse(socketEndpoints.remoteAddress);
|
||||||
if (cidrs.some((cidr) => ip.match(cidr as [IPv4, number]))) {
|
if (
|
||||||
|
cidrs.some((cidr) => ip.kind() === cidr[0].kind() && ip.match(cidr))
|
||||||
|
) {
|
||||||
const parsed = parseForwardedHeader(header);
|
const parsed = parseForwardedHeader(header);
|
||||||
|
|
||||||
if (parsed["proto"] === "https") {
|
if (parsed["proto"] === "https") {
|
||||||
|
|||||||
Reference in new issue
Block a user