[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-lib/master] Recognize bandwidth files with @type annotation.



commit f8afa3930d800e139b4e1ca540961ac4a097c11b
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Thu May 16 15:54:13 2019 +0200

    Recognize bandwidth files with @type annotation.
    
    Fixes part of #30525.
---
 CHANGELOG.md                                                        | 6 ++++++
 .../java/org/torproject/descriptor/impl/DescriptorParserImpl.java   | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e70572..d1aa923 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# Changes in version 2.6.2 - 2019-05-??
+
+ * Medium changes
+   - Recognize bandwidth files with @type annotation.
+
+
 # Changes in version 2.6.1 - 2019-05-03
 
  * Medium changes
diff --git a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
index 08ac909..ef9da56 100644
--- a/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/DescriptorParserImpl.java
@@ -132,7 +132,8 @@ public class DescriptorParserImpl implements DescriptorParser {
           sourceFile);
     } else if (fileName.contains(LogDescriptorImpl.MARKER)) {
       return LogDescriptorImpl.parse(rawDescriptorBytes, sourceFile, fileName);
-    } else if (firstLines.matches("(?s)[0-9]{10}\\n.*")) {
+    } else if (firstLines.startsWith("@type bandwidth-file 1.")
+        || firstLines.matches("(?s)[0-9]{10}\\n.*")) {
       /* Identifying bandwidth files by a 10-digit timestamp in the first line
        * breaks with files generated before 2002 or after 2286 and when the next
        * descriptor identifier starts with just a timestamp in the first line

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits