Skip to content

Commit

Permalink
Merge pull request #37 from RIKEN-RCCS/IPLimitation
Browse files Browse the repository at this point in the history
support IP address limitation
  • Loading branch information
so5 authored Feb 29, 2024
2 parents 25f492e + 90d3a8f commit bf9d55c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 4 deletions.
73 changes: 71 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@
"lint-staged": {
"*.js": "eslint --fix",
"*.vue": "eslint --fix"
},
"dependencies": {
"express-ipfilter": "^1.3.2"
}
}
2 changes: 1 addition & 1 deletion server/app/db/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "2024-0213-173244" }
{"version": "2024-0229-105541" }
9 changes: 8 additions & 1 deletion server/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const path = require("path");
const fs = require("fs-extra");
const cors = require("cors");
const express = require("express");
const ipfilter = require("express-ipfilter").IpFilter
const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const Siofu = require("socketio-file-upload");
Expand All @@ -28,8 +29,9 @@ process.on("uncaughtException", logger.debug.bind(logger));
* setup express, socketIO
*/

const baseURL = process.env.WHEEL_BASE_URL || "/";
const app = express();
const baseURL = process.env.WHEEL_BASE_URL || "/";
const address = process.env.WHEEL_ACCEPT_ADDRESS

function createHTTPSServer(argApp) {
const { keyFilename, certFilename } = require("./db/db");
Expand All @@ -56,6 +58,7 @@ logger.info(`WHEEL_TEMPD = ${process.env.WHEEL_TEMPD}`);
logger.info(`WHEEL_CONFIG_DIR = ${process.env.WHEEL_CONFIG_DIR}`);
logger.info(`WHEEL_USE_HTTP = ${process.env.WHEEL_USE_HTTP}`);
logger.info(`WHEEL_PORT = ${process.env.WHEEL_PORT}`);
logger.info(`WHEEL_ACCEPT_ADDRESS= ${process.env.WHEEL_ACCEPT_ADDRESS}`);
logger.info(`WHEEL_LOGLEVEL = ${process.env.WHEEL_LOGLEVEL}`);
logger.info(`WHEEL_VERBOSE_SSH = ${process.env.WHEEL_VERBOSE_SSH}`);
logger.info(`WHEEL_INTERVAL= ${process.env.WHEEL_INTERVAL}`);
Expand All @@ -67,6 +70,10 @@ let portNumber = port || defaultPort;
portNumber = portNumber > 0 ? portNumber : defaultPort;

//middlewares
if(address){
const ips = [address];
app.use(ipfilter(ips, { mode: "allow", logF: logger.debug.bind(logger) }));
}
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
Expand Down

0 comments on commit bf9d55c

Please sign in to comment.