mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
add server settings api
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const express = require("express");
|
||||
const dns = require("dns").promises;
|
||||
const net = require("net");
|
||||
const settings = require("../settings");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -105,6 +106,19 @@ router.post("/", async (req, res) => {
|
||||
return res.status(e.statusCode || 400).json({ error: e.message });
|
||||
}
|
||||
|
||||
// When a host allowlist is defined , the proxy only reaches those hosts.
|
||||
const allowlist = settings.get("proxyAllowlist");
|
||||
|
||||
if (allowlist.length > 0) {
|
||||
const host = new URL(url).hostname;
|
||||
|
||||
if (!allowlist.includes(host)) {
|
||||
return res
|
||||
.status(403)
|
||||
.json({ error: `Host not in proxy allowlist: ${host}` });
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Forward the caller's headers as-is.
|
||||
const fetchOpts = {
|
||||
|
||||
Reference in New Issue
Block a user