Synchronize manual cache

Re-sync our manual cache with tor and correct a few issues with regard to
python 3 and asyncio compatibility.
This commit is contained in:
Damian Johnson 2020-07-18 16:14:13 -07:00
parent a3eab95d6a
commit 950895c9b3
4 changed files with 43 additions and 9 deletions

View File

@ -14,12 +14,12 @@ import stem.manual
import stem.util.system
GITWEB_MAN_LOG = 'https://gitweb.torproject.org/tor.git/log/doc/tor.1.txt'
MAN_LOG_LINK = "href='/tor.git/commit/doc/tor.1.txt\\?id=([^']*)'"
MAN_LOG_LINK = b"href='/tor.git/commit/doc/tor.1.txt\\?id=([^']*)'"
if __name__ == '__main__':
try:
man_log_page = urllib.request.urlopen(GITWEB_MAN_LOG).read()
man_commit = re.search(MAN_LOG_LINK, man_log_page).group(1)
man_commit = re.search(MAN_LOG_LINK, man_log_page).group(1).decode('utf-8')
except:
print("Unable to determine the latest commit to edit tor's man page: %s" % sys.exc_info()[1])
sys.exit(1)

Binary file not shown.

View File

@ -66,7 +66,7 @@ import stem.util.system
from typing import Any, BinaryIO, Dict, List, Mapping, Optional, Sequence, Tuple, Union
Category = stem.util.enum.Enum('GENERAL', 'CLIENT', 'RELAY', 'DIRECTORY', 'AUTHORITY', 'HIDDEN_SERVICE', 'DENIAL_OF_SERVICE', 'TESTING', 'UNKNOWN')
Category = stem.util.enum.Enum('GENERAL', 'CLIENT', 'CIRCUIT_TIMEOUT', 'DORMANT_MODE', 'NODE_SELECTION', 'RELAY', 'STATISTIC', 'DIRECTORY', 'AUTHORITY', 'HIDDEN_SERVICE', 'DENIAL_OF_SERVICE', 'TESTING', 'UNKNOWN')
GITWEB_MANUAL_URL = 'https://gitweb.torproject.org/tor.git/plain/doc/man/tor.1.txt'
CACHE_PATH = os.path.join(os.path.dirname(__file__), 'cached_manual.sqlite')
DATABASE = None # cache database connections
@ -87,7 +87,11 @@ SCHEMA = (
CATEGORY_SECTIONS = collections.OrderedDict((
('GENERAL OPTIONS', Category.GENERAL),
('CLIENT OPTIONS', Category.CLIENT),
('CIRCUIT TIMEOUT OPTIONS', Category.CIRCUIT_TIMEOUT),
('DORMANT MODE OPTIONS', Category.DORMANT_MODE),
('NODE SELECTION OPTIONS', Category.NODE_SELECTION),
('SERVER OPTIONS', Category.RELAY),
('STATISTICS OPTIONS', Category.STATISTIC),
('DIRECTORY SERVER OPTIONS', Category.DIRECTORY),
('DIRECTORY AUTHORITY SERVER OPTIONS', Category.AUTHORITY),
('HIDDEN SERVICE OPTIONS', Category.HIDDEN_SERVICE),

View File

@ -14,6 +14,7 @@ import test
import test.runner
from stem.manual import Category
from stem.util.test_tools import async_test
EXPECTED_CATEGORIES = set([
'NAME',
@ -23,7 +24,11 @@ EXPECTED_CATEGORIES = set([
'THE CONFIGURATION FILE FORMAT',
'GENERAL OPTIONS',
'CLIENT OPTIONS',
'CIRCUIT TIMEOUT OPTIONS',
'DORMANT MODE OPTIONS',
'NODE SELECTION OPTIONS',
'SERVER OPTIONS',
'STATISTICS OPTIONS',
'DIRECTORY SERVER OPTIONS',
'DIRECTORY AUTHORITY SERVER OPTIONS',
'HIDDEN SERVICE OPTIONS',
@ -38,7 +43,30 @@ EXPECTED_CATEGORIES = set([
'AUTHORS',
])
EXPECTED_CLI_OPTIONS = set(['-f FILE', '--hash-password PASSWORD', '--ignore-missing-torrc', '--defaults-torrc FILE', '--key-expiration [purpose]', '--list-fingerprint', '--list-deprecated-options', '--allow-missing-torrc', '--nt-service', '--verify-config', '--dump-config short|full|non-builtin', '--service remove|start|stop', '--passphrase-fd FILEDES', '--keygen [--newpass]', '--list-torrc-options', '--service install [--options command-line options]', '--list-modules', '--quiet|--hush', '--version', '-h, --help'])
EXPECTED_CLI_OPTIONS = set([
'--allow-missing-torrc',
'--dbg-...',
'--defaults-torrc FILE',
'--dump-config short|full',
'--hash-password PASSWORD',
'--ignore-missing-torrc',
'--key-expiration [purpose]',
'--keygen [--newpass]',
'--list-deprecated-options',
'--list-fingerprint',
'--list-modules',
'--list-torrc-options',
'--nt-service',
'--passphrase-fd FILEDES',
'--quiet|--hush',
'--service install [--options command-line options]',
'--service remove|start|stop',
'--verify-config',
'--version',
'-f FILE',
'-h, --help',
])
EXPECTED_SIGNALS = set(['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGUSR1', 'SIGUSR2', 'SIGCHLD', 'SIGPIPE', 'SIGXFSZ'])
EXPECTED_DESCRIPTION = """
@ -216,20 +244,22 @@ class TestManual(unittest.TestCase):
self.assertEqual(['tor - The second-generation onion router'], categories['NAME'])
self.assertEqual(['tor [OPTION value]...'], categories['SYNOPSIS'])
def test_has_all_tor_config_options(self):
@async_test
async def test_has_all_tor_config_options(self):
"""
Check that all the configuration options tor supports are in the man page.
"""
self.requires_downloaded_manual()
with test.runner.get_runner().get_tor_controller() as controller:
config_options_in_tor = set([line.split()[0] for line in controller.get_info('config/names').splitlines() if line.split()[1] != 'Virtual'])
async with await test.runner.get_runner().get_tor_controller() as controller:
config_options_in_tor = set([line.split()[0] for line in (await controller.get_info('config/names')).splitlines() if line.split()[1] != 'Virtual'])
# options starting with an underscore are hidden by convention
# options starting with an underscore are hidden by convention, but the
# manual includes OwningControllerProcess
for name in list(config_options_in_tor):
if name.startswith('_'):
if name.startswith('_') and name != '__OwningControllerProcess':
config_options_in_tor.remove(name)
manual = stem.manual.Manual.from_man(self.man_path)