Inline redundant local variables.

This commit is contained in:
Karsten Loesing 2018-08-21 14:10:41 +02:00
parent 5080bf9907
commit 7c44c114e4
3 changed files with 6 additions and 12 deletions

View File

@ -44,10 +44,9 @@ public class BridgeSnapshotReader {
} }
SortedSet<String> parsed = new TreeSet<>(); SortedSet<String> parsed = new TreeSet<>();
File bdDir = bridgeDirectoriesDir;
File pbdFile = new File(statsDirectory, "parsed-bridge-directories"); File pbdFile = new File(statsDirectory, "parsed-bridge-directories");
boolean modified = false; boolean modified = false;
if (bdDir.exists()) { if (bridgeDirectoriesDir.exists()) {
if (pbdFile.exists()) { if (pbdFile.exists()) {
logger.debug("Reading file {}...", pbdFile.getAbsolutePath()); logger.debug("Reading file {}...", pbdFile.getAbsolutePath());
try { try {
@ -73,7 +72,7 @@ public class BridgeSnapshotReader {
int parsedExtraInfoDescriptors = 0; int parsedExtraInfoDescriptors = 0;
int skippedExtraInfoDescriptors = 0; int skippedExtraInfoDescriptors = 0;
Stack<File> filesInInputDir = new Stack<>(); Stack<File> filesInInputDir = new Stack<>();
filesInInputDir.add(bdDir); filesInInputDir.add(bridgeDirectoriesDir);
while (!filesInInputDir.isEmpty()) { while (!filesInInputDir.isEmpty()) {
File pop = filesInInputDir.pop(); File pop = filesInInputDir.pop();
if (pop.isDirectory()) { if (pop.isDirectory()) {

View File

@ -274,11 +274,10 @@ public class SanitizedBridgesWriter extends CollecTorMain {
byte[] secret = this.getSecretForMonth(month); byte[] secret = this.getSecretForMonth(month);
System.arraycopy(secret, 0, hashInput, 24, 31); System.arraycopy(secret, 0, hashInput, 24, 31);
byte[] hashOutput = DigestUtils.sha256(hashInput); byte[] hashOutput = DigestUtils.sha256(hashInput);
String hashedAddress = "10." return "10."
+ (((int) hashOutput[0] + 256) % 256) + "." + (((int) hashOutput[0] + 256) % 256) + "."
+ (((int) hashOutput[1] + 256) % 256) + "." + (((int) hashOutput[1] + 256) % 256) + "."
+ (((int) hashOutput[2] + 256) % 256); + (((int) hashOutput[2] + 256) % 256);
return hashedAddress;
} else { } else {
return "127.0.0.1"; return "127.0.0.1";
} }
@ -1090,9 +1089,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
masterKeyEd25519, 0, masterKeyEd25519.length); masterKeyEd25519, 0, masterKeyEd25519.length);
String masterKeyEd25519Base64 = Base64.encodeBase64String( String masterKeyEd25519Base64 = Base64.encodeBase64String(
masterKeyEd25519); masterKeyEd25519);
String masterKeyEd25519Base64NoTrailingEqualSigns = return masterKeyEd25519Base64.replaceAll("=", "");
masterKeyEd25519Base64.replaceAll("=", "");
return masterKeyEd25519Base64NoTrailingEqualSigns;
} }
extensionStart += 4 + extensionLength; extensionStart += 4 + extensionLength;
} }

View File

@ -146,16 +146,14 @@ public class CreateIndexJson extends CollecTorMain {
} }
} }
} }
DirectoryNode directoryNode = new DirectoryNode( return new DirectoryNode(
directory.getName(), fileNodes.isEmpty() ? null : fileNodes, directory.getName(), fileNodes.isEmpty() ? null : fileNodes,
directoryNodes.isEmpty() ? null : directoryNodes); directoryNodes.isEmpty() ? null : directoryNodes);
return directoryNode;
} }
private FileNode indexFile(File file) { private FileNode indexFile(File file) {
FileNode fileNode = new FileNode(file.getName(), file.length(), return new FileNode(file.getName(), file.length(),
dateTimeFormat.format(file.lastModified())); dateTimeFormat.format(file.lastModified()));
return fileNode;
} }
private void writeIndex(IndexNode indexNode) throws Exception { private void writeIndex(IndexNode indexNode) throws Exception {