管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-15 fd098f67ef7e57f7165c06519a3f238f9d4529b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package com.lf.server.entity.other;
 
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
 
/**
 * ReqParamFloatServer
 * @author WWW
 */
public class ReqParamFloatServer {
    private String id;
 
    private String port;
 
    private String modules;
 
    private int availableNum;
 
    private long time;
 
    private String localId;
 
    private String cmdType;
 
    public ReqParamFloatServer() {
        this.localId = a();
    }
 
    public ReqParamFloatServer(String id, String port) {
        this.id = id;
        this.port = port;
        this.localId = a();
    }
 
    public String getPort() {
        return this.port;
    }
 
    public void setPort(final String port) {
        this.port = port;
    }
 
    public String getId() {
        return this.id;
    }
 
    public void setId(final String id) {
        this.id = id;
    }
 
    public String getModules() {
        return this.modules;
    }
 
    public void setModules(final String modules) {
        this.modules = modules;
    }
 
    public int getAvailableNum() {
        return this.availableNum;
    }
 
    public void setAvailableNum(final int availableNum) {
        this.availableNum = availableNum;
    }
 
    public long getTime() {
        return this.time;
    }
 
    public void setTime(final long time) {
        this.time = time;
    }
 
    public String getLocalId() {
        return this.localId;
    }
 
    public String getCmdType() {
        return this.cmdType;
    }
 
    public void setCmdType(final String cmdType) {
        this.cmdType = cmdType;
    }
 
    public static String a() {
        String string = "";
        try {
            final Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                final NetworkInterface networkInterface;
                if (!(networkInterface = networkInterfaces.nextElement()).isLoopback() && !networkInterface.isVirtual() && networkInterface.isUp()) {
                    final Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
                    final byte[] hardwareAddress;
                    if ((hardwareAddress = networkInterface.getHardwareAddress()) == null || networkInterface.getName().contains("docker")) {
                        continue;
                    }
                    while (inetAddresses.hasMoreElements()) {
                        final InetAddress inetAddress;
                        if ((inetAddress = inetAddresses.nextElement()) != null && inetAddress instanceof Inet4Address) {
                            final String a = a(inetAddress);
                            string = String.valueOf(inetAddress.getHostAddress()) + "|" + a;
                            if (!a.isEmpty()) {
                                return string;
                            }
                            continue;
                        }
                    }
                }
            }
        } catch (SocketException ex) {
            //
        }
        return string;
    }
 
    private static String a(final InetAddress addr) {
        String upperCase = "";
        try {
            final byte[] hardwareAddress = NetworkInterface.getByInetAddress(addr).getHardwareAddress();
            final StringBuffer sb = new StringBuffer("");
            for (int i = 0; i < hardwareAddress.length; ++i) {
                if (i != 0) {
                    sb.append("-");
                }
                final String hexString;
                if ((hexString = Integer.toHexString(hardwareAddress[i] & 0xFF)).length() == 1) {
                    sb.append("0".concat(String.valueOf(hexString)));
                } else {
                    sb.append(hexString);
                }
            }
            upperCase = sb.toString().toUpperCase();
        } catch (Exception ex) {
            //
        }
        return upperCase;
    }
}