简体   繁体   中英

Get IP address from WebSocket in browser

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?

AFAIK,没有这种方法可以从URL获取解析IP,您可以使用外部服务,请查看http://www.fileformat.info/tool/rest/dns-json.htm

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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