简体   繁体   English

如何通过端点请求获取用户的mac地址

[英]how to get the mac Address , user , through an end-point request

I have a controller that when accessing it I need to get the ip, user, macAdress information that are accessing this new end-point.我有一个 controller,访问它时我需要获取正在访问此新端点的 ip、用户、macAdress 信息。 I have the code below and I would like to get this other information I need.我有下面的代码,我想获得我需要的其他信息。 Can you help me?你能帮助我吗?

@RequestMapping(value = "/account", method = RequestMethod.GET)
public String getIp(HttpServletRequest request) {
    
    String ipAddress = request.getHeader("X-FORWARDED-FOR");
    if (ipAddress == null) {
        ipAddress = request.getRemoteAddr();
    }

    return "page";
}

As you can see from the image below, a Network Layer packet does not contain fields for transporting the information you are asking about.从下图中可以看出,网络层数据包不包含用于传输您询问的信息的字段。

在此处输入图像描述

However, nothing stops you from putting this information on the payload.但是,没有什么能阻止您将此信息放在有效载荷上。 You could, for instance, establish a format for messages exchanged between applications where the sender's MAC address and the signed-in username is stored.例如,您可以为在存储发件人的 MAC 地址和登录用户名的应用程序之间交换的消息建立格式。 The receiver could then extract this information from the payload.然后接收器可以从有效载荷中提取此信息。

I think you should be able to do something like this:我认为你应该能够做这样的事情:

{
  "metadata":
  {
    "username" : "hector",
    "mac" : "00:00:00:00:00:00"
  },
  "payload" : {-WHATEVER YOU'RE SENDING HERE-}
}

In XML XML

<?xml version="1.0" encoding="UTF-8" ?>
<metadata>
    <username>hector</username>
    <mac>00:00:00:00:00:00</mac>
</metadata>
<payload>...</payload>

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

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