Skip to content

Commit

Permalink
chore: add eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcui committed May 24, 2018
2 parents d582821 + e97bae7 commit 5a39415
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 65 deletions.
12 changes: 8 additions & 4 deletions bin/lib/api/tnm2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,23 @@ var reportOpenapi = function(last) {

//阻止默认上报
if(retCall === false) {
return;
return defer.resolve();
}

if(config.isTest) {
return;
return defer.resolve();
}

if(config.devMode) {
return defer.resolve();
}

if(!config.appid || !config.appkey) {
return;
return defer.resolve();
}

if(!config.appReportUrl) {
return;
return defer.resolve();
}

var arr = [];
Expand Down
71 changes: 11 additions & 60 deletions bin/proxy/http.proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const cp = require('child_process');
const parseGet = require('util/http/parseGet.js');
const tnm2 = require('api/tnm2');
const cpuUtil = require('util/cpu.js');
const httpUtil = require('util/http.js');
const TEReport = require('util/auto-report/TEReport.js');
const mail = require('util/mail/mail.js');
const websocket = require('./websocket.js');
Expand All @@ -35,14 +34,14 @@ const serverInfo = {
intranetIp: require('serverInfo.js').intranetIp,
cpu: 'X'
};
var server;
var serverThis;
var serverHttps;
var config = require('./config.js');
var routeCache = null;
var cleanCacheTid = null;
var isStartHeartBeat = false;
var heartBeatCount = 0;
let server;
let serverThis;
let serverHttps;
let config = require('./config.js');
let routeCache = null;
let cleanCacheTid = null;
let isStartHeartBeat = false;
let heartBeatCount = 0;


function doRoute(req, res) {
Expand All @@ -52,57 +51,12 @@ function doRoute(req, res) {
config = require('./config.js');
}

if(req.headers['user-agent'] === 'nws' && req.headers.host === serverInfo.intranetIp) {
//nws探测请求
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
res.end('hello nws');

return;
}

if(req.headers['user-agent'] === 'TgwProbe') {
//stgw探测请求
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
res.end('hello TgwProbe');

return;
}

if(req.headers['user-agent'] === 'StgwProbe') {
//stgw探测请求
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
res.end('hello StgwProbe');

return;
}

if(req.headers['user-agent'] === 'TgwProbe') {
//stgw探测请求
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
res.end('hello TgwProbe');

return;
}

if(req.REQUEST.pathname === '/' && !req.headers['user-agent']) {

if(httpUtil.isInnerIP(httpUtil.getUserIp(req))) {
//l7探测请求
res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
res.end('hello l7');
return;
}

}

routeCache(req, res);
}

process.serverInfo = serverInfo;

/**
* 清除缓存
*/
//清除缓存
function cleanCache() {

clearTimeout(cleanCacheTid);
Expand Down Expand Up @@ -203,7 +157,7 @@ function requestHandler(req, res) {
}

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

//解析get参数
Expand Down Expand Up @@ -542,10 +496,7 @@ methodMap.listen = function(message) {
};

if(cluster.isMaster) {
if(isWindows) {
logger.info('isWindows, start listening');
methodMap.listen({cpu : 0});
}else if(debugOptions && debugOptions.inspectorEnabled) {
if(debugOptions && debugOptions.inspectorEnabled) {
logger.setLogLevel('debug');
logger.info('inspectorEnabled, start listening');
methodMap.listen({cpu : 0});
Expand Down
2 changes: 1 addition & 1 deletion bin/proxy/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function startServer() {

}else{

//子进程直接引入proxy文件,当然也可以直接在这里写逻辑运行,注意此处else作用域属于子进程作用域,非本程序作用域
//子进程直接引入proxy文件,注意此处else作用域属于子进程作用域,非本程序作用域
process.title = 'TSW/worker/node';
logger.info('start worker....');
require('./http.proxy.js');
Expand Down

0 comments on commit 5a39415

Please sign in to comment.