Skip to content

Commit

Permalink
Merge pull request jason5ng32#190 from jason5ng32/dev
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
jason5ng32 authored Apr 26, 2024
2 parents a8efcea + 7744862 commit 580e488
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-rate-limit": "^7.2.0",
"express-slow-down": "^2.0.1",
"flag-icons": "^7.2.1",
"http-proxy-middleware": "^2.0.6",
"nodemon": "^3.1.0",
Expand Down
9 changes: 9 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import recaptchaHandler from './api/recaptcha.js';
import validateConfigs from './api/configs.js';
import dnsResolver from './api/dnsresolver.js';
import rateLimit from 'express-rate-limit';
import { slowDown } from 'express-slow-down'

dotenv.config();

const app = express();
const port = process.env.PORT || 11966;
const blackListIPLogFilePath = process.env.BLACKLIST_LOG_FILE_PATH || '';
const rateLimitSet = process.env.RATE_LIMIT || '60';
const deleyAfter = process.env.DELAY_AFTER || '60';

app.set('trust proxy', 1);

Expand Down Expand Up @@ -90,7 +92,14 @@ const apiLimiter = rateLimit({
}
});

const speedLimiter = slowDown({
windowMs: 60 * 60 * 1000,
delayAfter: parseInt(deleyAfter, 10),
delayMs: (hits) => hits * 400,
})

app.use('/api', apiLimiter);
app.use('/api', speedLimiter);

// APIs
app.get('/api/map', mapHandler);
Expand Down
1 change: 1 addition & 0 deletions src/components/ipcheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ export default {
},
mounted() {
this.isMapShown = JSON.parse(localStorage.getItem("isMapShown")) || false;
this.checkAllIPs();
// 从本地存储中获取 ipGeoSource
Expand Down

0 comments on commit 580e488

Please sign in to comment.