Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var globalServer = http.createServer(function(req, res) {
if (typeof fsServer =='function'){
return fsServer(req,res);
}
}).listen(PORT, function() {
fw.log('Server Listening on ' + PORT);
});
// register the server to group
//groupManager.register([{addr:config.get('selfGroupManagerAddr') || '0.0.0.0',port:config.get('selfGroupManagerPort') || (parseInt(PORT) + 3000)}]);
// ===================== NET MESSAGE DISPATCHER , WANG SU ================== //
//start websocket server
var sock = sockjs.listen(globalServer, {
prefix : '/socket'
});
sock.on("connection", function(conn) {
if(!conn){
fw.log('no connection object.');
return;
}
conn.on("data", function(msg){
//FIXME 做跨域连接检测和授权检查
//后面的pk判断是用于如果server的pk变化,中断后重新交换公钥的时候不加密,所以此处遇到'{}'不解密。
if (fw.config.get("rsa_enable") && msg.substring(0,1) !== "{") {
msg = fw.myrsa.decrypt(msg);
}