-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNTSConfig.java
More file actions
73 lines (67 loc) · 1.82 KB
/
Copy pathNTSConfig.java
File metadata and controls
73 lines (67 loc) · 1.82 KB
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
package nts;
import java.util.ArrayList;
import java.util.List;
import nts.NTSKERecords.*;
public class NTSConfig {
public Constants.NTSNextProtocols NTSProtocol;
public Constants.AEADAlgorithms AEADAlgorithm;
public List<byte[]> cookies = new ArrayList<>();
public String host;
public int port;
public byte[] C2SKey;
public byte[] S2CKey;
public NTSConfig(
Constants.NTSNextProtocols NTSProtocol,
Constants.AEADAlgorithms AEADAlgorithm,
List<byte[]> cookies,
String host,
int port,
byte[] C2SKey,
byte[] S2CKey) {
this.NTSProtocol = NTSProtocol;
this.AEADAlgorithm = AEADAlgorithm;
this.cookies = cookies;
this.host = host;
this.port = port;
this.C2SKey = C2SKey;
this.S2CKey = S2CKey;
}
public NTSConfig() {
// Default constructor
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("NTSConfig {")
.append("\n NTSProtocol: ")
.append(NTSProtocol)
.append("\n AEADAlgorithm: ")
.append(AEADAlgorithm)
.append("\n cookies: [");
if (cookies != null) {
for (int i = 0; i < cookies.size(); i++) {
sb.append(bytesToHex(cookies.get(i)));
if (i < cookies.size() - 1) sb.append(", ");
}
}
sb.append("]")
.append("\n host: ")
.append(host)
.append("\n port: ")
.append(port)
.append("\n C2SKey: ")
.append(bytesToHex(C2SKey))
.append("\n S2CKey: ")
.append(bytesToHex(S2CKey))
.append("\n}");
return sb.toString();
}
private static String bytesToHex(byte[] bytes) {
if (bytes == null) return "null";
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02X", b));
}
return sb.toString();
}
}