tor-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2016
- 20 participants
- 1204 discussions
commit a149675b7bcd8c78ee6573344e7d0a280a35cda7
Author: Sambuddha Basu <sambuddhabasu1(a)gmail.com>
Date: Mon Jun 13 23:48:46 2016 -0700
Updated event dialogbox tests
---
test/popups.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/test/popups.py b/test/popups.py
index 4eecc94..a526927 100644
--- a/test/popups.py
+++ b/test/popups.py
@@ -94,6 +94,9 @@ Config Option Ordering:--------------------------------------------------------+
EXPECTED_EVENT_SELECTOR = """
Event Types:-------------------------------------------------------------------+
+| |
+| |
++------------------------------------------------------------------------------|
|Tor Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
|Nyx Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
+------------------------------------------------------------------------------+
@@ -104,6 +107,9 @@ Event Types:-------------------------------------------------------------------+
EXPECTED_EVENT_SELECTOR_UP_DOWN = """
Event Types:-------------------------------------------------------------------+
+| |
+| |
++------------------------------------------------------------------------------|
|Tor Runlevel: [X] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
|Nyx Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
+------------------------------------------------------------------------------+
@@ -115,6 +121,9 @@ Event Types:-------------------------------------------------------------------+
EXPECTED_EVENT_SELECTOR_LEFT_RIGHT = """
Event Types:-------------------------------------------------------------------+
+| |
+| |
++------------------------------------------------------------------------------|
|Tor Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
|Nyx Runlevel: [X] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
+------------------------------------------------------------------------------+
@@ -126,6 +135,9 @@ Event Types:-------------------------------------------------------------------+
EXPECTED_EVENT_SELECTOR_CANCEL = """
Event Types:-------------------------------------------------------------------+
+| |
+| |
++------------------------------------------------------------------------------|
|Tor Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
|Nyx Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
+------------------------------------------------------------------------------+
@@ -137,6 +149,9 @@ Event Types:-------------------------------------------------------------------+
EXPECTED_EVENT_SELECTOR_INITIAL_SELECTION = """
Event Types:-------------------------------------------------------------------+
+| |
+| |
++------------------------------------------------------------------------------|
|Tor Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
|Nyx Runlevel: [ ] DEBUG [ ] INFO [ ] NOTICE [ ] WARN [ ] ERR |
+------------------------------------------------------------------------------+
1
0
commit 78f5e41aafb6904f31e3d94f8f452cbcb110604a
Author: Damian Johnson <atagar(a)torproject.org>
Date: Mon Jun 13 08:32:45 2016 -0700
Simpler coloring for event popup
On reflection using the event colors makes it harder to read the text so just
opting for bold green (giving the dialog a little color while still being
readable). Also fixing an issue with addstr_wrap() that caused us to have an
extra space when wrapping to new lines.
---
nyx/curses.py | 1 +
nyx/popups.py | 11 +----------
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/nyx/curses.py b/nyx/curses.py
index f357443..a02adc8 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -575,6 +575,7 @@ class _Subwindow(object):
draw_msg, msg = stem.util.str_tools.crop(msg, width - x), '' # first word is longer than the line
x = self.addstr(x, y, draw_msg, *attr)
+ msg = msg.lstrip()
if (y - orig_y + 1) >= CONFIG['features.maxLineWrap']:
break # maximum number we'll wrap
diff --git a/nyx/popups.py b/nyx/popups.py
index c588aad..3127e67 100644
--- a/nyx/popups.py
+++ b/nyx/popups.py
@@ -36,13 +36,6 @@ from nyx.curses import RED, GREEN, YELLOW, CYAN, WHITE, NORMAL, BOLD, HIGHLIGHT
import stem.control
import stem.util.str_tools
-from stem.util import conf
-
-
-CONFIG = conf.config_dict('nyx', {
- 'attr.log_color': {},
-})
-
NO_STATS_MSG = "Usage stats aren't available yet, press any key..."
HEADERS = ['Consensus:', 'Microdescriptor:', 'Server Descriptor:']
@@ -427,9 +420,7 @@ def select_event_types(initial_selection):
event = events[selection - 10]
if event:
- color = CONFIG['attr.log_color'].get(event, WHITE) if event in nyx.log.TOR_RUNLEVELS else WHITE
- subwindow.addstr_wrap(1, 1, stem.control.event_description(event), subwindow.width - 1, 0, color)
- subwindow._addch(0, 2, curses.ACS_VLINE)
+ subwindow.addstr_wrap(1, 1, stem.control.event_description(event), subwindow.width - 1, 1, GREEN, BOLD)
subwindow.hline(1, 3, 78)
subwindow._addch(0, 3, curses.ACS_LTEE)
1
0

14 Jun '16
commit afa8e3a17c29e0f3c8f48a0f7c33efe743e7f6ab
Author: Damian Johnson <atagar(a)torproject.org>
Date: Tue Jun 14 08:32:33 2016 -0700
Account for event_description() being None
When Stem doesn't recognize an event its event_description() function provides
None. Accounting for this.
---
nyx/popups.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/nyx/popups.py b/nyx/popups.py
index 3127e67..8cadf05 100644
--- a/nyx/popups.py
+++ b/nyx/popups.py
@@ -411,16 +411,15 @@ def select_event_types(initial_selection):
subwindow.box()
subwindow.addstr(0, 0, 'Event Types:', HIGHLIGHT)
- event = None
- if selection < 5:
- event = nyx.log.TOR_RUNLEVELS[selection]
- elif selection < 10:
- event = nyx.log.TOR_RUNLEVELS[selection - 5]
+ if selection < 10:
+ description = stem.control.event_description(nyx.log.TOR_RUNLEVELS[selection % 5])
elif selection < (len(events) + 10):
- event = events[selection - 10]
+ description = stem.control.event_description(events[selection - 10])
+ else:
+ description = None
- if event:
- subwindow.addstr_wrap(1, 1, stem.control.event_description(event), subwindow.width - 1, 1, GREEN, BOLD)
+ if description:
+ subwindow.addstr_wrap(1, 1, description, subwindow.width - 1, 1, GREEN, BOLD)
subwindow.hline(1, 3, 78)
subwindow._addch(0, 3, curses.ACS_LTEE)
1
0
commit f3319a4ba62d5aefabd10e1dd9011208ca11aeb9
Author: Damian Johnson <atagar(a)torproject.org>
Date: Tue Jun 14 08:24:49 2016 -0700
Fix popup module's descriptor test
Earlier fix of the addstr_wrap() broke one of these. Easy fix.
---
test/popups.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/popups.py b/test/popups.py
index a526927..02dc6a1 100644
--- a/test/popups.py
+++ b/test/popups.py
@@ -219,7 +219,7 @@ Consensus Descriptor (29787760145CD1A473552A2FC64C72A9A130820E):---------------+
| 1 Consensus: |
| 2 |
| 3 r cyberphunk KXh3YBRc0aRzVSovxkxyqaEwgg4 VjdJThHuYj0jDY2tkkDJkCa8s1s |
-| 2016-04-04 19:03:16 94.23.150.191 8080 0 |
+| 2016-04-04 19:03:16 94.23.150.191 8080 0 |
| 4 s Fast Guard Running Stable Valid |
| 5 w Bandwidth=8410 |
| 6 p reject 1-65535 |
1
0
commit d8332a97046e6af3bda32d847126781a9a19145b
Author: Sambuddha Basu <sambuddhabasu1(a)gmail.com>
Date: Fri Jun 10 20:25:09 2016 -0700
Added event description for dialog box
---
nyx/popups.py | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/nyx/popups.py b/nyx/popups.py
index 5bfb2f8..9e819da 100644
--- a/nyx/popups.py
+++ b/nyx/popups.py
@@ -33,6 +33,7 @@ import nyx.panel
from nyx.curses import RED, GREEN, YELLOW, CYAN, WHITE, NORMAL, BOLD, HIGHLIGHT
+import stem.control
import stem.util.str_tools
NO_STATS_MSG = "Usage stats aren't available yet, press any key..."
@@ -410,25 +411,36 @@ def select_event_types(initial_selection):
subwindow.box()
subwindow.addstr(0, 0, 'Event Types:', HIGHLIGHT)
- x = subwindow.addstr(1, 1, 'Tor Runlevel:')
+ event = None
+ if selection < 5:
+ event = nyx.log.TOR_RUNLEVELS[selection]
+ elif selection < 10:
+ event = nyx.log.TOR_RUNLEVELS[selection - 5]
+ elif selection < (len(events) + 10):
+ event = events[selection - 10]
+
+ if event:
+ subwindow.addstr_wrap(1, 1, stem.control.event_description(event), subwindow.width - 1, 1)
+
+ x = subwindow.addstr(1, 4, 'Tor Runlevel:')
for i, event in enumerate(nyx.log.TOR_RUNLEVELS):
- x = subwindow.addstr(x + 4, 1, '[X]' if event in selected_events else '[ ]')
- x = subwindow.addstr(x + 1, 1, event, HIGHLIGHT if selection == i else NORMAL)
+ x = subwindow.addstr(x + 4, 4, '[X]' if event in selected_events else '[ ]')
+ x = subwindow.addstr(x + 1, 4, event, HIGHLIGHT if selection == i else NORMAL)
- x = subwindow.addstr(1, 2, 'Nyx Runlevel:')
+ x = subwindow.addstr(1, 5, 'Nyx Runlevel:')
for i, event in enumerate(nyx.log.NYX_RUNLEVELS):
- x = subwindow.addstr(x + 4, 2, '[X]' if event in selected_events else '[ ]')
- x = subwindow.addstr(x + 1, 2, nyx.log.TOR_RUNLEVELS[i], HIGHLIGHT if selection == (i + 5) else NORMAL)
+ x = subwindow.addstr(x + 4, 5, '[X]' if event in selected_events else '[ ]')
+ x = subwindow.addstr(x + 1, 5, nyx.log.TOR_RUNLEVELS[i], HIGHLIGHT if selection == (i + 5) else NORMAL)
- subwindow.hline(1, 3, 78)
- subwindow._addch(0, 3, curses.ACS_LTEE)
- subwindow._addch(79, 3, curses.ACS_RTEE)
+ subwindow.hline(1, 6, 78)
+ subwindow._addch(0, 6, curses.ACS_LTEE)
+ subwindow._addch(79, 6, curses.ACS_RTEE)
for i, event in enumerate(events):
- x = subwindow.addstr((i % 3) * 25 + 1, i / 3 + 4, '[X]' if event in selected_events else '[ ]')
- x = subwindow.addstr(x + 1, i / 3 + 4, event, HIGHLIGHT if selection == (i + 10) else NORMAL)
+ x = subwindow.addstr((i % 3) * 25 + 1, i / 3 + 7, '[X]' if event in selected_events else '[ ]')
+ x = subwindow.addstr(x + 1, i / 3 + 7, event, HIGHLIGHT if selection == (i + 10) else NORMAL)
x = subwindow.width - 14
@@ -439,7 +451,7 @@ def select_event_types(initial_selection):
with nyx.curses.CURSES_LOCK:
while True:
- nyx.curses.draw(_render, top = _top(), width = 80, height = (len(events) / 3) + 7)
+ nyx.curses.draw(_render, top = _top(), width = 80, height = (len(events) / 3) + 10)
key = nyx.curses.key_input()
if key.match('up'):
1
0

14 Jun '16
commit ec4987112695ab338e854c37458a3f811b9ce8f1
Author: David Goulet <dgoulet(a)ev0ke.net>
Date: Tue Jun 14 10:53:56 2016 -0400
Fix wrong tor_address check for NULL
Signed-off-by: David Goulet <dgoulet(a)ev0ke.net>
---
src/common/config-file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/common/config-file.c b/src/common/config-file.c
index 05ca9cb..a22d4c6 100644
--- a/src/common/config-file.c
+++ b/src/common/config-file.c
@@ -284,13 +284,13 @@ int conf_file_set_tor_address(const char *addr, struct configuration *config)
config->conf_file.tor_domain = CONNECTION_DOMAIN_INET6;
}
- if (config->conf_file.tor_address == NULL) {
+ if (config->conf_file.tor_address != NULL) {
free(config->conf_file.tor_address);
config->conf_file.tor_address = NULL;
}
config->conf_file.tor_address = strdup(addr);
- if (!config->conf_file.tor_address) {
+ if (config->conf_file.tor_address == NULL) {
ret = -ENOMEM;
goto error;
}
1
0

[torsocks/master] Fix: accept{4} wrappers to accept addr to NULL
by dgoulet@torproject.org 14 Jun '16
by dgoulet@torproject.org 14 Jun '16
14 Jun '16
commit 67d9b1a4620445bfb271d64a7799ef22487fabfa
Author: David Goulet <dgoulet(a)ev0ke.net>
Date: Tue Jun 14 10:40:18 2016 -0400
Fix: accept{4} wrappers to accept addr to NULL
The accept(2) man page specifies that addr can be a NULL pointer for both
accept() and accept4().
This has been reported in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811266
Signed-off-by: David Goulet <dgoulet(a)ev0ke.net>
---
src/lib/accept.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/src/lib/accept.c b/src/lib/accept.c
index 21714cb..80434fc 100644
--- a/src/lib/accept.c
+++ b/src/lib/accept.c
@@ -37,11 +37,6 @@ LIBC_ACCEPT_RET_TYPE tsocks_accept(LIBC_ACCEPT_SIG)
goto libc_call;
}
- if (!addr) {
- errno = EFAULT;
- goto error;
- }
-
sa_len = sizeof(sa);
ret = getsockname(sockfd, &sa, &sa_len);
@@ -61,11 +56,10 @@ LIBC_ACCEPT_RET_TYPE tsocks_accept(LIBC_ACCEPT_SIG)
/* Inbound localhost connections are allowed. */
ret = utils_sockaddr_is_localhost(&sa);
if (!ret) {
-
/*
* Accept is completely denied here since this means that the
- * application can accept inbound connections on non localhost that are
- * obviously NOT handled by the Tor network thus reject this call.
+ * application can accept inbound connections on non localhost that
+ * are obviously NOT handled by the Tor network thus reject this call.
*/
DBG("[accept] Non localhost inbound connection are not allowed.");
errno = EPERM;
@@ -111,11 +105,6 @@ LIBC_ACCEPT4_RET_TYPE tsocks_accept4(LIBC_ACCEPT4_SIG)
goto libc_call;
}
- if (!addr) {
- errno = EFAULT;
- goto error;
- }
-
sa_len = sizeof(sa);
ret = getsockname(sockfd, &sa, &sa_len);
1
0

[metrics-lib/master] Parse "package" lines in consensuses and votes.
by karsten@torproject.org 14 Jun '16
by karsten@torproject.org 14 Jun '16
14 Jun '16
commit 4d79f79a78af5f1dee293b29c1758f8864d3f6b7
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Sun Jun 12 17:00:48 2016 +0200
Parse "package" lines in consensuses and votes.
Implements #19285.
---
CHANGELOG.md | 6 +++
.../descriptor/RelayNetworkStatusConsensus.java | 11 +++++
.../descriptor/RelayNetworkStatusVote.java | 10 +++++
.../impl/RelayNetworkStatusConsensusImpl.java | 21 ++++++++++
.../impl/RelayNetworkStatusVoteImpl.java | 21 ++++++++++
.../descriptor/impl/ConsensusBuilder.java | 11 +++++
.../impl/RelayNetworkStatusConsensusImplTest.java | 37 +++++++++++++++++
.../impl/RelayNetworkStatusVoteImplTest.java | 47 ++++++++++++++++++++++
8 files changed, 164 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ecb1523..3c243d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# Changes in version 1.3.0 - 2016-0x-xx
+
+ * Medium changes
+ - Parse "package" lines in consensuses and votes.
+
+
# Changes in version 1.2.0 - 2016-05-31
* Medium changes
diff --git a/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java b/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java
index 624f1cc..90f96d7 100644
--- a/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java
+++ b/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java
@@ -113,6 +113,17 @@ public interface RelayNetworkStatusConsensus extends Descriptor {
public List<String> getRecommendedClientVersions();
/**
+ * Return a list of software packages and their versions together with a
+ * URL and one or more digests in the format <code>PackageName Version
+ * URL DIGESTS</code> that are known by at least three directory
+ * authorities and agreed upon by the majority of directory authorities,
+ * or null if the consensus does not contain package information.
+ *
+ * @since 1.3.0
+ */
+ public List<String> getPackageLines();
+
+ /**
* Return known relay flags in this descriptor that were contained in
* enough votes for this consensus to be an authoritative opinion for
* these relay flags.
diff --git a/src/org/torproject/descriptor/RelayNetworkStatusVote.java b/src/org/torproject/descriptor/RelayNetworkStatusVote.java
index 5e0c7cd..6e7e1b7 100644
--- a/src/org/torproject/descriptor/RelayNetworkStatusVote.java
+++ b/src/org/torproject/descriptor/RelayNetworkStatusVote.java
@@ -105,6 +105,16 @@ public interface RelayNetworkStatusVote extends Descriptor {
public List<String> getRecommendedClientVersions();
/**
+ * Return a list of software packages and their versions together with a
+ * URL and one or more digests in the format <code>PackageName Version
+ * URL DIGESTS</code> that are known by this directory authority, or
+ * null if this descriptor does not contain package information.
+ *
+ * @since 1.3.0
+ */
+ public List<String> getPackageLines();
+
+ /**
* Return known relay flags by this authority.
*
* @since 1.0.0
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
index 13b9142..091ba09 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
@@ -123,6 +123,9 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
case "server-versions":
this.parseServerVersionsLine(line, parts);
break;
+ case "package":
+ this.parsePackageLine(line, parts);
+ break;
case "known-flags":
this.parseKnownFlagsLine(line, parts);
break;
@@ -276,6 +279,18 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
line, parts);
}
+ private void parsePackageLine(String line, String[] parts)
+ throws DescriptorParseException {
+ if (parts.length < 5) {
+ throw new DescriptorParseException("Wrong number of values in line "
+ + "'" + line + "'.");
+ }
+ if (this.packageLines == null) {
+ this.packageLines = new ArrayList<>();
+ }
+ this.packageLines.add(line.substring("package ".length()));
+ }
+
private void parseKnownFlagsLine(String line, String[] parts)
throws DescriptorParseException {
if (parts.length < 2) {
@@ -358,6 +373,12 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
Arrays.asList(this.recommendedServerVersions);
}
+ private List<String> packageLines;
+ public List<String> getPackageLines() {
+ return this.packageLines == null ? null
+ : new ArrayList<>(this.packageLines);
+ }
+
private String[] knownFlags;
public SortedSet<String> getKnownFlags() {
return new TreeSet<>(Arrays.asList(this.knownFlags));
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index 8d18919..f378a79 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -113,6 +113,9 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
case "server-versions":
this.parseServerVersionsLine(line, parts);
break;
+ case "package":
+ this.parsePackageLine(line, parts);
+ break;
case "known-flags":
this.parseKnownFlagsLine(line, parts);
break;
@@ -298,6 +301,18 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
line, parts);
}
+ private void parsePackageLine(String line, String[] parts)
+ throws DescriptorParseException {
+ if (parts.length < 5) {
+ throw new DescriptorParseException("Wrong number of values in line "
+ + "'" + line + "'.");
+ }
+ if (this.packageLines == null) {
+ this.packageLines = new ArrayList<>();
+ }
+ this.packageLines.add(line.substring("package ".length()));
+ }
+
private void parseKnownFlagsLine(String line, String[] parts)
throws DescriptorParseException {
if (parts.length < 2) {
@@ -634,6 +649,12 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
Arrays.asList(this.recommendedServerVersions);
}
+ private List<String> packageLines;
+ public List<String> getPackageLines() {
+ return this.packageLines == null ? null
+ : new ArrayList<>(this.packageLines);
+ }
+
private String[] knownFlags;
public SortedSet<String> getKnownFlags() {
return new TreeSet<>(Arrays.asList(this.knownFlags));
diff --git a/test/org/torproject/descriptor/impl/ConsensusBuilder.java b/test/org/torproject/descriptor/impl/ConsensusBuilder.java
index b9638fb..29a2d47 100644
--- a/test/org/torproject/descriptor/impl/ConsensusBuilder.java
+++ b/test/org/torproject/descriptor/impl/ConsensusBuilder.java
@@ -85,6 +85,14 @@ public class ConsensusBuilder {
cb.serverVersionsLine = line;
return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
}
+ private String packageLines = null;
+ protected static RelayNetworkStatusConsensus
+ createWithPackageLines(String lines)
+ throws DescriptorParseException {
+ ConsensusBuilder cb = new ConsensusBuilder();
+ cb.packageLines = lines;
+ return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true);
+ }
private String knownFlagsLine = "known-flags Authority BadExit Exit "
+ "Fast Guard HSDir Named Running Stable Unnamed V2Dir Valid";
protected static RelayNetworkStatusConsensus
@@ -261,6 +269,9 @@ public class ConsensusBuilder {
if (this.serverVersionsLine != null) {
sb.append(this.serverVersionsLine).append("\n");
}
+ if (this.packageLines != null) {
+ sb.append(this.packageLines).append("\n");
+ }
if (this.knownFlagsLine != null) {
sb.append(this.knownFlagsLine).append("\n");
}
diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
index dbe6cd3..86e4e78 100644
--- a/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
+++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
@@ -10,6 +10,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@@ -607,6 +608,42 @@ public class RelayNetworkStatusConsensusImplTest {
"client-versions ,0.2.2.34");
}
+ @Test()
+ public void testPackageNone() throws DescriptorParseException {
+ RelayNetworkStatusConsensus consensus =
+ ConsensusBuilder.createWithPackageLines(null);
+ assertNull(consensus.getPackageLines());
+ }
+
+ @Test()
+ public void testPackageOne() throws DescriptorParseException {
+ String packageLine = "package shouldbesecond 0 http digest=digest";
+ RelayNetworkStatusConsensus consensus =
+ ConsensusBuilder.createWithPackageLines(packageLine);
+ assertEquals(packageLine.substring("package ".length()),
+ consensus.getPackageLines().get(0));
+ }
+
+ @Test()
+ public void testPackageTwo() throws DescriptorParseException {
+ List<String> packageLines = Arrays.asList(
+ "package shouldbesecond 0 http digest=digest",
+ "package outoforder 0 http digest=digest");
+ RelayNetworkStatusConsensus consensus =
+ ConsensusBuilder.createWithPackageLines(packageLines.get(0)
+ + "\n" + packageLines.get(1));
+ for (int i = 0; i < packageLines.size(); i++) {
+ assertEquals(packageLines.get(i).substring("package ".length()),
+ consensus.getPackageLines().get(i));
+ }
+ }
+
+ @Test(expected = DescriptorParseException.class)
+ public void testPackageIncomplete() throws DescriptorParseException {
+ String packageLine = "package shouldbesecond 0 http";
+ ConsensusBuilder.createWithPackageLines(packageLine);
+ }
+
@Test(expected = DescriptorParseException.class)
public void testKnownFlagsNoLine() throws DescriptorParseException {
ConsensusBuilder.createWithKnownFlagsLine(null);
diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index 261abd4..f7ddd8c 100644
--- a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -108,6 +108,14 @@ public class RelayNetworkStatusVoteImplTest {
vb.serverVersionsLine = line;
return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
}
+ private String packageLines = null;
+ protected static RelayNetworkStatusVote
+ createWithPackageLines(String lines)
+ throws DescriptorParseException {
+ VoteBuilder vb = new VoteBuilder();
+ vb.packageLines = lines;
+ return new RelayNetworkStatusVoteImpl(vb.buildVote(), true);
+ }
private String knownFlagsLine = "known-flags Authority BadExit Exit "
+ "Fast Guard HSDir Named Running Stable Unnamed V2Dir Valid";
private static RelayNetworkStatusVote
@@ -408,6 +416,9 @@ public class RelayNetworkStatusVoteImplTest {
if (this.serverVersionsLine != null) {
sb.append(this.serverVersionsLine).append("\n");
}
+ if (this.packageLines != null) {
+ sb.append(this.packageLines).append("\n");
+ }
if (this.knownFlagsLine != null) {
sb.append(this.knownFlagsLine).append("\n");
}
@@ -777,6 +788,42 @@ public class RelayNetworkStatusVoteImplTest {
"client-versions ,0.2.2.34");
}
+ @Test()
+ public void testPackageNone() throws DescriptorParseException {
+ RelayNetworkStatusVote vote =
+ VoteBuilder.createWithPackageLines(null);
+ assertNull(vote.getPackageLines());
+ }
+
+ @Test()
+ public void testPackageOne() throws DescriptorParseException {
+ String packageLine = "package shouldbesecond 0 http digest=digest";
+ RelayNetworkStatusVote vote =
+ VoteBuilder.createWithPackageLines(packageLine);
+ assertEquals(packageLine.substring("package ".length()),
+ vote.getPackageLines().get(0));
+ }
+
+ @Test()
+ public void testPackageTwo() throws DescriptorParseException {
+ List<String> packageLines = Arrays.asList(
+ "package shouldbesecond 0 http digest=digest",
+ "package outoforder 0 http digest=digest");
+ RelayNetworkStatusVote vote =
+ VoteBuilder.createWithPackageLines(packageLines.get(0)
+ + "\n" + packageLines.get(1));
+ for (int i = 0; i < packageLines.size(); i++) {
+ assertEquals(packageLines.get(i).substring("package ".length()),
+ vote.getPackageLines().get(i));
+ }
+ }
+
+ @Test(expected = DescriptorParseException.class)
+ public void testPackageIncomplete() throws DescriptorParseException {
+ String packageLine = "package shouldbesecond 0 http";
+ ConsensusBuilder.createWithPackageLines(packageLine);
+ }
+
@Test(expected = DescriptorParseException.class)
public void testKnownFlagsNoLine() throws DescriptorParseException {
VoteBuilder.createWithKnownFlagsLine(null);
1
0
commit d863abbc4e132c8d6375f6e2e00f390075507133
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Sun Jun 12 21:46:21 2016 +0200
Add @Override annotations.
Also reduce visibility of all public methods in ParseHelper and of one
public method in TorperfResultsImpl, and remove unused methods in
DirectorySignatureImpl and ExitListEntryImpl.
---
.../descriptor/impl/BandwidthHistoryImpl.java | 4 ++
.../descriptor/impl/BlockingIteratorImpl.java | 3 ++
.../descriptor/impl/BridgeNetworkStatusImpl.java | 10 ++++
.../descriptor/impl/BridgePoolAssignmentImpl.java | 2 +
.../descriptor/impl/DescriptorDownloaderImpl.java | 18 +++++++
.../descriptor/impl/DescriptorFileImpl.java | 7 +++
.../torproject/descriptor/impl/DescriptorImpl.java | 3 ++
.../descriptor/impl/DescriptorParserImpl.java | 2 +
.../descriptor/impl/DescriptorReaderImpl.java | 9 ++++
.../descriptor/impl/DescriptorRequestImpl.java | 10 ++++
.../descriptor/impl/DirSourceEntryImpl.java | 10 ++++
.../descriptor/impl/DirectoryDownloader.java | 1 +
.../impl/DirectoryKeyCertificateImpl.java | 11 ++++
.../descriptor/impl/DirectorySignatureImpl.java | 7 +--
.../descriptor/impl/DownloadCoordinatorImpl.java | 2 +
.../descriptor/impl/ExitListEntryImpl.java | 9 ++--
.../torproject/descriptor/impl/ExitListImpl.java | 3 ++
.../descriptor/impl/ExtraInfoDescriptorImpl.java | 63 ++++++++++++++++++++++
.../descriptor/impl/MicrodescriptorImpl.java | 11 ++++
.../descriptor/impl/NetworkStatusEntryImpl.java | 18 +++++++
.../torproject/descriptor/impl/ParseHelper.java | 40 +++++++-------
.../descriptor/impl/RelayDirectoryImpl.java | 9 ++++
.../impl/RelayNetworkStatusConsensusImpl.java | 15 ++++++
.../descriptor/impl/RelayNetworkStatusImpl.java | 14 +++++
.../impl/RelayNetworkStatusVoteImpl.java | 38 +++++++++++++
.../descriptor/impl/RouterStatusEntryImpl.java | 4 ++
.../descriptor/impl/ServerDescriptorImpl.java | 41 ++++++++++++++
.../descriptor/impl/TorperfResultImpl.java | 26 ++++++++-
28 files changed, 363 insertions(+), 27 deletions(-)
diff --git a/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java b/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java
index 0023b88..295e0a4 100644
--- a/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java
+++ b/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java
@@ -66,21 +66,25 @@ public class BandwidthHistoryImpl implements BandwidthHistory {
}
private String line;
+ @Override
public String getLine() {
return this.line;
}
private long historyEndMillis;
+ @Override
public long getHistoryEndMillis() {
return this.historyEndMillis;
}
private long intervalLength;
+ @Override
public long getIntervalLength() {
return this.intervalLength;
}
private long[] bandwidthValues;
+ @Override
public SortedMap<Long, Long> getBandwidthValues() {
SortedMap<Long, Long> result = new TreeMap<>();
if (this.bandwidthValues != null) {
diff --git a/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java b/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java
index b4ea525..66426d8 100644
--- a/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java
+++ b/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java
@@ -58,6 +58,7 @@ public class BlockingIteratorImpl<T> implements Iterator<T> {
/* Return whether there are more objects. Block if there are currently
* no objects, but the producer hasn't signalized that there won't be
* further objects. */
+ @Override
public synchronized boolean hasNext() {
while (!this.outOfDescriptors && this.queue.isEmpty()) {
try {
@@ -72,6 +73,7 @@ public class BlockingIteratorImpl<T> implements Iterator<T> {
* are no further objects. Block if there are currently no objects, but
* the producer hasn't signalized that there won't be further
* objects. */
+ @Override
public synchronized T next() {
while (!this.outOfDescriptors && this.queue.isEmpty()) {
try {
@@ -88,6 +90,7 @@ public class BlockingIteratorImpl<T> implements Iterator<T> {
/* Don't support explicitly removing objects. They are removed
* anyway. */
+ @Override
public void remove() {
throw new UnsupportedOperationException();
}
diff --git a/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java
index fcc9b64..bf3804d 100644
--- a/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java
@@ -168,51 +168,61 @@ public class BridgeNetworkStatusImpl extends NetworkStatusImpl
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private long stableUptime;
+ @Override
public long getStableUptime() {
return this.stableUptime;
}
private long stableMtbf;
+ @Override
public long getStableMtbf() {
return this.stableMtbf;
}
private long fastBandwidth;
+ @Override
public long getFastBandwidth() {
return this.fastBandwidth;
}
private double guardWfu;
+ @Override
public double getGuardWfu() {
return this.guardWfu;
}
private long guardTk;
+ @Override
public long getGuardTk() {
return this.guardTk;
}
private long guardBandwidthIncludingExits;
+ @Override
public long getGuardBandwidthIncludingExits() {
return this.guardBandwidthIncludingExits;
}
private long guardBandwidthExcludingExits;
+ @Override
public long getGuardBandwidthExcludingExits() {
return this.guardBandwidthExcludingExits;
}
private int enoughMtbfInfo;
+ @Override
public int getEnoughMtbfInfo() {
return this.enoughMtbfInfo;
}
private int ignoringAdvertisedBws;
+ @Override
public int getIgnoringAdvertisedBws() {
return this.ignoringAdvertisedBws;
}
diff --git a/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java b/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java
index 06270bc..99578e8 100644
--- a/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java
+++ b/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java
@@ -85,11 +85,13 @@ public class BridgePoolAssignmentImpl extends DescriptorImpl
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private SortedMap<String, String> entries = new TreeMap<>();
+ @Override
public SortedMap<String, String> getEntries() {
return new TreeMap<>(this.entries);
}
diff --git a/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java b/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java
index aaac8f8..e726ce9 100644
--- a/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java
@@ -18,6 +18,7 @@ public class DescriptorDownloaderImpl
private SortedMap<String, DirectoryDownloader> directoryAuthorities =
new TreeMap<>();
+ @Override
public void addDirectoryAuthority(String nickname, String ip,
int dirPort) {
if (this.hasStartedDownloading) {
@@ -32,6 +33,7 @@ public class DescriptorDownloaderImpl
private SortedMap<String, DirectoryDownloader> directoryMirrors =
new TreeMap<>();
+ @Override
public void addDirectoryMirror(String nickname, String ip,
int dirPort) {
if (this.hasStartedDownloading) {
@@ -73,6 +75,7 @@ public class DescriptorDownloaderImpl
}
private boolean downloadConsensus = false;
+ @Override
public void setIncludeCurrentConsensus() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -82,6 +85,7 @@ public class DescriptorDownloaderImpl
}
private boolean downloadConsensusFromAllAuthorities = false;
+ @Override
public void setIncludeCurrentConsensusFromAllDirectoryAuthorities() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -91,6 +95,7 @@ public class DescriptorDownloaderImpl
}
private boolean includeCurrentReferencedVotes = false;
+ @Override
public void setIncludeCurrentReferencedVotes() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -100,6 +105,7 @@ public class DescriptorDownloaderImpl
}
private Set<String> downloadVotes = new HashSet<>();
+ @Override
public void setIncludeCurrentVote(String fingerprint) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -109,6 +115,7 @@ public class DescriptorDownloaderImpl
this.downloadVotes.add(fingerprint);
}
+ @Override
public void setIncludeCurrentVotes(Set<String> fingerprints) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -133,6 +140,7 @@ public class DescriptorDownloaderImpl
}
}
+ @Override
public void setIncludeReferencedServerDescriptors() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -143,6 +151,7 @@ public class DescriptorDownloaderImpl
+ "descriptors is not implemented yet.");
}
+ @Override
public void setExcludeServerDescriptor(String identifier) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -153,6 +162,7 @@ public class DescriptorDownloaderImpl
+ "descriptors is not implemented yet.");
}
+ @Override
public void setExcludeServerDescriptors(Set<String> identifier) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -163,6 +173,7 @@ public class DescriptorDownloaderImpl
+ "descriptors is not implemented yet.");
}
+ @Override
public void setIncludeReferencedExtraInfoDescriptors() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -173,6 +184,7 @@ public class DescriptorDownloaderImpl
+ "descriptors is not implemented yet.");
}
+ @Override
public void setExcludeExtraInfoDescriptor(String identifier) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -183,6 +195,7 @@ public class DescriptorDownloaderImpl
+ "descriptors is not implemented yet.");
}
+ @Override
public void setExcludeExtraInfoDescriptors(Set<String> identifiers) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -194,6 +207,7 @@ public class DescriptorDownloaderImpl
}
private long readTimeoutMillis = 60L * 1000L;
+ @Override
public void setReadTimeout(long readTimeoutMillis) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -208,6 +222,7 @@ public class DescriptorDownloaderImpl
}
private long connectTimeoutMillis = 60L * 1000L;
+ @Override
public void setConnectTimeout(long connectTimeoutMillis) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -222,6 +237,7 @@ public class DescriptorDownloaderImpl
}
private long globalTimeoutMillis = 60L * 60L * 1000L;
+ @Override
public void setGlobalTimeout(long globalTimeoutMillis) {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -236,6 +252,7 @@ public class DescriptorDownloaderImpl
}
private boolean failUnrecognizedDescriptorLines = false;
+ @Override
public void setFailUnrecognizedDescriptorLines() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -244,6 +261,7 @@ public class DescriptorDownloaderImpl
this.failUnrecognizedDescriptorLines = true;
}
+ @Override
public Iterator<DescriptorRequest> downloadDescriptors() {
if (this.hasStartedDownloading) {
throw new IllegalStateException("Initiating downloads is only "
diff --git a/src/org/torproject/descriptor/impl/DescriptorFileImpl.java b/src/org/torproject/descriptor/impl/DescriptorFileImpl.java
index b683e7f..801c546 100644
--- a/src/org/torproject/descriptor/impl/DescriptorFileImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorFileImpl.java
@@ -15,6 +15,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setDirectory(File directory) {
this.directory = directory;
}
+ @Override
public File getDirectory() {
return this.directory;
}
@@ -23,6 +24,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setTarball(File tarball) {
this.tarball = tarball;
}
+ @Override
public File getTarball() {
return this.tarball;
}
@@ -31,6 +33,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setFile(File file) {
this.file = file;
}
+ @Override
public File getFile() {
return this.file;
}
@@ -39,6 +42,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setFileName(String fileName) {
this.fileName = fileName;
}
+ @Override
public String getFileName() {
return this.fileName;
}
@@ -47,6 +51,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
+ @Override
public long getLastModified() {
return this.lastModified;
}
@@ -55,6 +60,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setDescriptors(List<Descriptor> descriptors) {
this.descriptors = descriptors;
}
+ @Override
public List<Descriptor> getDescriptors() {
return this.descriptors == null ? new ArrayList<Descriptor>() :
new ArrayList<>(this.descriptors);
@@ -64,6 +70,7 @@ public class DescriptorFileImpl implements DescriptorFile {
protected void setException(Exception exception) {
this.exception = exception;
}
+ @Override
public Exception getException() {
return this.exception;
}
diff --git a/src/org/torproject/descriptor/impl/DescriptorImpl.java b/src/org/torproject/descriptor/impl/DescriptorImpl.java
index e7a3f0e..5625b3f 100644
--- a/src/org/torproject/descriptor/impl/DescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorImpl.java
@@ -159,6 +159,7 @@ public abstract class DescriptorImpl implements Descriptor {
}
protected byte[] rawDescriptorBytes;
+ @Override
public byte[] getRawDescriptorBytes() {
return this.rawDescriptorBytes;
}
@@ -166,6 +167,7 @@ public abstract class DescriptorImpl implements Descriptor {
protected boolean failUnrecognizedDescriptorLines = false;
protected List<String> unrecognizedLines;
+ @Override
public List<String> getUnrecognizedLines() {
return this.unrecognizedLines == null ? new ArrayList<String>() :
new ArrayList<>(this.unrecognizedLines);
@@ -205,6 +207,7 @@ public abstract class DescriptorImpl implements Descriptor {
this.rawDescriptorBytes = rawDescriptor;
}
}
+ @Override
public List<String> getAnnotations() {
return new ArrayList<>(this.annotations);
}
diff --git a/src/org/torproject/descriptor/impl/DescriptorParserImpl.java b/src/org/torproject/descriptor/impl/DescriptorParserImpl.java
index b9af853..6ac53f8 100644
--- a/src/org/torproject/descriptor/impl/DescriptorParserImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorParserImpl.java
@@ -12,12 +12,14 @@ public class DescriptorParserImpl implements DescriptorParser {
private boolean failUnrecognizedDescriptorLines;
+ @Override
public void setFailUnrecognizedDescriptorLines(
boolean failUnrecognizedDescriptorLines) {
this.failUnrecognizedDescriptorLines =
failUnrecognizedDescriptorLines;
}
+ @Override
public List<Descriptor> parseDescriptors(byte[] rawDescriptorBytes,
String fileName) throws DescriptorParseException {
return DescriptorImpl.parseDescriptors(rawDescriptorBytes, fileName,
diff --git a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
index 454c526..8da88e9 100644
--- a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java
@@ -35,6 +35,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
private boolean hasStartedReading = false;
private List<File> directories = new ArrayList<>();
+ @Override
public void addDirectory(File directory) {
if (this.hasStartedReading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -44,6 +45,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private List<File> tarballs = new ArrayList<>();
+ @Override
public void addTarball(File tarball) {
if (this.hasStartedReading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -53,6 +55,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private File historyFile;
+ @Override
public void setExcludeFiles(File historyFile) {
if (this.hasStartedReading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -62,6 +65,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private SortedMap<String, Long> excludedFiles;
+ @Override
public void setExcludedFiles(SortedMap<String, Long> excludedFiles) {
if (this.hasStartedReading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -70,6 +74,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
this.excludedFiles = excludedFiles;
}
+ @Override
public SortedMap<String, Long> getExcludedFiles() {
if (this.reader == null || !this.reader.hasFinishedReading) {
throw new IllegalStateException("Operation is not permitted before "
@@ -78,6 +83,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
return new TreeMap<>(this.reader.excludedFilesAfter);
}
+ @Override
public SortedMap<String, Long> getParsedFiles() {
if (this.reader == null || !this.reader.hasFinishedReading) {
throw new IllegalStateException("Operation is not permitted before "
@@ -87,6 +93,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private boolean failUnrecognizedDescriptorLines = false;
+ @Override
public void setFailUnrecognizedDescriptorLines() {
if (this.hasStartedReading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -96,6 +103,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private Integer maxDescriptorFilesInQueue = null;
+ @Override
public void setMaxDescriptorFilesInQueue(int max) {
if (this.hasStartedReading) {
throw new IllegalStateException("Reconfiguration is not permitted "
@@ -105,6 +113,7 @@ public class DescriptorReaderImpl implements DescriptorReader {
}
private DescriptorReaderRunnable reader;
+ @Override
public Iterator<DescriptorFile> readDescriptors() {
if (this.hasStartedReading) {
throw new IllegalStateException("Initiating reading is only "
diff --git a/src/org/torproject/descriptor/impl/DescriptorRequestImpl.java b/src/org/torproject/descriptor/impl/DescriptorRequestImpl.java
index 5a5f020..0238f24 100644
--- a/src/org/torproject/descriptor/impl/DescriptorRequestImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorRequestImpl.java
@@ -34,6 +34,7 @@ public class DescriptorRequestImpl implements DescriptorRequest {
}
private String requestUrl;
+ @Override
public String getRequestUrl() {
return this.requestUrl;
}
@@ -42,6 +43,7 @@ public class DescriptorRequestImpl implements DescriptorRequest {
protected void setDirectoryNickname(String directoryNickname) {
this.directoryNickname = directoryNickname;
}
+ @Override
public String getDirectoryNickname() {
return this.directoryNickname;
}
@@ -50,6 +52,7 @@ public class DescriptorRequestImpl implements DescriptorRequest {
protected void setResponseCode(int responseCode) {
this.responseCode = responseCode;
}
+ @Override
public int getResponseCode() {
return this.responseCode;
}
@@ -58,6 +61,7 @@ public class DescriptorRequestImpl implements DescriptorRequest {
protected void setRequestStart(long requestStart) {
this.requestStart = requestStart;
}
+ @Override
public long getRequestStart() {
return this.requestStart;
}
@@ -66,21 +70,25 @@ public class DescriptorRequestImpl implements DescriptorRequest {
protected void setRequestEnd(long requestEnd) {
this.requestEnd = requestEnd;
}
+ @Override
public long getRequestEnd() {
return this.requestEnd;
}
private boolean connectTimeoutHasExpired;
+ @Override
public boolean connectTimeoutHasExpired() {
return this.connectTimeoutHasExpired;
}
private boolean readTimeoutHasExpired;
+ @Override
public boolean readTimeoutHasExpired() {
return this.readTimeoutHasExpired;
}
private boolean globalTimeoutHasExpired;
+ @Override
public boolean globalTimeoutHasExpired() {
return this.globalTimeoutHasExpired;
}
@@ -89,6 +97,7 @@ public class DescriptorRequestImpl implements DescriptorRequest {
protected void setDescriptors(List<Descriptor> descriptors) {
this.descriptors = descriptors;
}
+ @Override
public List<Descriptor> getDescriptors() {
return this.descriptors;
}
@@ -97,6 +106,7 @@ public class DescriptorRequestImpl implements DescriptorRequest {
protected void setException(Exception exception) {
this.exception = exception;
}
+ @Override
public Exception getException() {
return this.exception;
}
diff --git a/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java b/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java
index 5e39cfe..fb2f5ad 100644
--- a/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java
@@ -14,6 +14,7 @@ import org.torproject.descriptor.DirSourceEntry;
public class DirSourceEntryImpl implements DirSourceEntry {
private byte[] dirSourceEntryBytes;
+ @Override
public byte[] getDirSourceEntryBytes() {
return this.dirSourceEntryBytes;
}
@@ -161,46 +162,55 @@ public class DirSourceEntryImpl implements DirSourceEntry {
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String identity;
+ @Override
public String getIdentity() {
return this.identity;
}
private boolean isLegacy;
+ @Override
public boolean isLegacy() {
return this.isLegacy;
}
private String hostname;
+ @Override
public String getHostname() {
return this.hostname;
}
private String ip;
+ @Override
public String getIp() {
return this.ip;
}
private int dirPort;
+ @Override
public int getDirPort() {
return this.dirPort;
}
private int orPort;
+ @Override
public int getOrPort() {
return this.orPort;
}
private String contactLine;
+ @Override
public String getContactLine() {
return this.contactLine;
}
private String voteDigest;
+ @Override
public String getVoteDigest() {
return this.voteDigest;
}
diff --git a/src/org/torproject/descriptor/impl/DirectoryDownloader.java b/src/org/torproject/descriptor/impl/DirectoryDownloader.java
index 66af559..a27ed76 100644
--- a/src/org/torproject/descriptor/impl/DirectoryDownloader.java
+++ b/src/org/torproject/descriptor/impl/DirectoryDownloader.java
@@ -49,6 +49,7 @@ public class DirectoryDownloader implements Runnable {
failUnrecognizedDescriptorLines);
}
+ @Override
public void run() {
boolean keepRunning = true;
do {
diff --git a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
index 13baedb..b62fc8e 100644
--- a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
+++ b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
@@ -240,56 +240,67 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl
}
private int dirKeyCertificateVersion;
+ @Override
public int getDirKeyCertificateVersion() {
return this.dirKeyCertificateVersion;
}
private String address;
+ @Override
public String getAddress() {
return this.address;
}
private int port = -1;
+ @Override
public int getPort() {
return this.port;
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private String dirIdentityKey;
+ @Override
public String getDirIdentityKey() {
return this.dirIdentityKey;
}
private long dirKeyPublishedMillis;
+ @Override
public long getDirKeyPublishedMillis() {
return this.dirKeyPublishedMillis;
}
private long dirKeyExpiresMillis;
+ @Override
public long getDirKeyExpiresMillis() {
return this.dirKeyExpiresMillis;
}
private String dirSigningKey;
+ @Override
public String getDirSigningKey() {
return this.dirSigningKey;
}
private String dirKeyCrosscert;
+ @Override
public String getDirKeyCrosscert() {
return this.dirKeyCrosscert;
}
private String dirKeyCertification;
+ @Override
public String getDirKeyCertification() {
return this.dirKeyCertification;
}
private String certificateDigest;
+ @Override
public String getCertificateDigest() {
return this.certificateDigest;
}
diff --git a/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java b/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java
index 18de918..597ccce 100644
--- a/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java
+++ b/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java
@@ -12,9 +12,6 @@ import org.torproject.descriptor.DirectorySignature;
public class DirectorySignatureImpl implements DirectorySignature {
private byte[] directorySignatureBytes;
- public byte[] getDirectorySignatureBytes() {
- return this.directorySignatureBytes;
- }
private boolean failUnrecognizedDescriptorLines;
private List<String> unrecognizedLines;
@@ -90,21 +87,25 @@ public class DirectorySignatureImpl implements DirectorySignature {
}
private String algorithm = "sha1";
+ @Override
public String getAlgorithm() {
return this.algorithm;
}
private String identity;
+ @Override
public String getIdentity() {
return this.identity;
}
private String signingKeyDigest;
+ @Override
public String getSigningKeyDigest() {
return this.signingKeyDigest;
}
private String signature;
+ @Override
public String getSignature() {
return this.signature;
}
diff --git a/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java b/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java
index 6a73090..a8e3731 100644
--- a/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java
+++ b/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java
@@ -142,6 +142,7 @@ public class DownloadCoordinatorImpl implements DownloadCoordinator {
/* Look up what request a directory should make next. If there is
* nothing to do right now, but maybe later, block the caller. If
* we're done downloading, return null to notify the caller. */
+ @Override
public synchronized DescriptorRequestImpl createRequest(
String nickname) {
while (!this.hasFinishedDownloading) {
@@ -197,6 +198,7 @@ public class DownloadCoordinatorImpl implements DownloadCoordinator {
* or a failure response code. Update the lists of missing descriptors,
* decide if there are more descriptors to download, and wake up any
* waiting downloader threads. */
+ @Override
public synchronized void deliverResponse(
DescriptorRequestImpl response) {
String nickname = response.getDirectoryNickname();
diff --git a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
index 6d00bf4..efbf31c 100644
--- a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
@@ -18,9 +18,6 @@ import org.torproject.descriptor.ExitListEntry;
public class ExitListEntryImpl implements ExitListEntry, ExitList.Entry {
private byte[] exitListEntryBytes;
- public byte[] getExitListEntryBytes() {
- return this.exitListEntryBytes;
- }
private boolean failUnrecognizedDescriptorLines;
private List<String> unrecognizedLines;
@@ -172,21 +169,25 @@ public class ExitListEntryImpl implements ExitListEntry, ExitList.Entry {
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private long lastStatusMillis;
+ @Override
public long getLastStatusMillis() {
return this.lastStatusMillis;
}
private String exitAddress;
+ @Override
public String getExitAddress() {
if (null == exitAddress) {
Map.Entry<String, Long> randomEntry =
@@ -198,11 +199,13 @@ public class ExitListEntryImpl implements ExitListEntry, ExitList.Entry {
}
private Map<String, Long> exitAddresses = new HashMap<>();
+ @Override
public Map<String, Long> getExitAddresses(){
return new HashMap<>(this.exitAddresses);
}
private long scanMillis;
+ @Override
public long getScanMillis() {
if (null == exitAddress) {
getExitAddress();
diff --git a/src/org/torproject/descriptor/impl/ExitListImpl.java b/src/org/torproject/descriptor/impl/ExitListImpl.java
index 33003df..10619ba 100644
--- a/src/org/torproject/descriptor/impl/ExitListImpl.java
+++ b/src/org/torproject/descriptor/impl/ExitListImpl.java
@@ -121,17 +121,20 @@ public class ExitListImpl extends DescriptorImpl implements ExitList {
}
private long downloadedMillis;
+ @Override
public long getDownloadedMillis() {
return this.downloadedMillis;
}
private Set<ExitListEntry> oldExitListEntries = new HashSet<>();
@Deprecated
+ @Override
public Set<ExitListEntry> getExitListEntries() {
return new HashSet<>(this.oldExitListEntries);
}
private Set<ExitList.Entry> exitListEntries = new HashSet<>();
+ @Override
public Set<ExitList.Entry> getEntries() {
return new HashSet<>(this.exitListEntries);
}
diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
index 3255bd9..3f72616 100644
--- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
@@ -881,339 +881,402 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
}
private String extraInfoDigest;
+ @Override
public String getExtraInfoDigest() {
return this.extraInfoDigest;
}
private String extraInfoDigestSha256;
+ @Override
public String getExtraInfoDigestSha256() {
return this.extraInfoDigestSha256;
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private BandwidthHistory readHistory;
+ @Override
public BandwidthHistory getReadHistory() {
return this.readHistory;
}
private BandwidthHistory writeHistory;
+ @Override
public BandwidthHistory getWriteHistory() {
return this.writeHistory;
}
private String geoipDbDigest;
+ @Override
public String getGeoipDbDigest() {
return this.geoipDbDigest;
}
private String geoip6DbDigest;
+ @Override
public String getGeoip6DbDigest() {
return this.geoip6DbDigest;
}
private long dirreqStatsEndMillis = -1L;
+ @Override
public long getDirreqStatsEndMillis() {
return this.dirreqStatsEndMillis;
}
private long dirreqStatsIntervalLength = -1L;
+ @Override
public long getDirreqStatsIntervalLength() {
return this.dirreqStatsIntervalLength;
}
private String dirreqV2Ips;
+ @Override
public SortedMap<String, Integer> getDirreqV2Ips() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV2Ips);
}
private String dirreqV3Ips;
+ @Override
public SortedMap<String, Integer> getDirreqV3Ips() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV3Ips);
}
private String dirreqV2Reqs;
+ @Override
public SortedMap<String, Integer> getDirreqV2Reqs() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV2Reqs);
}
private String dirreqV3Reqs;
+ @Override
public SortedMap<String, Integer> getDirreqV3Reqs() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV3Reqs);
}
private double dirreqV2Share = -1.0;
+ @Override
public double getDirreqV2Share() {
return this.dirreqV2Share;
}
private double dirreqV3Share = -1.0;
+ @Override
public double getDirreqV3Share() {
return this.dirreqV3Share;
}
private String dirreqV2Resp;
+ @Override
public SortedMap<String, Integer> getDirreqV2Resp() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV2Resp);
}
private String dirreqV3Resp;
+ @Override
public SortedMap<String, Integer> getDirreqV3Resp() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV3Resp);
}
private String dirreqV2DirectDl;
+ @Override
public SortedMap<String, Integer> getDirreqV2DirectDl() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV2DirectDl);
}
private String dirreqV3DirectDl;
+ @Override
public SortedMap<String, Integer> getDirreqV3DirectDl() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV3DirectDl);
}
private String dirreqV2TunneledDl;
+ @Override
public SortedMap<String, Integer> getDirreqV2TunneledDl() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV2TunneledDl);
}
private String dirreqV3TunneledDl;
+ @Override
public SortedMap<String, Integer> getDirreqV3TunneledDl() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.dirreqV3TunneledDl);
}
private BandwidthHistory dirreqReadHistory;
+ @Override
public BandwidthHistory getDirreqReadHistory() {
return this.dirreqReadHistory;
}
private BandwidthHistory dirreqWriteHistory;
+ @Override
public BandwidthHistory getDirreqWriteHistory() {
return this.dirreqWriteHistory;
}
private long entryStatsEndMillis = -1L;
+ @Override
public long getEntryStatsEndMillis() {
return this.entryStatsEndMillis;
}
private long entryStatsIntervalLength = -1L;
+ @Override
public long getEntryStatsIntervalLength() {
return this.entryStatsIntervalLength;
}
private String entryIps;
+ @Override
public SortedMap<String, Integer> getEntryIps() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.entryIps);
}
private long cellStatsEndMillis = -1L;
+ @Override
public long getCellStatsEndMillis() {
return this.cellStatsEndMillis;
}
private long cellStatsIntervalLength = -1L;
+ @Override
public long getCellStatsIntervalLength() {
return this.cellStatsIntervalLength;
}
private Integer[] cellProcessedCells;
+ @Override
public List<Integer> getCellProcessedCells() {
return this.cellProcessedCells == null ? null :
Arrays.asList(this.cellProcessedCells);
}
private Double[] cellQueuedCells;
+ @Override
public List<Double> getCellQueuedCells() {
return this.cellQueuedCells == null ? null :
Arrays.asList(this.cellQueuedCells);
}
private Integer[] cellTimeInQueue;
+ @Override
public List<Integer> getCellTimeInQueue() {
return this.cellTimeInQueue == null ? null :
Arrays.asList(this.cellTimeInQueue);
}
private int cellCircuitsPerDecile = -1;
+ @Override
public int getCellCircuitsPerDecile() {
return this.cellCircuitsPerDecile;
}
private long connBiDirectStatsEndMillis = -1L;
+ @Override
public long getConnBiDirectStatsEndMillis() {
return this.connBiDirectStatsEndMillis;
}
private long connBiDirectStatsIntervalLength = -1L;
+ @Override
public long getConnBiDirectStatsIntervalLength() {
return this.connBiDirectStatsIntervalLength;
}
private int connBiDirectBelow = -1;
+ @Override
public int getConnBiDirectBelow() {
return this.connBiDirectBelow;
}
private int connBiDirectRead = -1;
+ @Override
public int getConnBiDirectRead() {
return this.connBiDirectRead;
}
private int connBiDirectWrite = -1;
+ @Override
public int getConnBiDirectWrite() {
return this.connBiDirectWrite;
}
private int connBiDirectBoth = -1;
+ @Override
public int getConnBiDirectBoth() {
return this.connBiDirectBoth;
}
private long exitStatsEndMillis = -1L;
+ @Override
public long getExitStatsEndMillis() {
return this.exitStatsEndMillis;
}
private long exitStatsIntervalLength = -1L;
+ @Override
public long getExitStatsIntervalLength() {
return this.exitStatsIntervalLength;
}
private SortedMap<String, Long> exitKibibytesWritten;
+ @Override
public SortedMap<String, Long> getExitKibibytesWritten() {
return this.exitKibibytesWritten == null ? null :
new TreeMap<>(this.exitKibibytesWritten);
}
private SortedMap<String, Long> exitKibibytesRead;
+ @Override
public SortedMap<String, Long> getExitKibibytesRead() {
return this.exitKibibytesRead == null ? null :
new TreeMap<>(this.exitKibibytesRead);
}
private SortedMap<String, Long> exitStreamsOpened;
+ @Override
public SortedMap<String, Long> getExitStreamsOpened() {
return this.exitStreamsOpened == null ? null :
new TreeMap<>(this.exitStreamsOpened);
}
private long geoipStartTimeMillis = -1L;
+ @Override
public long getGeoipStartTimeMillis() {
return this.geoipStartTimeMillis;
}
private String geoipClientOrigins;
+ @Override
public SortedMap<String, Integer> getGeoipClientOrigins() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.geoipClientOrigins);
}
private long bridgeStatsEndMillis = -1L;
+ @Override
public long getBridgeStatsEndMillis() {
return this.bridgeStatsEndMillis;
}
private long bridgeStatsIntervalLength = -1L;
+ @Override
public long getBridgeStatsIntervalLength() {
return this.bridgeStatsIntervalLength;
}
private String bridgeIps;
+ @Override
public SortedMap<String, Integer> getBridgeIps() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.bridgeIps);
}
private String bridgeIpVersions;
+ @Override
public SortedMap<String, Integer> getBridgeIpVersions() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.bridgeIpVersions);
}
private String bridgeIpTransports;
+ @Override
public SortedMap<String, Integer> getBridgeIpTransports() {
return ParseHelper.convertCommaSeparatedKeyIntegerValueList(
this.bridgeIpTransports);
}
private List<String> transports = new ArrayList<>();
+ @Override
public List<String> getTransports() {
return new ArrayList<>(this.transports);
}
private long hidservStatsEndMillis = -1L;
+ @Override
public long getHidservStatsEndMillis() {
return this.hidservStatsEndMillis;
}
private long hidservStatsIntervalLength = -1L;
+ @Override
public long getHidservStatsIntervalLength() {
return this.hidservStatsIntervalLength;
}
private Double hidservRendRelayedCells;
+ @Override
public Double getHidservRendRelayedCells() {
return this.hidservRendRelayedCells;
}
private Map<String, Double> hidservRendRelayedCellsParameters;
+ @Override
public Map<String, Double> getHidservRendRelayedCellsParameters() {
return this.hidservRendRelayedCellsParameters == null ? null :
new HashMap<>(this.hidservRendRelayedCellsParameters);
}
private Double hidservDirOnionsSeen;
+ @Override
public Double getHidservDirOnionsSeen() {
return this.hidservDirOnionsSeen;
}
private Map<String, Double> hidservDirOnionsSeenParameters;
+ @Override
public Map<String, Double> getHidservDirOnionsSeenParameters() {
return this.hidservDirOnionsSeenParameters == null ? null :
new HashMap<>(this.hidservDirOnionsSeenParameters);
}
private String routerSignature;
+ @Override
public String getRouterSignature() {
return this.routerSignature;
}
private String identityEd25519;
+ @Override
public String getIdentityEd25519() {
return this.identityEd25519;
}
private String masterKeyEd25519;
+ @Override
public String getMasterKeyEd25519() {
return this.masterKeyEd25519;
}
private String routerSignatureEd25519;
+ @Override
public String getRouterSignatureEd25519() {
return this.routerSignatureEd25519;
}
diff --git a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
index cf8f3e6..4931c31 100644
--- a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
@@ -260,56 +260,67 @@ public class MicrodescriptorImpl extends DescriptorImpl
}
private String microdescriptorDigest;
+ @Override
public String getMicrodescriptorDigest() {
return this.microdescriptorDigest;
}
private String onionKey;
+ @Override
public String getOnionKey() {
return this.onionKey;
}
private String ntorOnionKey;
+ @Override
public String getNtorOnionKey() {
return this.ntorOnionKey;
}
private List<String> orAddresses = new ArrayList<>();
+ @Override
public List<String> getOrAddresses() {
return new ArrayList<>(this.orAddresses);
}
private String[] familyEntries;
+ @Override
public List<String> getFamilyEntries() {
return this.familyEntries == null ? null :
Arrays.asList(this.familyEntries);
}
private String defaultPolicy;
+ @Override
public String getDefaultPolicy() {
return this.defaultPolicy;
}
private String portList;
+ @Override
public String getPortList() {
return this.portList;
}
private String ipv6DefaultPolicy;
+ @Override
public String getIpv6DefaultPolicy() {
return this.ipv6DefaultPolicy;
}
private String ipv6PortList;
+ @Override
public String getIpv6PortList() {
return this.ipv6PortList;
}
private String rsa1024Identity;
+ @Override
public String getRsa1024Identity() {
return this.rsa1024Identity;
}
private String ed25519Identity;
+ @Override
public String getEd25519Identity() {
return this.ed25519Identity;
}
diff --git a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
index a17973e..b73d211 100644
--- a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
@@ -20,6 +20,7 @@ import org.torproject.descriptor.NetworkStatusEntry;
public class NetworkStatusEntryImpl implements NetworkStatusEntry {
private byte[] statusEntryBytes;
+ @Override
public byte[] getStatusEntryBytes() {
return this.statusEntryBytes;
}
@@ -269,52 +270,62 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private String descriptor;
+ @Override
public String getDescriptor() {
return this.descriptor;
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private String address;
+ @Override
public String getAddress() {
return this.address;
}
private int orPort;
+ @Override
public int getOrPort() {
return this.orPort;
}
private int dirPort;
+ @Override
public int getDirPort() {
return this.dirPort;
}
private Set<String> microdescriptorDigests;
+ @Override
public Set<String> getMicrodescriptorDigests() {
return this.microdescriptorDigests == null ? null :
new HashSet<>(this.microdescriptorDigests);
}
private List<String> orAddresses = new ArrayList<>();
+ @Override
public List<String> getOrAddresses() {
return new ArrayList<>(this.orAddresses);
}
private BitSet flags;
+ @Override
public SortedSet<String> getFlags() {
SortedSet<String> result = new TreeSet<>();
if (this.flags != null) {
@@ -327,36 +338,43 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
}
private String version;
+ @Override
public String getVersion() {
return this.version;
}
private long bandwidth = -1L;
+ @Override
public long getBandwidth() {
return this.bandwidth;
}
private long measured = -1L;
+ @Override
public long getMeasured() {
return this.measured;
}
private boolean unmeasured = false;
+ @Override
public boolean getUnmeasured() {
return this.unmeasured;
}
private String defaultPolicy;
+ @Override
public String getDefaultPolicy() {
return this.defaultPolicy;
}
private String portList;
+ @Override
public String getPortList() {
return this.portList;
}
private String masterKeyEd25519;
+ @Override
public String getMasterKeyEd25519() {
return this.masterKeyEd25519;
}
diff --git a/src/org/torproject/descriptor/impl/ParseHelper.java b/src/org/torproject/descriptor/impl/ParseHelper.java
index 6ae549b..1d349b4 100644
--- a/src/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/org/torproject/descriptor/impl/ParseHelper.java
@@ -22,7 +22,7 @@ public class ParseHelper {
private static Pattern keywordPattern =
Pattern.compile("^[A-Za-z0-9-]+$");
- public static String parseKeyword(String line, String keyword)
+ protected static String parseKeyword(String line, String keyword)
throws DescriptorParseException {
if (!keywordPattern.matcher(keyword).matches()) {
throw new DescriptorParseException("Unrecognized character in "
@@ -33,7 +33,7 @@ public class ParseHelper {
private static Pattern ipv4Pattern =
Pattern.compile("^[0-9\\.]{7,15}$");
- public static String parseIpv4Address(String line, String address)
+ protected static String parseIpv4Address(String line, String address)
throws DescriptorParseException {
boolean isValid = true;
if (!ipv4Pattern.matcher(address).matches()) {
@@ -62,7 +62,7 @@ public class ParseHelper {
return address;
}
- public static int parsePort(String line, String portString)
+ protected static int parsePort(String line, String portString)
throws DescriptorParseException {
int port = -1;
try {
@@ -78,7 +78,7 @@ public class ParseHelper {
return port;
}
- public static long parseSeconds(String line, String secondsString)
+ protected static long parseSeconds(String line, String secondsString)
throws DescriptorParseException {
try {
return Long.parseLong(secondsString);
@@ -88,7 +88,7 @@ public class ParseHelper {
}
}
- public static String parseExitPattern(String line, String exitPattern)
+ protected static String parseExitPattern(String line, String exitPattern)
throws DescriptorParseException {
if (!exitPattern.contains(":")) {
throw new DescriptorParseException("'" + exitPattern + "' in line '"
@@ -166,7 +166,7 @@ public class ParseHelper {
return threadDateFormats.get(format);
}
- public static long parseTimestampAtIndex(String line, String[] parts,
+ protected static long parseTimestampAtIndex(String line, String[] parts,
int dateIndex, int timeIndex) throws DescriptorParseException {
if (dateIndex >= parts.length || timeIndex >= parts.length) {
throw new DescriptorParseException("Line '" + line + "' does not "
@@ -187,7 +187,7 @@ public class ParseHelper {
return result;
}
- public static long parseDateAtIndex(String line, String[] parts,
+ protected static long parseDateAtIndex(String line, String[] parts,
int dateIndex) throws DescriptorParseException {
if (dateIndex >= parts.length) {
throw new DescriptorParseException("Line '" + line + "' does not "
@@ -209,7 +209,7 @@ public class ParseHelper {
private static Pattern twentyByteHexPattern =
Pattern.compile("^[0-9a-fA-F]{40}$");
- public static String parseTwentyByteHexString(String line,
+ protected static String parseTwentyByteHexString(String line,
String hexString) throws DescriptorParseException {
if (!twentyByteHexPattern.matcher(hexString).matches()) {
throw new DescriptorParseException("Illegal hex string in line '"
@@ -218,7 +218,7 @@ public class ParseHelper {
return hexString.toUpperCase();
}
- public static SortedMap<String, String> parseKeyValueStringPairs(
+ protected static SortedMap<String, String> parseKeyValueStringPairs(
String line, String[] parts, int startIndex, String separatorString)
throws DescriptorParseException {
SortedMap<String, String> result = new TreeMap<>();
@@ -234,7 +234,7 @@ public class ParseHelper {
return result;
}
- public static SortedMap<String, Integer> parseKeyValueIntegerPairs(
+ protected static SortedMap<String, Integer> parseKeyValueIntegerPairs(
String line, String[] parts, int startIndex, String separatorString)
throws DescriptorParseException {
SortedMap<String, Integer> result = new TreeMap<>();
@@ -254,7 +254,7 @@ public class ParseHelper {
private static Pattern nicknamePattern =
Pattern.compile("^[0-9a-zA-Z]{1,19}$");
- public static String parseNickname(String line, String nickname)
+ protected static String parseNickname(String line, String nickname)
throws DescriptorParseException {
if (!nicknamePattern.matcher(nickname).matches()) {
throw new DescriptorParseException("Illegal nickname in line '"
@@ -263,7 +263,7 @@ public class ParseHelper {
return nickname;
}
- public static boolean parseBoolean(String b, String line)
+ protected static boolean parseBoolean(String b, String line)
throws DescriptorParseException {
switch (b) {
case "1":
@@ -277,7 +277,7 @@ public class ParseHelper {
private static Pattern twentyByteBase64Pattern =
Pattern.compile("^[0-9a-zA-Z+/]{27}$");
- public static String parseTwentyByteBase64String(String line,
+ protected static String parseTwentyByteBase64String(String line,
String base64String) throws DescriptorParseException {
if (!twentyByteBase64Pattern.matcher(base64String).matches()) {
throw new DescriptorParseException("'" + base64String
@@ -291,7 +291,7 @@ public class ParseHelper {
private static Pattern thirtyTwoByteBase64Pattern =
Pattern.compile("^[0-9a-zA-Z+/]{43}$");
- public static String parseThirtyTwoByteBase64String(String line,
+ protected static String parseThirtyTwoByteBase64String(String line,
String base64String) throws DescriptorParseException {
if (!thirtyTwoByteBase64Pattern.matcher(base64String).matches()) {
throw new DescriptorParseException("'" + base64String
@@ -305,7 +305,7 @@ public class ParseHelper {
private static Map<Integer, Pattern>
commaSeparatedKeyValueListPatterns = new HashMap<>();
- public static String parseCommaSeparatedKeyIntegerValueList(
+ protected static String parseCommaSeparatedKeyIntegerValueList(
String line, String[] partsNoOpt, int index, int keyLength)
throws DescriptorParseException {
String result = "";
@@ -338,7 +338,7 @@ public class ParseHelper {
return result;
}
- public static SortedMap<String, Integer>
+ protected static SortedMap<String, Integer>
convertCommaSeparatedKeyIntegerValueList(String validatedString) {
SortedMap<String, Integer> result = null;
if (validatedString != null) {
@@ -353,7 +353,7 @@ public class ParseHelper {
return result;
}
- public static SortedMap<String, Long>
+ protected static SortedMap<String, Long>
parseCommaSeparatedKeyLongValueList(String line,
String[] partsNoOpt, int index, int keyLength)
throws DescriptorParseException {
@@ -391,7 +391,7 @@ public class ParseHelper {
return result;
}
- public static Integer[] parseCommaSeparatedIntegerValueList(
+ protected static Integer[] parseCommaSeparatedIntegerValueList(
String line, String[] partsNoOpt, int index)
throws DescriptorParseException {
Integer[] result = null;
@@ -419,7 +419,7 @@ public class ParseHelper {
return result;
}
- public static Double[] parseCommaSeparatedDoubleValueList(
+ protected static Double[] parseCommaSeparatedDoubleValueList(
String line, String[] partsNoOpt, int index)
throws DescriptorParseException {
Double[] result = null;
@@ -480,7 +480,7 @@ public class ParseHelper {
return result;
}
- public static String
+ protected static String
parseMasterKeyEd25519FromIdentityEd25519CryptoBlock(
String identityEd25519CryptoBlock) throws DescriptorParseException {
String identityEd25519CryptoBlockNoNewlines =
diff --git a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
index 873326d..1ff15cb 100644
--- a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
@@ -489,48 +489,57 @@ public class RelayDirectoryImpl extends DescriptorImpl
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private String dirSigningKey;
+ @Override
public String getDirSigningKey() {
return this.dirSigningKey;
}
private List<String> recommendedSoftware;
+ @Override
public List<String> getRecommendedSoftware() {
return this.recommendedSoftware == null ? null :
new ArrayList<>(this.recommendedSoftware);
}
private String directorySignature;
+ @Override
public String getDirectorySignature() {
return this.directorySignature;
}
private List<RouterStatusEntry> statusEntries = new ArrayList<>();
+ @Override
public List<RouterStatusEntry> getRouterStatusEntries() {
return new ArrayList<>(this.statusEntries);
}
private List<ServerDescriptor> serverDescriptors = new ArrayList<>();
+ @Override
public List<ServerDescriptor> getServerDescriptors() {
return new ArrayList<>(this.serverDescriptors);
}
private List<Exception> serverDescriptorParseExceptions =
new ArrayList<>();
+ @Override
public List<Exception> getServerDescriptorParseExceptions() {
return new ArrayList<>(this.serverDescriptorParseExceptions);
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String directoryDigest;
+ @Override
public String getDirectoryDigest() {
return this.directoryDigest;
}
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
index 091ba09..fe045c1 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
@@ -317,80 +317,95 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
}
private String consensusDigest;
+ @Override
public String getConsensusDigest() {
return this.consensusDigest;
}
private int networkStatusVersion;
+ @Override
public int getNetworkStatusVersion() {
return this.networkStatusVersion;
}
private String consensusFlavor;
+ @Override
public String getConsensusFlavor() {
return this.consensusFlavor;
}
private int consensusMethod;
+ @Override
public int getConsensusMethod() {
return this.consensusMethod;
}
private long validAfterMillis;
+ @Override
public long getValidAfterMillis() {
return this.validAfterMillis;
}
private long freshUntilMillis;
+ @Override
public long getFreshUntilMillis() {
return this.freshUntilMillis;
}
private long validUntilMillis;
+ @Override
public long getValidUntilMillis() {
return this.validUntilMillis;
}
private long voteSeconds;
+ @Override
public long getVoteSeconds() {
return this.voteSeconds;
}
private long distSeconds;
+ @Override
public long getDistSeconds() {
return this.distSeconds;
}
private String[] recommendedClientVersions;
+ @Override
public List<String> getRecommendedClientVersions() {
return this.recommendedClientVersions == null ? null :
Arrays.asList(this.recommendedClientVersions);
}
private String[] recommendedServerVersions;
+ @Override
public List<String> getRecommendedServerVersions() {
return this.recommendedServerVersions == null ? null :
Arrays.asList(this.recommendedServerVersions);
}
private List<String> packageLines;
+ @Override
public List<String> getPackageLines() {
return this.packageLines == null ? null
: new ArrayList<>(this.packageLines);
}
private String[] knownFlags;
+ @Override
public SortedSet<String> getKnownFlags() {
return new TreeSet<>(Arrays.asList(this.knownFlags));
}
private SortedMap<String, Integer> consensusParams;
+ @Override
public SortedMap<String, Integer> getConsensusParams() {
return this.consensusParams == null ? null:
new TreeMap<>(this.consensusParams);
}
private SortedMap<String, Integer> bandwidthWeights;
+ @Override
public SortedMap<String, Integer> getBandwidthWeights() {
return this.bandwidthWeights == null ? null :
new TreeMap<>(this.bandwidthWeights);
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
index 9ac3284..a5469db 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
@@ -296,73 +296,87 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
}
private String statusDigest;
+ @Override
public String getStatusDigest() {
return this.statusDigest;
}
private int networkStatusVersion;
+ @Override
public int getNetworkStatusVersion() {
return this.networkStatusVersion;
}
private String hostname;
+ @Override
public String getHostname() {
return this.hostname;
}
private String address;
+ @Override
public String getAddress() {
return this.address;
}
private int dirPort;
+ @Override
public int getDirport() {
return this.dirPort;
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private String contactLine;
+ @Override
public String getContactLine() {
return this.contactLine;
}
private String dirSigningKey;
+ @Override
public String getDirSigningKey() {
return this.dirSigningKey;
}
private String[] recommendedClientVersions;
+ @Override
public List<String> getRecommendedClientVersions() {
return this.recommendedClientVersions == null ? null :
Arrays.asList(this.recommendedClientVersions);
}
private String[] recommendedServerVersions;
+ @Override
public List<String> getRecommendedServerVersions() {
return this.recommendedServerVersions == null ? null :
Arrays.asList(this.recommendedServerVersions);
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private String[] dirOptions;
+ @Override
public SortedSet<String> getDirOptions() {
return new TreeSet<>(Arrays.asList(this.dirOptions));
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String directorySignature;
+ @Override
public String getDirectorySignature() {
return this.directorySignature;
}
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index f378a79..d9bdd3c 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -513,80 +513,96 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String identity;
+ @Override
public String getIdentity() {
return this.identity;
}
private String hostname;
+ @Override
public String getHostname() {
return this.hostname;
}
private String address;
+ @Override
public String getAddress() {
return this.address;
}
private int dirPort;
+ @Override
public int getDirport() {
return this.dirPort;
}
private int orPort;
+ @Override
public int getOrport() {
return this.orPort;
}
private String contactLine;
+ @Override
public String getContactLine() {
return this.contactLine;
}
private int dirKeyCertificateVersion;
+ @Override
public int getDirKeyCertificateVersion() {
return this.dirKeyCertificateVersion;
}
private String legacyDirKey;
+ @Override
public String getLegacyDirKey() {
return this.legacyDirKey;
}
private long dirKeyPublishedMillis;
+ @Override
public long getDirKeyPublishedMillis() {
return this.dirKeyPublishedMillis;
}
private long dirKeyExpiresMillis;
+ @Override
public long getDirKeyExpiresMillis() {
return this.dirKeyExpiresMillis;
}
private String dirIdentityKey;
+ @Override
public String getDirIdentityKey() {
return this.dirIdentityKey;
}
private String dirSigningKey;
+ @Override
public String getDirSigningKey() {
return this.dirSigningKey;
}
private String dirKeyCrosscert;
+ @Override
public String getDirKeyCrosscert() {
return this.dirKeyCrosscert;
}
private String dirKeyCertification;
+ @Override
public String getDirKeyCertification() {
return this.dirKeyCertification;
}
+ @Override
public String getSigningKeyDigest() {
String signingKeyDigest = null;
if (!this.directorySignatures.isEmpty()) {
@@ -597,115 +613,137 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
}
private int networkStatusVersion;
+ @Override
public int getNetworkStatusVersion() {
return this.networkStatusVersion;
}
private Integer[] consensusMethods;
+ @Override
public List<Integer> getConsensusMethods() {
return this.consensusMethods == null ? null :
Arrays.asList(this.consensusMethods);
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private long validAfterMillis;
+ @Override
public long getValidAfterMillis() {
return this.validAfterMillis;
}
private long freshUntilMillis;
+ @Override
public long getFreshUntilMillis() {
return this.freshUntilMillis;
}
private long validUntilMillis;
+ @Override
public long getValidUntilMillis() {
return this.validUntilMillis;
}
private long voteSeconds;
+ @Override
public long getVoteSeconds() {
return this.voteSeconds;
}
private long distSeconds;
+ @Override
public long getDistSeconds() {
return this.distSeconds;
}
private String[] recommendedClientVersions;
+ @Override
public List<String> getRecommendedClientVersions() {
return this.recommendedClientVersions == null ? null :
Arrays.asList(this.recommendedClientVersions);
}
private String[] recommendedServerVersions;
+ @Override
public List<String> getRecommendedServerVersions() {
return this.recommendedServerVersions == null ? null :
Arrays.asList(this.recommendedServerVersions);
}
private List<String> packageLines;
+ @Override
public List<String> getPackageLines() {
return this.packageLines == null ? null
: new ArrayList<>(this.packageLines);
}
private String[] knownFlags;
+ @Override
public SortedSet<String> getKnownFlags() {
return new TreeSet<>(Arrays.asList(this.knownFlags));
}
private long stableUptime;
+ @Override
public long getStableUptime() {
return this.stableUptime;
}
private long stableMtbf;
+ @Override
public long getStableMtbf() {
return this.stableMtbf;
}
private long fastBandwidth;
+ @Override
public long getFastBandwidth() {
return this.fastBandwidth;
}
private double guardWfu;
+ @Override
public double getGuardWfu() {
return this.guardWfu;
}
private long guardTk;
+ @Override
public long getGuardTk() {
return this.guardTk;
}
private long guardBandwidthIncludingExits;
+ @Override
public long getGuardBandwidthIncludingExits() {
return this.guardBandwidthIncludingExits;
}
private long guardBandwidthExcludingExits;
+ @Override
public long getGuardBandwidthExcludingExits() {
return this.guardBandwidthExcludingExits;
}
private int enoughMtbfInfo;
+ @Override
public int getEnoughMtbfInfo() {
return this.enoughMtbfInfo;
}
private int ignoringAdvertisedBws;
+ @Override
public int getIgnoringAdvertisedBws() {
return this.ignoringAdvertisedBws;
}
private SortedMap<String, Integer> consensusParams;
+ @Override
public SortedMap<String, Integer> getConsensusParams() {
return this.consensusParams == null ? null:
new TreeMap<>(this.consensusParams);
diff --git a/src/org/torproject/descriptor/impl/RouterStatusEntryImpl.java b/src/org/torproject/descriptor/impl/RouterStatusEntryImpl.java
index c6942e8..a359c50 100644
--- a/src/org/torproject/descriptor/impl/RouterStatusEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/RouterStatusEntryImpl.java
@@ -15,21 +15,25 @@ public class RouterStatusEntryImpl implements RouterStatusEntry {
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private boolean isLive;
+ @Override
public boolean isLive() {
return this.isLive;
}
private boolean isVerified;
+ @Override
public boolean isVerified() {
return this.isVerified;
}
diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index 8b6e983..aa9cc02 100644
--- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -715,210 +715,251 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl
}
private String serverDescriptorDigest;
+ @Override
public String getServerDescriptorDigest() {
return this.serverDescriptorDigest;
}
private String serverDescriptorDigestSha256;
+ @Override
public String getServerDescriptorDigestSha256() {
return this.serverDescriptorDigestSha256;
}
private String nickname;
+ @Override
public String getNickname() {
return this.nickname;
}
private String address;
+ @Override
public String getAddress() {
return this.address;
}
private int orPort;
+ @Override
public int getOrPort() {
return this.orPort;
}
private int socksPort;
+ @Override
public int getSocksPort() {
return this.socksPort;
}
private int dirPort;
+ @Override
public int getDirPort() {
return this.dirPort;
}
private List<String> orAddresses = new ArrayList<>();
+ @Override
public List<String> getOrAddresses() {
return new ArrayList<>(this.orAddresses);
}
private int bandwidthRate;
+ @Override
public int getBandwidthRate() {
return this.bandwidthRate;
}
private int bandwidthBurst;
+ @Override
public int getBandwidthBurst() {
return this.bandwidthBurst;
}
private int bandwidthObserved;
+ @Override
public int getBandwidthObserved() {
return this.bandwidthObserved;
}
private String platform;
+ @Override
public String getPlatform() {
return this.platform;
}
private long publishedMillis;
+ @Override
public long getPublishedMillis() {
return this.publishedMillis;
}
private String fingerprint;
+ @Override
public String getFingerprint() {
return this.fingerprint;
}
private boolean hibernating;
+ @Override
public boolean isHibernating() {
return this.hibernating;
}
private Long uptime;
+ @Override
public Long getUptime() {
return this.uptime;
}
private String onionKey;
+ @Override
public String getOnionKey() {
return this.onionKey;
}
private String signingKey;
+ @Override
public String getSigningKey() {
return this.signingKey;
}
private List<String> exitPolicyLines = new ArrayList<>();
+ @Override
public List<String> getExitPolicyLines() {
return new ArrayList<>(this.exitPolicyLines);
}
private String routerSignature;
+ @Override
public String getRouterSignature() {
return this.routerSignature;
}
private String contact;
+ @Override
public String getContact() {
return this.contact;
}
private String[] familyEntries;
+ @Override
public List<String> getFamilyEntries() {
return this.familyEntries == null ? null :
Arrays.asList(this.familyEntries);
}
private BandwidthHistory readHistory;
+ @Override
public BandwidthHistory getReadHistory() {
return this.readHistory;
}
private BandwidthHistory writeHistory;
+ @Override
public BandwidthHistory getWriteHistory() {
return this.writeHistory;
}
private boolean usesEnhancedDnsLogic;
+ @Override
public boolean getUsesEnhancedDnsLogic() {
return this.usesEnhancedDnsLogic;
}
private boolean cachesExtraInfo;
+ @Override
public boolean getCachesExtraInfo() {
return this.cachesExtraInfo;
}
private String extraInfoDigest;
+ @Override
public String getExtraInfoDigest() {
return this.extraInfoDigest;
}
private String extraInfoDigestSha256;
+ @Override
public String getExtraInfoDigestSha256() {
return this.extraInfoDigestSha256;
}
private Integer[] hiddenServiceDirVersions;
+ @Override
public List<Integer> getHiddenServiceDirVersions() {
return this.hiddenServiceDirVersions == null ? null :
Arrays.asList(this.hiddenServiceDirVersions);
}
private Integer[] linkProtocolVersions;
+ @Override
public List<Integer> getLinkProtocolVersions() {
return this.linkProtocolVersions == null ? null :
Arrays.asList(this.linkProtocolVersions);
}
private Integer[] circuitProtocolVersions;
+ @Override
public List<Integer> getCircuitProtocolVersions() {
return this.circuitProtocolVersions == null ? null :
Arrays.asList(this.circuitProtocolVersions);
}
private boolean allowSingleHopExits;
+ @Override
public boolean getAllowSingleHopExits() {
return this.allowSingleHopExits;
}
private String ipv6DefaultPolicy;
+ @Override
public String getIpv6DefaultPolicy() {
return this.ipv6DefaultPolicy;
}
private String ipv6PortList;
+ @Override
public String getIpv6PortList() {
return this.ipv6PortList;
}
private String ntorOnionKey;
+ @Override
public String getNtorOnionKey() {
return this.ntorOnionKey;
}
private String identityEd25519;
+ @Override
public String getIdentityEd25519() {
return this.identityEd25519;
}
private String masterKeyEd25519;
+ @Override
public String getMasterKeyEd25519() {
return this.masterKeyEd25519;
}
private String routerSignatureEd25519;
+ @Override
public String getRouterSignatureEd25519() {
return this.routerSignatureEd25519;
}
private String onionKeyCrosscert;
+ @Override
public String getOnionKeyCrosscert() {
return this.onionKeyCrosscert;
}
private String ntorOnionKeyCrosscert;
+ @Override
public String getNtorOnionKeyCrosscert() {
return this.ntorOnionKeyCrosscert;
}
private int ntorOnionKeyCrosscertSign = -1;
+ @Override
public int getNtorOnionKeyCrosscertSign() {
return ntorOnionKeyCrosscertSign;
}
diff --git a/src/org/torproject/descriptor/impl/TorperfResultImpl.java b/src/org/torproject/descriptor/impl/TorperfResultImpl.java
index 62cf68d..0800de0 100644
--- a/src/org/torproject/descriptor/impl/TorperfResultImpl.java
+++ b/src/org/torproject/descriptor/impl/TorperfResultImpl.java
@@ -18,7 +18,7 @@ import org.torproject.descriptor.TorperfResult;
public class TorperfResultImpl extends DescriptorImpl
implements TorperfResult {
- public static List<Descriptor> parseTorperfResults(
+ protected static List<Descriptor> parseTorperfResults(
byte[] rawDescriptorBytes, boolean failUnrecognizedDescriptorLines)
throws DescriptorParseException {
if (rawDescriptorBytes.length == 0) {
@@ -397,124 +397,148 @@ public class TorperfResultImpl extends DescriptorImpl
}
private SortedMap<String, String> unrecognizedKeys;
+ @Override
public SortedMap<String, String> getUnrecognizedKeys() {
return this.unrecognizedKeys == null ? null
: new TreeMap<>(this.unrecognizedKeys);
}
private String source;
+ @Override
public String getSource() {
return this.source;
}
private int fileSize;
+ @Override
public int getFileSize() {
return this.fileSize;
}
private long startMillis;
+ @Override
public long getStartMillis() {
return this.startMillis;
}
private long socketMillis;
+ @Override
public long getSocketMillis() {
return this.socketMillis;
}
private long connectMillis;
+ @Override
public long getConnectMillis() {
return this.connectMillis;
}
private long negotiateMillis;
+ @Override
public long getNegotiateMillis() {
return this.negotiateMillis;
}
private long requestMillis;
+ @Override
public long getRequestMillis() {
return this.requestMillis;
}
private long responseMillis;
+ @Override
public long getResponseMillis() {
return this.responseMillis;
}
private long dataRequestMillis;
+ @Override
public long getDataRequestMillis() {
return this.dataRequestMillis;
}
private long dataResponseMillis;
+ @Override
public long getDataResponseMillis() {
return this.dataResponseMillis;
}
private long dataCompleteMillis;
+ @Override
public long getDataCompleteMillis() {
return this.dataCompleteMillis;
}
private int writeBytes;
+ @Override
public int getWriteBytes() {
return this.writeBytes;
}
private int readBytes;
+ @Override
public int getReadBytes() {
return this.readBytes;
}
private boolean didTimeout;
+ @Override
public Boolean didTimeout() {
return this.didTimeout;
}
private SortedMap<Integer, Long> dataPercentiles;
+ @Override
public SortedMap<Integer, Long> getDataPercentiles() {
return this.dataPercentiles == null ? null
: new TreeMap<>(this.dataPercentiles);
}
private long launchMillis = -1L;
+ @Override
public long getLaunchMillis() {
return this.launchMillis;
}
private long usedAtMillis = -1L;
+ @Override
public long getUsedAtMillis() {
return this.usedAtMillis;
}
private String[] path;
+ @Override
public List<String> getPath() {
return this.path == null ? null : Arrays.asList(this.path);
}
private Long[] buildTimes;
+ @Override
public List<Long> getBuildTimes() {
return this.buildTimes == null ? null :
Arrays.asList(this.buildTimes);
}
private long timeout = -1L;
+ @Override
public long getTimeout() {
return this.timeout;
}
private double quantile = -1.0;
+ @Override
public double getQuantile() {
return this.quantile;
}
private int circId = -1;
+ @Override
public int getCircId() {
return this.circId;
}
private int usedBy = -1;
+ @Override
public int getUsedBy() {
return this.usedBy;
}
1
0

[snowflake/master] improve client interface specificity and composability which eliminates much unnecessary code
by serene@torproject.org 13 Jun '16
by serene@torproject.org 13 Jun '16
13 Jun '16
commit 4ca0a3aa0a964e23549a7088cb14c8e1a0f932a5
Author: Serene Han <keroserene+git(a)gmail.com>
Date: Mon Jun 13 11:05:26 2016 -0700
improve client interface specificity and composability which eliminates much unnecessary code
---
client/client_test.go | 87 ++++++++++++++++++++++-----------------------------
client/interfaces.go | 24 ++++++++++++--
client/peers.go | 8 ++---
client/rendezvous.go | 4 +--
client/snowflake.go | 34 ++++++++++----------
client/webrtc.go | 47 +++++++++++-----------------
6 files changed, 100 insertions(+), 104 deletions(-)
diff --git a/client/client_test.go b/client/client_test.go
index de83768..87fb2cb 100644
--- a/client/client_test.go
+++ b/client/client_test.go
@@ -47,7 +47,7 @@ func (m *MockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
type FakeDialer struct{}
-func (w FakeDialer) Catch() (*webRTCConn, error) {
+func (w FakeDialer) Catch() (Snowflake, error) {
fmt.Println("Caught a dummy snowflake.")
return &webRTCConn{}, nil
}
@@ -65,57 +65,10 @@ func (f FakeSocksConn) Grant(addr *net.TCPAddr) error { return nil }
type FakePeers struct{ toRelease *webRTCConn }
-func (f FakePeers) Collect() error { return nil }
-func (f FakePeers) Pop() *webRTCConn { return nil }
+func (f FakePeers) Collect() error { return nil }
+func (f FakePeers) Pop() Snowflake { return nil }
func TestSnowflakeClient(t *testing.T) {
- SkipConvey("WebRTC ConnectLoop", t, func() {
- Convey("WebRTC ConnectLoop continues until capacity of 1.\n", func() {
- snowflakes := NewPeers(1)
- snowflakes.Tongue = FakeDialer{}
-
- go ConnectLoop(snowflakes)
- // <-snowflakes.maxedChan
-
- So(snowflakes.Count(), ShouldEqual, 1)
- r := <-snowflakes.snowflakeChan
- So(r, ShouldNotBeNil)
- So(snowflakes.Count(), ShouldEqual, 0)
- })
-
- Convey("WebRTC ConnectLoop continues until capacity of 3.\n", func() {
- snowflakes := NewPeers(3)
- snowflakes.Tongue = FakeDialer{}
-
- go ConnectLoop(snowflakes)
- // <-snowflakes.maxedChan
- So(snowflakes.Count(), ShouldEqual, 3)
- <-snowflakes.snowflakeChan
- <-snowflakes.snowflakeChan
- <-snowflakes.snowflakeChan
- So(snowflakes.Count(), ShouldEqual, 0)
- })
-
- Convey("WebRTC ConnectLoop continues filling when Snowflakes disconnect.\n", func() {
- snowflakes := NewPeers(3)
- snowflakes.Tongue = FakeDialer{}
-
- go ConnectLoop(snowflakes)
- // <-snowflakes.maxedChan
- So(snowflakes.Count(), ShouldEqual, 3)
-
- r := <-snowflakes.snowflakeChan
- So(snowflakes.Count(), ShouldEqual, 2)
- r.Close()
- // <-snowflakes.maxedChan
- So(snowflakes.Count(), ShouldEqual, 3)
-
- <-snowflakes.snowflakeChan
- <-snowflakes.snowflakeChan
- <-snowflakes.snowflakeChan
- So(snowflakes.Count(), ShouldEqual, 0)
- })
- })
Convey("Peers", t, func() {
Convey("Can construct", func() {
@@ -183,6 +136,17 @@ func TestSnowflakeClient(t *testing.T) {
So(p.Count(), ShouldEqual, 2)
})
+ Convey("End Closes all peers.", func() {
+ cnt := 5
+ p := NewPeers(cnt)
+ for i := 0; i < cnt; i++ {
+ p.activePeers.PushBack(&webRTCConn{})
+ }
+ So(p.Count(), ShouldEqual, cnt)
+ p.End()
+ So(p.Count(), ShouldEqual, 0)
+ })
+
})
Convey("Snowflake", t, func() {
@@ -253,6 +217,29 @@ func TestSnowflakeClient(t *testing.T) {
})
})
+ Convey("Dialers", t, func() {
+ Convey("Can construct WebRTCDialer.", func() {
+ broker := &BrokerChannel{Host: "test"}
+ d := NewWebRTCDialer(broker, nil)
+ So(d, ShouldNotBeNil)
+ So(d.BrokerChannel, ShouldNotBeNil)
+ So(d.BrokerChannel.Host, ShouldEqual, "test")
+ })
+ Convey("WebRTCDialer cannot Catch a snowflake with nil broker.", func() {
+ d := NewWebRTCDialer(nil, nil)
+ conn, err := d.Catch()
+ So(conn, ShouldBeNil)
+ So(err, ShouldNotBeNil)
+ })
+ SkipConvey("WebRTCDialer can Catch a snowflake.", func() {
+ broker := &BrokerChannel{Host: "test"}
+ d := NewWebRTCDialer(broker, nil)
+ conn, err := d.Catch()
+ So(conn, ShouldBeNil)
+ So(err, ShouldNotBeNil)
+ })
+ })
+
Convey("Rendezvous", t, func() {
webrtc.SetLoggingVerbosity(0)
transport := &MockTransport{http.StatusOK}
diff --git a/client/interfaces.go b/client/interfaces.go
index ba49a92..4fb0dcf 100644
--- a/client/interfaces.go
+++ b/client/interfaces.go
@@ -1,13 +1,31 @@
-// In the Client context, "Snowflake" refers to a remote browser proxy.
package main
import (
+ "io"
"net"
)
+type Connector interface {
+ Connect() error
+}
+
+type Resetter interface {
+ Reset()
+ WaitForReset()
+}
+
+// Interface for a single remote WebRTC peer.
+// In the Client context, "Snowflake" refers to the remote browser proxy.
+type Snowflake interface {
+ io.ReadWriter
+ Resetter
+ Connector
+ Close() error
+}
+
// Interface for catching Snowflakes. (aka the remote dialer)
type Tongue interface {
- Catch() (*webRTCConn, error)
+ Catch() (Snowflake, error)
}
// Interface for collecting some number of Snowflakes, for passing along
@@ -19,7 +37,7 @@ type SnowflakeCollector interface {
Collect() error
// Remove and return the most available Snowflake from the collection.
- Pop() *webRTCConn
+ Pop() Snowflake
}
// Interface to adapt to goptlib's SocksConn struct.
diff --git a/client/peers.go b/client/peers.go
index 734fdfe..eb435fd 100644
--- a/client/peers.go
+++ b/client/peers.go
@@ -22,7 +22,7 @@ type Peers struct {
Tongue
BytesLogger
- snowflakeChan chan *webRTCConn
+ snowflakeChan chan Snowflake
activePeers *list.List
capacity int
}
@@ -31,7 +31,7 @@ type Peers struct {
func NewPeers(max int) *Peers {
p := &Peers{capacity: max}
// Use buffered go channel to pass snowflakes onwards to the SOCKS handler.
- p.snowflakeChan = make(chan *webRTCConn, max)
+ p.snowflakeChan = make(chan Snowflake, max)
p.activePeers = list.New()
return p
}
@@ -59,7 +59,7 @@ func (p *Peers) Collect() error {
}
// As part of |SnowflakeCollector| interface.
-func (p *Peers) Pop() *webRTCConn {
+func (p *Peers) Pop() Snowflake {
// Blocks until an available snowflake appears.
snowflake, ok := <-p.snowflakeChan
@@ -67,7 +67,7 @@ func (p *Peers) Pop() *webRTCConn {
return nil
}
// Set to use the same rate-limited traffic logger to keep consistency.
- snowflake.BytesLogger = p.BytesLogger
+ snowflake.(*webRTCConn).BytesLogger = p.BytesLogger
return snowflake
}
diff --git a/client/rendezvous.go b/client/rendezvous.go
index 0acee80..6c7aa44 100644
--- a/client/rendezvous.go
+++ b/client/rendezvous.go
@@ -128,7 +128,7 @@ func NewWebRTCDialer(
}
// Initialize a WebRTC Connection by signaling through the broker.
-func (w WebRTCDialer) Catch() (*webRTCConn, error) {
+func (w WebRTCDialer) Catch() (Snowflake, error) {
if nil == w.BrokerChannel {
return nil, errors.New("Cannot Dial WebRTC without a BrokerChannel.")
}
@@ -174,7 +174,7 @@ func NewCopyPasteDialer(iceServers IceServerList) *CopyPasteDialer {
}
// Initialize a WebRTC connection via manual copy-paste.
-func (d *CopyPasteDialer) Catch() (*webRTCConn, error) {
+func (d *CopyPasteDialer) Catch() (Snowflake, error) {
if nil == d.signal {
return nil, errors.New("Cannot copy-paste dial without signal pipe.")
}
diff --git a/client/snowflake.go b/client/snowflake.go
index 7c06b17..9f5cdc7 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -26,21 +26,6 @@ const (
// ends, -1 is written.
var handlerChan = make(chan int)
-func copyLoop(a, b net.Conn) {
- var wg sync.WaitGroup
- wg.Add(2)
- go func() {
- io.Copy(b, a)
- wg.Done()
- }()
- go func() {
- io.Copy(a, b)
- wg.Done()
- }()
- wg.Wait()
- log.Println("copy loop ended")
-}
-
// Maintain |SnowflakeCapacity| number of available WebRTC connections, to
// transfer to the Tor SOCKS handler when needed.
func ConnectLoop(snowflakes SnowflakeCollector) {
@@ -104,11 +89,28 @@ func handler(socks SocksConnector, snowflakes SnowflakeCollector) error {
// When WebRTC resets, close the SOCKS connection, which induces new handler.
// TODO: Double check this / fix it.
- <-snowflake.reset
+ snowflake.WaitForReset()
log.Println("---- Closed ---")
return nil
}
+// Exchanges bytes between two ReadWriters.
+// (In this case, between a SOCKS and WebRTC connection.)
+func copyLoop(a, b io.ReadWriter) {
+ var wg sync.WaitGroup
+ wg.Add(2)
+ go func() {
+ io.Copy(b, a)
+ wg.Done()
+ }()
+ go func() {
+ io.Copy(a, b)
+ wg.Done()
+ }()
+ wg.Wait()
+ log.Println("copy loop ended")
+}
+
func main() {
webrtc.SetLoggingVerbosity(1)
logFile, err := os.OpenFile("snowflake.log",
diff --git a/client/webrtc.go b/client/webrtc.go
index 2d26b7a..c7a46ea 100644
--- a/client/webrtc.go
+++ b/client/webrtc.go
@@ -3,15 +3,15 @@ package main
import (
"bytes"
"errors"
- "fmt"
"github.com/keroserene/go-webrtc"
"io"
"log"
- "net"
"time"
)
-// Remote WebRTC peer. Implements the |net.Conn| interface.
+// Remote WebRTC peer.
+// Implements the |Snowflake| interface, which includes
+// |io.ReadWriter|, |Resetter|, and |Connector|.
type webRTCConn struct {
config *webrtc.Configuration
pc *webrtc.PeerConnection
@@ -33,11 +33,14 @@ type webRTCConn struct {
BytesLogger
}
+// Read bytes from remote WebRTC.
+// As part of |io.ReadWriter|
func (c *webRTCConn) Read(b []byte) (int, error) {
return c.recvPipe.Read(b)
}
-// Writes bytes out to the snowflake proxy.
+// Writes bytes out to remote WebRTC.
+// As part of |io.ReadWriter|
func (c *webRTCConn) Write(b []byte) (int, error) {
c.BytesLogger.AddOutbound(len(b))
if nil == c.snowflake {
@@ -49,6 +52,7 @@ func (c *webRTCConn) Write(b []byte) (int, error) {
return len(b), nil
}
+// As part of |Snowflake|
func (c *webRTCConn) Close() error {
var err error = nil
log.Printf("WebRTC: Closing")
@@ -67,25 +71,17 @@ func (c *webRTCConn) Close() error {
return err
}
-func (c *webRTCConn) LocalAddr() net.Addr {
- return nil
-}
-
-func (c *webRTCConn) RemoteAddr() net.Addr {
- return nil
-}
-
-func (c *webRTCConn) SetDeadline(t time.Time) error {
- return fmt.Errorf("SetDeadline not implemented")
-}
-
-func (c *webRTCConn) SetReadDeadline(t time.Time) error {
- return fmt.Errorf("SetReadDeadline not implemented")
+// As part of |Resetter|
+func (c *webRTCConn) Reset() {
+ go func() {
+ c.reset <- struct{}{}
+ log.Println("WebRTC resetting...")
+ }()
+ c.Close()
}
-func (c *webRTCConn) SetWriteDeadline(t time.Time) error {
- return fmt.Errorf("SetWriteDeadline not implemented")
-}
+// As part of |Resetter|
+func (c *webRTCConn) WaitForReset() { <-c.reset }
// Construct a WebRTC PeerConnection.
func NewWebRTCConnection(config *webrtc.Configuration,
@@ -108,6 +104,7 @@ func NewWebRTCConnection(config *webrtc.Configuration,
return connection
}
+// As part of |Connector| interface.
func (c *webRTCConn) Connect() error {
log.Printf("Establishing WebRTC connection #%d...", c.index)
// TODO: When go-webrtc is more stable, it's possible that a new
@@ -287,14 +284,6 @@ func (c *webRTCConn) exchangeSDP() error {
return nil
}
-func (c *webRTCConn) Reset() {
- go func() {
- c.reset <- struct{}{}
- log.Println("WebRTC resetting...")
- }()
- c.Close()
-}
-
func (c *webRTCConn) cleanup() {
if nil != c.snowflake {
log.Printf("WebRTC: closing DataChannel")
1
0