简体   繁体   English

WebRTC Node.JS WebSocket 服务器,如果 WSS 参数不为 1,则阻止请求

[英]WebRTC Node.JS WebSocket Server, Block a Request if WSS Parameter is Not 1

I would like that the node Web Socket server (command: node /root/server.js) will refuse connection if PARAM is not 1. Connection like this will be refused: wss://example.com/socket.io/?**PARAM**=**0**&EIO=3&transport=websocket如果PARAM不是 1,我希望节点 Web 套接字服务器(命令:节点/root/server.js)将拒绝连接。这样的连接将被拒绝: wss://example.com/socket.io/?**PARAM**=**0**&EIO=3&transport=websocket

server.js looks like this(EasyRTC Framework): https://github.com/open-easyrtc/open-easyrtc/blob/master/server_example/server_ssl.js server.js 看起来像这样(EasyRTC 框架): https://github.com/open-easyrtc/open-easyrtc/blob/master/server_example/server_ssl.js

I finally realized it's actually not that simple (doing inside server.js if PARAM.= 1 then exit), Anyone can confirm this complexity or offer a simple solution.我终于意识到它实际上并不是那么简单(如果 PARAM.= 1 然后退出,则在 server.js 内部执行),任何人都可以确认这种复杂性或提供一个简单的解决方案。 without recommending complex authentication frameworks.不推荐复杂的身份验证框架。 Also can't see that EasyRTC Framework will offer something like this.也看不到 EasyRTC Framework 会提供这样的东西。

Can someone lead me in the right direction because I am lost.因为我迷路了,有人能引导我朝着正确的方向前进吗?

Thank you谢谢

I crawled all the EasyRTC Group, there is an authentication system for node server.js web socket and it's very simple:我爬了所有EasyRTC群,有一个node server.js web socket的认证系统,很简单:

var onAuthenticate = function(socket, easyrtcid, appName, username, credential, easyrtcAuthMessage, next){
// do your checks
next(null); // Run next with a null if they are allowed in / or if not the socket is "disconnected" for them not for others.
};
easyrtc.events.on("authenticate", onAuthenticate);

Tested and works perfectly.经过测试并完美运行。 More testing will follow.接下来将进行更多测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM