Skip to content

Commit

Permalink
chore(http): probe request
Browse files Browse the repository at this point in the history
增加探测请求判断
  • Loading branch information
huangyoukun committed May 25, 2018
1 parent 1df3503 commit 00fde12
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
14 changes: 14 additions & 0 deletions bin/lib/util/isProbe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*!
* Tencent is pleased to support the open source community by making Tencent Server Web available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

//是否接入层探测请求
this.isProbe = (req) => {
return false;
};

4 changes: 2 additions & 2 deletions bin/lib/util/isTST.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
const config = require('config');

//是否安全扫描器请求
this.isTST = function(request) {
this.isTST = (req) => {

if(config.extendMod && typeof config.extendMod.isTST === 'function') {
return config.extendMod.isTST(request);
return config.extendMod.isTST(req);
}

return false;
Expand Down
9 changes: 8 additions & 1 deletion bin/proxy/http.proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const cp = require('child_process');
const parseGet = require('util/http/parseGet.js');
const tnm2 = require('api/tnm2');
const cpuUtil = require('util/cpu.js');
const isProbe = require('util/isProbe.js');
const TEReport = require('util/auto-report/TEReport.js');
const mail = require('util/mail/mail.js');
const websocket = require('./websocket.js');
Expand Down Expand Up @@ -51,6 +52,12 @@ function doRoute(req, res) {
config = require('./config.js');
}

if(isProbe.isProbe(req)) {
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
res.end();
return;
}

routeCache(req, res);
}

Expand Down Expand Up @@ -157,7 +164,7 @@ function requestHandler(req, res) {
}

res.flush = res.flush || function() {
return true;
return true;
};

//解析get参数
Expand Down

0 comments on commit 00fde12

Please sign in to comment.