Update haproxy-sdk to new version with small failsafe for illegal commands

Reenable custom backend mapping to show backend server names
Minor formatting fixes
develop
Your Name 2 years ago
parent cf3176f811
commit f4cbb8ccb0
  1. 1
      Dockerfile
  2. 1
      controllers/maps.js
  3. 14
      package-lock.json
  4. 2
      package.json
  5. 6
      pages/account.js
  6. 10
      pages/map/[name].js
  7. 9
      router.js
  8. 4
      util.js

@ -9,7 +9,6 @@ RUN npm install --production
COPY .env /opt/.env
COPY . /opt
COPY ./node_modules/@fatchan/haproxy-sdk/lib/_utils.js /opt/node_modules/@fatchan/haproxy-sdk/lib/_utils.js
RUN npm run build

@ -23,6 +23,7 @@ exports.mapData = async (req, res, next) => {
switch (req.params.name) {
case process.env.DDOS_MAP_NAME:
showValues = true;
case process.env.BACKENDS_MAP_NAME:
case process.env.HOSTS_MAP_NAME:
if (process.env.CUSTOM_BACKENDS_ENABLED) {
showValues = true;

14
package-lock.json generated

@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "AGPL-3.0-only",
"dependencies": {
"@fatchan/haproxy-sdk": "^1.0.5",
"@fatchan/haproxy-sdk": "^1.0.6",
"bcrypt": "^5.0.1",
"body-parser": "^1.20.0",
"bootstrap": "^5.1.3",
@ -102,9 +102,9 @@
"dev": true
},
"node_modules/@fatchan/haproxy-sdk": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@fatchan/haproxy-sdk/-/haproxy-sdk-1.0.5.tgz",
"integrity": "sha512-O0NzzpAwOcJDKUgvkaGIxvXn+uozpAWbT1lncFEX5MGoJ/HmKGQCtARStQNk/d//Q1gm4ILiOmLa9XcJRq+cbQ==",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@fatchan/haproxy-sdk/-/haproxy-sdk-1.0.6.tgz",
"integrity": "sha512-VJbQGtGuxNhpcmYQI9kXAKHpmWXqQ9hs0K+GzIDG7pJ2dwBwaDf71hcezvehFhgmQMqD7dDMZG+1QkMCJDbiMA==",
"engines": {
"node": ">=8.15.1",
"npm": ">=6.4.1"
@ -8010,9 +8010,9 @@
}
},
"@fatchan/haproxy-sdk": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@fatchan/haproxy-sdk/-/haproxy-sdk-1.0.5.tgz",
"integrity": "sha512-O0NzzpAwOcJDKUgvkaGIxvXn+uozpAWbT1lncFEX5MGoJ/HmKGQCtARStQNk/d//Q1gm4ILiOmLa9XcJRq+cbQ=="
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@fatchan/haproxy-sdk/-/haproxy-sdk-1.0.6.tgz",
"integrity": "sha512-VJbQGtGuxNhpcmYQI9kXAKHpmWXqQ9hs0K+GzIDG7pJ2dwBwaDf71hcezvehFhgmQMqD7dDMZG+1QkMCJDbiMA=="
},
"@humanwhocodes/config-array": {
"version": "0.9.5",

@ -13,7 +13,7 @@
"author": "Thomas Lynch (fatchan) <tom@69420.me>",
"license": "AGPL-3.0-only",
"dependencies": {
"@fatchan/haproxy-sdk": "^1.0.5",
"@fatchan/haproxy-sdk": "^1.0.6",
"bcrypt": "^5.0.1",
"body-parser": "^1.20.0",
"bootstrap": "^5.1.3",

@ -92,10 +92,10 @@ const Account = (props) => {
<div className="d-flex w-100 justify-content-between mt-2">
<div className="ms-2">
<div className="fw-bold">
Servers ({user.clusters[user.activeCluster].split(',').length})
<span className="fw-normal">
Servers ({user.clusters.length === 0 ? 0 : user.clusters[user.activeCluster].split(',').length})
{user.clusters.length > 0 && (<span className="fw-normal">
: {user.clusters[user.activeCluster].split(',').map(x => x.substring(0, x.length/2)+'...').join(', ')}
</span>
</span>)}
</div>
</div>
<span className="ml-auto d-flex flex-row">

@ -94,6 +94,16 @@ const MapPage = (props) => {
<option selected />
{domainSelectOptions}
</select>
{
(process.env.NEXT_PUBLIC_CUSTOM_BACKENDS_ENABLED && mapId.name === "hosts") &&
<input
className="form-control ml-2"
type="text"
name="value"
placeholder="backend ip:port"
required
/>
}
</>
);
break;

@ -17,9 +17,9 @@ const testRouter = (server, app) => {
rolling: true,
cookie: {
httpOnly: true,
secure: false, //!dev, //TODO: check https
secure: true, //!dev, //TODO: check https
sameSite: 'strict',
maxAge: 1000 * 60 * 60 * 24 * 7, //week
maxAge: 1000 * 60 * 60 * 24 * 30, //month
}
});
@ -70,7 +70,8 @@ const testRouter = (server, app) => {
};
const hasCluster = (req, res, next) => {
if (res.locals.user.clusters.length > 0) {
console.log(req.path)
if (res.locals.user.clusters.length > 0 || (req.baseUrl+req.path) === '/forms/cluster/add') {
return next();
}
return dynamicResponse(req, res, 302, { redirect: '/clusters' });
@ -93,7 +94,7 @@ const testRouter = (server, app) => {
server.post('/forms/register', useSession, accountController.register);
const mapNames = [process.env.BLOCKED_MAP_NAME, process.env.MAINTENANCE_MAP_NAME, process.env.WHITELIST_MAP_NAME,
process.env.BLOCKED_MAP_NAME, process.env.DDOS_MAP_NAME, process.env.HOSTS_MAP_NAME]
process.env.BACKENDS_MAP_NAME, process.env.DDOS_MAP_NAME, process.env.HOSTS_MAP_NAME]
, mapNamesOrString = mapNames.join('|');
//authed pages that dont require a cluster

@ -32,11 +32,11 @@ const fMap = {
columnNames: ['Domain', ''],
},
/*[process.env.BACKENDS_MAP_NAME]: {
[process.env.BACKENDS_MAP_NAME]: {
fname: 'Domain Backend Mappings',
description: 'Which internal server haproxy uses for domains',
columnNames: ['Domain', 'Server Name'],
},*/
},
};

Loading…
Cancel
Save