commit ca201de75e451e1131e1ae68f7cdfb24280c36be Author: Karsten Loesing karsten.loesing@gmx.net Date: Fri Jun 29 13:54:31 2012 +0200
Parse transport lines in bridge extra-infos. --- .../torproject/descriptor/ExtraInfoDescriptor.java | 4 ++++ .../descriptor/impl/ExtraInfoDescriptorImpl.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/org/torproject/descriptor/ExtraInfoDescriptor.java b/src/org/torproject/descriptor/ExtraInfoDescriptor.java index 229b075..05707a5 100644 --- a/src/org/torproject/descriptor/ExtraInfoDescriptor.java +++ b/src/org/torproject/descriptor/ExtraInfoDescriptor.java @@ -237,5 +237,9 @@ public interface ExtraInfoDescriptor extends Descriptor { * have connected from that country rounded up to the nearest multiple * of 8, or null if no bridge statistics are included. */ public SortedMap<String, Integer> getBridgeIps(); + + /* Return the (possibly empty) list of transports supported by this + * bridge. */ + public List<String> getTransports(); }
diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java index f6e0fd9..0a0bf1a 100644 --- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java @@ -166,6 +166,8 @@ public class ExtraInfoDescriptorImpl extends DescriptorImpl this.parseBridgeStatsEndLine(line, lineNoOpt, partsNoOpt); } else if (keyword.equals("bridge-ips")) { this.parseBridgeStatsIpsLine(line, lineNoOpt, partsNoOpt); + } else if (keyword.equals("transport")) { + this.parseTransportLine(line, lineNoOpt, partsNoOpt); } else if (keyword.equals("router-signature")) { this.parseRouterSignatureLine(line, lineNoOpt, partsNoOpt); } else if (keyword.equals("router-digest")) { @@ -567,6 +569,14 @@ public class ExtraInfoDescriptorImpl extends DescriptorImpl partsNoOpt, 1, 2); }
+ private void parseTransportLine(String line, String lineNoOpt, + String[] partsNoOpt) throws DescriptorParseException { + if (partsNoOpt.length != 2) { + throw new DescriptorParseException("Illegal line '" + line + "'."); + } + this.transports.add(partsNoOpt[1]); + } + private void parseRouterSignatureLine(String line, String lineNoOpt, String[] partsNoOpt) throws DescriptorParseException { if (!lineNoOpt.equals("router-signature")) { @@ -869,5 +879,10 @@ public class ExtraInfoDescriptorImpl extends DescriptorImpl return this.bridgeIps == null ? null : new TreeMap<String, Integer>(this.bridgeIps); } + + private List<String> transports = new ArrayList<String>(); + public List<String> getTransports() { + return new ArrayList<String>(this.transports); + } }
tor-commits@lists.torproject.org