简体   繁体   English

如何在 Restful web 服务中访问客户端的 MAC 地址

[英]How to access client's MAC address in Restful web services

I have a angular application, which is making a rest call as:我有一个 angular 应用程序,它正在将 rest 调用为:

http://localhost:8765/test/iptest

And in my controller:在我的 controller 中:

@GetMapping(value = "test/iptest")
public ResponseEntity<Object> doTest() {
    log.debug("Inside Test");
    return new ResponseEntity<>("Test success", HttpStatus.OK);
}

How do I access client's IP and MAC address using this request?如何使用此请求访问客户端的IPMAC 地址

EDIT: I was able to access Client's IP Address using HttpServletRequest as:编辑:我能够使用HttpServletRequest访问客户的 IP 地址:

    import javax.servlet.http.HttpServletRequest;
    import javax.ws.rs.core.Context;

    @GetMapping(value = "test/iptest")
    public ResponseEntity<Object> doTest(@Context HttpServletRequest request) {
        log.debug("IP Address is:"+request.getRemoteAddr());
        return new ResponseEntity<>("Test success", HttpStatus.OK);
    }

But I'm not able to access MAC ADDRESS但我无法访问MAC 地址

You can't - other than on the local LAN, remote MAC addresses are not exposed to your end point.您不能 - 除了在本地 LAN 上,远程 MAC 地址不会暴露给您的端点。 The MAC address in the Ethernet header of the packet received at the server will be that of the nearest router that was the last hop in the path.在服务器收到的数据包的以太网 header 中的 MAC 地址将是路径中最后一跳最近的路由器的 MAC 地址。

Even on the local LAN you cannot get this information for an IP socket - looking up a local MAC address requires poking around in the OS's ARP tables.即使在本地 LAN 上,您也无法获取 IP 套接字的此信息 - 查找本地 MAC 地址需要在操作系统的 ARP 表中四处寻找。

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

相关问题 如何基于curl编写RESTful Web服务客户端 - How to write RESTful web services client based on curl 如何获取OAuth2.0访问令牌并使用此令牌通过Java客户端代码调用RESTFul Web服务? - How to fetch OAuth2.0 Access Token and use this token to call RESTFul Web services using Java client code? 客户端和RESTful Web服务之间的通信 - Communication between Client and RESTful web services 如何在Web应用程序中查找客户端系统mac地址 - how to find client system mac address in web application 如何从HttpServlet获取客户端的MAC地址? - how to get a client's MAC address from HttpServlet? 如何在Spring Restful Web Services中使用Rest Client传递输入参数 - How to pass input parameters using rest client in spring restful web services 如何将DTO传递到Restful Web服务 - How to Pass the DTO to the Restful web services 如何使用RESTFul Web服务发送请求? - How to send request, by using RESTFul web services? 如何在java中使用RESTful Web服务获取远程/客户端IP地址? - How to get Remote / Client IP address using RESTful web service in java? 宁静的Web服务运行在localhost apache tomcat上,如何通过Internet从其他计算机访问 - Restful Web services run on localhost apache tomcat, how to access from other computer over internet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM