Get IP address from WebSocket in browser

巧了我就是萌 提交于 2019-12-13 03:33:02

问题


I need to get the IP address of a WebSocket and compare it to other already connected WebSockets to prevent redundant connections because the list of server addresses for this application are retrieved from potentially malicious sources.

I've examined the WebSocket object and the specification, and it appears that the url can be returned but not the IP.

How can the IP be retrieved from the WebSocket connection in a browser?


回答1:


AFAIK, there is no such way to get resolve IP from url, you may use external services, check http://www.fileformat.info/tool/rest/dns-json.htm




回答2:


It is not possible to derive the IP address based on a WebSocket object in a browser for security reasons.

In case you are connecting to your own server, you can setup the WebSockets to communicate the IP with the browser when the connection is first established. Although, this would seriously undermine your security.



来源:https://stackoverflow.com/questions/24213590/get-ip-address-from-websocket-in-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!