[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r21895: {projects} Don't exit when running into an unrecognized line, but skip (projects/archives/trunk/bridge-desc-sanitizer)
Author: kloesing
Date: 2010-03-09 18:35:43 +0000 (Tue, 09 Mar 2010)
New Revision: 21895
Modified:
projects/archives/trunk/bridge-desc-sanitizer/ConvertBridgeDescs.java
Log:
Don't exit when running into an unrecognized line, but skip the descriptor.
Modified: projects/archives/trunk/bridge-desc-sanitizer/ConvertBridgeDescs.java
===================================================================
--- projects/archives/trunk/bridge-desc-sanitizer/ConvertBridgeDescs.java 2010-03-09 18:16:36 UTC (rev 21894)
+++ projects/archives/trunk/bridge-desc-sanitizer/ConvertBridgeDescs.java 2010-03-09 18:35:43 UTC (rev 21895)
@@ -140,6 +140,7 @@
String line = null;
StringBuilder original = null, scrubbed = null;
boolean skipSignature = false;
+ boolean skipDescriptor = false;
while ((line = br.readLine()) != null) {
if (skipSignature && !line.equals("-----END SIGNATURE-----")) {
continue;
@@ -157,33 +158,38 @@
original.append(line + "\n");
scrubbed.append(line + "\n");
} else if (line.startsWith("router-signature")) {
- String originalDesc = original.toString() + line + "\n";
- String originalHash = DigestUtils.shaHex(originalDesc);
- String countryCode = "ZZ";
- if (bridgeCountries.containsKey(originalHash.toUpperCase())) {
- countryCode = bridgeCountries.get(originalHash.toUpperCase());
+ if (skipDescriptor) {
+ System.out.println("Skipping!");
+ skipDescriptor = false;
+ } else {
+ String originalDesc = original.toString() + line + "\n";
+ String originalHash = DigestUtils.shaHex(originalDesc);
+ String countryCode = "ZZ";
+ if (bridgeCountries.containsKey(originalHash.toUpperCase())) {
+ countryCode = bridgeCountries.get(originalHash.toUpperCase());
+ }
+ String scrubbedDesc = "extra-info Unnamed" + countryCode + " "
+ + scrubbed.toString();
+ String scrubbedHash = DigestUtils.shaHex(scrubbedDesc);
+ if (extrainfoMapping.containsKey(originalHash) &&
+ !extrainfoMapping.get(originalHash).equals(scrubbedHash)) {
+ System.out.println("We already have an extra-info mapping "
+ + "from " + originalHash + " to "
+ + extrainfoMapping.get(originalHash) + ", but we now want "
+ + "to add a mapping to " + scrubbedHash + ". Exiting");
+ System.exit(1);
+ }
+ extrainfoMapping.put(originalHash, scrubbedHash);
+ File out = new File(outDir + File.separator + "extra-infos"
+ + File.separator + scrubbedHash.charAt(0) + File.separator
+ + scrubbedHash.charAt(1) + File.separator + scrubbedHash);
+ if (!out.exists()) {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(out));
+ bw.write(scrubbedDesc);
+ bw.close();
+ writtenExtrainfos++;
+ }
}
- String scrubbedDesc = "extra-info Unnamed" + countryCode + " "
- + scrubbed.toString();
- String scrubbedHash = DigestUtils.shaHex(scrubbedDesc);
- if (extrainfoMapping.containsKey(originalHash) &&
- !extrainfoMapping.get(originalHash).equals(scrubbedHash)) {
- System.out.println("We already have an extra-info mapping "
- + "from " + originalHash + " to "
- + extrainfoMapping.get(originalHash) + ", but we now want "
- + "to add a mapping to " + scrubbedHash + ". Exiting");
- System.exit(1);
- }
- extrainfoMapping.put(originalHash, scrubbedHash);
- File out = new File(outDir + File.separator + "extra-infos"
- + File.separator + scrubbedHash.charAt(0) + File.separator
- + scrubbedHash.charAt(1) + File.separator + scrubbedHash);
- if (!out.exists()) {
- BufferedWriter bw = new BufferedWriter(new FileWriter(out));
- bw.write(scrubbedDesc);
- bw.close();
- writtenExtrainfos++;
- }
} else if (line.equals("-----BEGIN SIGNATURE-----")) {
skipSignature = true;
} else if (line.equals("-----END SIGNATURE-----")) {
@@ -192,8 +198,8 @@
|| line.startsWith("exit-")) {
original.append(line + "\n");
} else {
- System.out.println("Unrecognized line '" + line + "'. Exiting");
- System.exit(1);
+ System.out.println("Unrecognized line '" + line + "'. Skipping");
+ skipDescriptor = true;
}
}
br.close();