imToken v2.14.1版本的 MD5 值为:83050b2c91219b46832c8336279e7878
以下内容为反编译后的 TrustedAuthorities.java 源代码,内容仅作参考
package com.subgraph.orchid.directory;
import com.subgraph.orchid.DirectoryServer;
import com.subgraph.orchid.Tor;
import com.subgraph.orchid.data.HexDigest;
import com.subgraph.orchid.data.IPv4Address;
import com.subgraph.orchid.directory.parsing.DocumentFieldParser;
import com.subgraph.orchid.directory.parsing.DocumentParsingHandler;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
public class TrustedAuthorities {
private final List<DirectoryServer> directoryServers = new ArrayList();
private final int v3ServerCount;
private static final String[] dirServers = {"authority moria1 orport=9101 no-v2 v3ident=D586D18309DED4CD6D57C18FDB97EFA96D330566 128.31.0.39:9131 9695 DFC3 5FFE B861 329B 9F1A B04C 4639 7020 CE31", "authority tor26 v1 orport=443 v3ident=14C131DFC5C6F93646BE72FA1401C02A8DF2E8B4 86.59.21.38:80 847B 1F85 0344 D787 6491 A548 92F9 0493 4E4E B85D", "authority dizum orport=443 v3ident=E8A9C45EDE6D711294FADF8E7951F4DE6CA56B58 194.109.206.212:80 7EA6 EAD6 FD83 083C 538F 4403 8BBF A077 587D D755", "authority Tonga orport=443 bridge no-v2 82.94.251.203:80 4A0C CD2D DC79 9508 3D73 F5D6 6710 0C8A 5831 F16D", "authority longclaw orport=9090 no-v2 v3ident=23D15D965BC35114467363C165C4F724B64B4F66 202.85.227.202:80 74A9 1064 6BCE EFBC D2E8 74FC 1DC9 9743 0F96 8145", "authority dannenberg orport=443 no-v2 v3ident=585769C78764D58426B8B52B6651A5A71137189A 193.23.244.244:80 7BE6 83E6 5D48 1413 21C5 ED92 F075 C553 64AC 7123", "authority urras orport=80 no-v2 v3ident=80550987E1D626E3EBA5E5E75A458DE0626D088C 208.83.223.34:443 0AD3 FA88 4D18 F89E EA2D 89C0 1937 9E0E 7FD9 4417", "authority maatuska orport=80 no-v2 v3ident=49015F787433103580E3B66A1707A00E60F2D15B 171.25.193.9:443 BD6A 8292 55CB 08E6 6FBE 7D37 4836 3586 E46B 3810", "authority Faravahar orport=443 no-v2 v3ident=EFCBE720AB3A82B99F9E953CD5BF50F7EEFC7B97 154.35.32.5:80 CF6D 0AAF B385 BE71 B8E1 11FC 5CFF 4B47 9237 33BC", "authority gabelmoo orport=443 no-v2 v3ident=ED03BB616EB2F60BEC80151114BB25CEF515B226 212.112.245.170:80 F204 4413 DAC2 E02E 3D6B CF47 35A1 9BCA 1DE9 7281"};
private static final TrustedAuthorities _instance = new TrustedAuthorities();
public static TrustedAuthorities getInstance() {
return _instance;
}
private TrustedAuthorities() {
initialize();
this.v3ServerCount = countV3Servers();
}
private int countV3Servers() {
int i2 = 0;
for (DirectoryServer directoryServer : this.directoryServers) {
if (directoryServer.getV3Identity() != null) {
i2++;
}
}
return i2;
}
void initialize() {
StringBuilder sb = new StringBuilder();
for (String str : dirServers) {
sb.append(str);
sb.append('\n');
}
final DocumentFieldParserImpl documentFieldParserImpl = new DocumentFieldParserImpl(ByteBuffer.wrap(sb.toString().getBytes(Tor.getDefaultCharset())));
documentFieldParserImpl.setHandler(new DocumentParsingHandler() {
@Override
public void endOfDocument() {
}
@Override
public void parseKeywordLine() {
TrustedAuthorities.this.processKeywordLine(documentFieldParserImpl);
}
});
documentFieldParserImpl.processDocument();
}
public void processKeywordLine(DocumentFieldParser documentFieldParser) {
DirectoryAuthorityStatus directoryAuthorityStatus = new DirectoryAuthorityStatus();
directoryAuthorityStatus.setNickname(documentFieldParser.parseNickname());
while (documentFieldParser.argumentsRemaining() > 0) {
processArgument(documentFieldParser, directoryAuthorityStatus);
}
}
private void processArgument(DocumentFieldParser documentFieldParser, DirectoryAuthorityStatus directoryAuthorityStatus) {
String parseString = documentFieldParser.parseString();
if (Character.isDigit(parseString.charAt(0))) {
parseAddressPort(documentFieldParser, parseString, directoryAuthorityStatus);
directoryAuthorityStatus.setIdentity(documentFieldParser.parseFingerprint());
DirectoryServerImpl directoryServerImpl = new DirectoryServerImpl(directoryAuthorityStatus);
if (directoryAuthorityStatus.getV3Ident() != null) {
directoryServerImpl.setV3Ident(directoryAuthorityStatus.getV3Ident());
}
documentFieldParser.logDebug("Adding trusted authority: " + directoryServerImpl);
this.directoryServers.add(directoryServerImpl);
return;
}
parseFlag(documentFieldParser, parseString, directoryAuthorityStatus);
}
private void parseAddressPort(DocumentFieldParser documentFieldParser, String str, DirectoryAuthorityStatus directoryAuthorityStatus) {
String[] split = str.split(":");
directoryAuthorityStatus.setAddress(IPv4Address.createFromString(split[0]));
directoryAuthorityStatus.setDirectoryPort(documentFieldParser.parsePort(split[1]));
}
private void parseFlag(DocumentFieldParser documentFieldParser, String str, DirectoryAuthorityStatus directoryAuthorityStatus) {
if (str.equals("v1")) {
directoryAuthorityStatus.setV1Authority();
directoryAuthorityStatus.setHiddenServiceAuthority();
} else if (str.equals("hs")) {
directoryAuthorityStatus.setHiddenServiceAuthority();
} else if (str.equals("no-hs")) {
directoryAuthorityStatus.unsetHiddenServiceAuthority();
} else if (str.equals("bridge")) {
directoryAuthorityStatus.setBridgeAuthority();
} else if (str.equals("no-v2")) {
directoryAuthorityStatus.unsetV2Authority();
} else if (str.startsWith("orport=")) {
directoryAuthorityStatus.setRouterPort(documentFieldParser.parsePort(str.substring(7)));
} else if (str.startsWith("v3ident=")) {
directoryAuthorityStatus.setV3Ident(HexDigest.createFromString(str.substring(8)));
}
}
public int getV3AuthorityServerCount() {
return this.v3ServerCount;
}
public List<DirectoryServer> getAuthorityServers() {
return this.directoryServers;
}
public DirectoryServer getAuthorityServerByIdentity(HexDigest hexDigest) {
for (DirectoryServer directoryServer : this.directoryServers) {
if (hexDigest.equals(directoryServer.getV3Identity())) {
return directoryServer;
}
}
return null;
}
}