mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-09 20:35:28 +02:00
Clean off ports for 80 and 443 hosts
This commit is contained in:
parent
b862e1aeef
commit
7bf820a4bf
1 changed files with 12 additions and 4 deletions
|
@ -90,7 +90,15 @@ export async function verifyResourceSession(
|
||||||
|
|
||||||
const clientIp = requestIp?.split(":")[0];
|
const clientIp = requestIp?.split(":")[0];
|
||||||
|
|
||||||
const resourceCacheKey = `resource:${host}`;
|
let cleanHost = host;
|
||||||
|
// if the host ends with :443 or :80 remove it
|
||||||
|
if (cleanHost.endsWith(":443")) {
|
||||||
|
cleanHost = cleanHost.slice(0, -4);
|
||||||
|
} else if (cleanHost.endsWith(":80")) {
|
||||||
|
cleanHost = cleanHost.slice(0, -3);
|
||||||
|
}
|
||||||
|
|
||||||
|
const resourceCacheKey = `resource:${cleanHost}`;
|
||||||
let resourceData:
|
let resourceData:
|
||||||
| {
|
| {
|
||||||
resource: Resource | null;
|
resource: Resource | null;
|
||||||
|
@ -111,11 +119,11 @@ export async function verifyResourceSession(
|
||||||
resourcePassword,
|
resourcePassword,
|
||||||
eq(resourcePassword.resourceId, resources.resourceId)
|
eq(resourcePassword.resourceId, resources.resourceId)
|
||||||
)
|
)
|
||||||
.where(eq(resources.fullDomain, host))
|
.where(eq(resources.fullDomain, cleanHost))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
logger.debug("Resource not found", host);
|
logger.debug("Resource not found", cleanHost);
|
||||||
return notAllowed(res);
|
return notAllowed(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +139,7 @@ export async function verifyResourceSession(
|
||||||
const { resource, pincode, password } = resourceData;
|
const { resource, pincode, password } = resourceData;
|
||||||
|
|
||||||
if (!resource) {
|
if (!resource) {
|
||||||
logger.debug("Resource not found", host);
|
logger.debug("Resource not found", cleanHost);
|
||||||
return notAllowed(res);
|
return notAllowed(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue