mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 11:16:24 +00:00
tor/i2p: rename create_onion/create_dest to create_config
This commit is contained in:
parent
856425fe0f
commit
d1fd43aa4f
@ -251,12 +251,12 @@ def write_node_config(c, config):
|
|||||||
else:
|
else:
|
||||||
if "tor" in listeners:
|
if "tor" in listeners:
|
||||||
(tor_config, tor_port, tor_location) = \
|
(tor_config, tor_port, tor_location) = \
|
||||||
yield tor_provider.create_onion(reactor, config)
|
yield tor_provider.create_config(reactor, config)
|
||||||
tub_ports.append(tor_port)
|
tub_ports.append(tor_port)
|
||||||
tub_locations.append(tor_location)
|
tub_locations.append(tor_location)
|
||||||
if "i2p" in listeners:
|
if "i2p" in listeners:
|
||||||
(i2p_config, i2p_port, i2p_location) = \
|
(i2p_config, i2p_port, i2p_location) = \
|
||||||
yield i2p_provider.create_dest(reactor, config)
|
yield i2p_provider.create_config(reactor, config)
|
||||||
tub_ports.append(i2p_port)
|
tub_ports.append(i2p_port)
|
||||||
tub_locations.append(i2p_location)
|
tub_locations.append(i2p_location)
|
||||||
if "tcp" in listeners:
|
if "tcp" in listeners:
|
||||||
|
@ -261,7 +261,7 @@ class Config(unittest.TestCase):
|
|||||||
def test_node_slow_tor(self):
|
def test_node_slow_tor(self):
|
||||||
basedir = self.mktemp()
|
basedir = self.mktemp()
|
||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
with mock.patch("allmydata.util.tor_provider.create_onion",
|
with mock.patch("allmydata.util.tor_provider.create_config",
|
||||||
return_value=d):
|
return_value=d):
|
||||||
d2 = run_cli("create-node", "--listen=tor", basedir)
|
d2 = run_cli("create-node", "--listen=tor", basedir)
|
||||||
d.callback(({}, "port", "location"))
|
d.callback(({}, "port", "location"))
|
||||||
@ -274,7 +274,7 @@ class Config(unittest.TestCase):
|
|||||||
def test_node_slow_i2p(self):
|
def test_node_slow_i2p(self):
|
||||||
basedir = self.mktemp()
|
basedir = self.mktemp()
|
||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
with mock.patch("allmydata.util.i2p_provider.create_dest",
|
with mock.patch("allmydata.util.i2p_provider.create_config",
|
||||||
return_value=d):
|
return_value=d):
|
||||||
d2 = run_cli("create-node", "--listen=i2p", basedir)
|
d2 = run_cli("create-node", "--listen=i2p", basedir)
|
||||||
d.callback(({}, "port", "location"))
|
d.callback(({}, "port", "location"))
|
||||||
@ -325,9 +325,9 @@ class Tor(unittest.TestCase):
|
|||||||
tor_config = {"abc": "def"}
|
tor_config = {"abc": "def"}
|
||||||
tor_port = "ghi"
|
tor_port = "ghi"
|
||||||
tor_location = "jkl"
|
tor_location = "jkl"
|
||||||
onion_d = defer.succeed( (tor_config, tor_port, tor_location) )
|
config_d = defer.succeed( (tor_config, tor_port, tor_location) )
|
||||||
with mock.patch("allmydata.util.tor_provider.create_onion",
|
with mock.patch("allmydata.util.tor_provider.create_config",
|
||||||
return_value=onion_d) as co:
|
return_value=config_d) as co:
|
||||||
rc, out, err = self.successResultOf(
|
rc, out, err = self.successResultOf(
|
||||||
run_cli("create-node", "--listen=tor", basedir))
|
run_cli("create-node", "--listen=tor", basedir))
|
||||||
self.assertEqual(len(co.mock_calls), 1)
|
self.assertEqual(len(co.mock_calls), 1)
|
||||||
@ -345,9 +345,9 @@ class Tor(unittest.TestCase):
|
|||||||
tor_config = {"abc": "def"}
|
tor_config = {"abc": "def"}
|
||||||
tor_port = "ghi"
|
tor_port = "ghi"
|
||||||
tor_location = "jkl"
|
tor_location = "jkl"
|
||||||
onion_d = defer.succeed( (tor_config, tor_port, tor_location) )
|
config_d = defer.succeed( (tor_config, tor_port, tor_location) )
|
||||||
with mock.patch("allmydata.util.tor_provider.create_onion",
|
with mock.patch("allmydata.util.tor_provider.create_config",
|
||||||
return_value=onion_d) as co:
|
return_value=config_d) as co:
|
||||||
rc, out, err = self.successResultOf(
|
rc, out, err = self.successResultOf(
|
||||||
run_cli("create-node", "--listen=tor", "--tor-launch",
|
run_cli("create-node", "--listen=tor", "--tor-launch",
|
||||||
basedir))
|
basedir))
|
||||||
@ -361,9 +361,9 @@ class Tor(unittest.TestCase):
|
|||||||
tor_config = {"abc": "def"}
|
tor_config = {"abc": "def"}
|
||||||
tor_port = "ghi"
|
tor_port = "ghi"
|
||||||
tor_location = "jkl"
|
tor_location = "jkl"
|
||||||
onion_d = defer.succeed( (tor_config, tor_port, tor_location) )
|
config_d = defer.succeed( (tor_config, tor_port, tor_location) )
|
||||||
with mock.patch("allmydata.util.tor_provider.create_onion",
|
with mock.patch("allmydata.util.tor_provider.create_config",
|
||||||
return_value=onion_d) as co:
|
return_value=config_d) as co:
|
||||||
rc, out, err = self.successResultOf(
|
rc, out, err = self.successResultOf(
|
||||||
run_cli("create-node", "--listen=tor", "--tor-control-port=mno",
|
run_cli("create-node", "--listen=tor", "--tor-control-port=mno",
|
||||||
basedir))
|
basedir))
|
||||||
@ -400,7 +400,7 @@ class I2P(unittest.TestCase):
|
|||||||
i2p_port = "ghi"
|
i2p_port = "ghi"
|
||||||
i2p_location = "jkl"
|
i2p_location = "jkl"
|
||||||
dest_d = defer.succeed( (i2p_config, i2p_port, i2p_location) )
|
dest_d = defer.succeed( (i2p_config, i2p_port, i2p_location) )
|
||||||
with mock.patch("allmydata.util.i2p_provider.create_dest",
|
with mock.patch("allmydata.util.i2p_provider.create_config",
|
||||||
return_value=dest_d) as co:
|
return_value=dest_d) as co:
|
||||||
rc, out, err = self.successResultOf(
|
rc, out, err = self.successResultOf(
|
||||||
run_cli("create-node", "--listen=i2p", basedir))
|
run_cli("create-node", "--listen=i2p", basedir))
|
||||||
@ -427,7 +427,7 @@ class I2P(unittest.TestCase):
|
|||||||
i2p_port = "ghi"
|
i2p_port = "ghi"
|
||||||
i2p_location = "jkl"
|
i2p_location = "jkl"
|
||||||
dest_d = defer.succeed( (i2p_config, i2p_port, i2p_location) )
|
dest_d = defer.succeed( (i2p_config, i2p_port, i2p_location) )
|
||||||
with mock.patch("allmydata.util.i2p_provider.create_dest",
|
with mock.patch("allmydata.util.i2p_provider.create_config",
|
||||||
return_value=dest_d) as co:
|
return_value=dest_d) as co:
|
||||||
rc, out, err = self.successResultOf(
|
rc, out, err = self.successResultOf(
|
||||||
run_cli("create-node", "--listen=i2p", "--i2p-sam-port=mno",
|
run_cli("create-node", "--listen=i2p", "--i2p-sam-port=mno",
|
||||||
|
@ -124,7 +124,7 @@ class CreateDest(unittest.TestCase):
|
|||||||
def test_no_txi2p(self):
|
def test_no_txi2p(self):
|
||||||
with mock.patch("allmydata.util.i2p_provider._import_txi2p",
|
with mock.patch("allmydata.util.i2p_provider._import_txi2p",
|
||||||
return_value=None):
|
return_value=None):
|
||||||
d = i2p_provider.create_dest("reactor", "cli_config")
|
d = i2p_provider.create_config("reactor", "cli_config")
|
||||||
f = self.failureResultOf(d)
|
f = self.failureResultOf(d)
|
||||||
self.assertIsInstance(f.value, ValueError)
|
self.assertIsInstance(f.value, ValueError)
|
||||||
self.assertEqual(str(f.value),
|
self.assertEqual(str(f.value),
|
||||||
@ -164,7 +164,7 @@ class CreateDest(unittest.TestCase):
|
|||||||
connect_to_i2p):
|
connect_to_i2p):
|
||||||
with mock.patch("allmydata.util.i2p_provider.clientFromString",
|
with mock.patch("allmydata.util.i2p_provider.clientFromString",
|
||||||
return_value=ep) as cfs:
|
return_value=ep) as cfs:
|
||||||
d = i2p_provider.create_dest(reactor, cli_config)
|
d = i2p_provider.create_config(reactor, cli_config)
|
||||||
tahoe_config_i2p, i2p_port, i2p_location = self.successResultOf(d)
|
tahoe_config_i2p, i2p_port, i2p_location = self.successResultOf(d)
|
||||||
|
|
||||||
connect_to_i2p.assert_called_with(reactor, cli_config, txi2p)
|
connect_to_i2p.assert_called_with(reactor, cli_config, txi2p)
|
||||||
|
@ -152,7 +152,7 @@ class CreateOnion(unittest.TestCase):
|
|||||||
def test_no_txtorcon(self):
|
def test_no_txtorcon(self):
|
||||||
with mock.patch("allmydata.util.tor_provider._import_txtorcon",
|
with mock.patch("allmydata.util.tor_provider._import_txtorcon",
|
||||||
return_value=None):
|
return_value=None):
|
||||||
d = tor_provider.create_onion("reactor", "cli_config")
|
d = tor_provider.create_config("reactor", "cli_config")
|
||||||
f = self.failureResultOf(d)
|
f = self.failureResultOf(d)
|
||||||
self.assertIsInstance(f.value, ValueError)
|
self.assertIsInstance(f.value, ValueError)
|
||||||
self.assertEqual(str(f.value),
|
self.assertEqual(str(f.value),
|
||||||
@ -184,7 +184,7 @@ class CreateOnion(unittest.TestCase):
|
|||||||
launch_tor):
|
launch_tor):
|
||||||
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
||||||
return_value=999999):
|
return_value=999999):
|
||||||
d = tor_provider.create_onion(reactor, cli_config)
|
d = tor_provider.create_config(reactor, cli_config)
|
||||||
tahoe_config_tor, tor_port, tor_location = self.successResultOf(d)
|
tahoe_config_tor, tor_port, tor_location = self.successResultOf(d)
|
||||||
|
|
||||||
launch_tor.assert_called_with(reactor, executable,
|
launch_tor.assert_called_with(reactor, executable,
|
||||||
@ -238,7 +238,7 @@ class CreateOnion(unittest.TestCase):
|
|||||||
connect_to_tor):
|
connect_to_tor):
|
||||||
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
||||||
return_value=999999):
|
return_value=999999):
|
||||||
d = tor_provider.create_onion(reactor, cli_config)
|
d = tor_provider.create_config(reactor, cli_config)
|
||||||
tahoe_config_tor, tor_port, tor_location = self.successResultOf(d)
|
tahoe_config_tor, tor_port, tor_location = self.successResultOf(d)
|
||||||
|
|
||||||
connect_to_tor.assert_called_with(reactor, cli_config, txtorcon)
|
connect_to_tor.assert_called_with(reactor, cli_config, txtorcon)
|
||||||
|
@ -65,7 +65,7 @@ def _connect_to_i2p(reactor, cli_config, txi2p):
|
|||||||
raise ValueError("unable to reach any default I2P SAM port")
|
raise ValueError("unable to reach any default I2P SAM port")
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def create_dest(reactor, cli_config):
|
def create_config(reactor, cli_config):
|
||||||
txi2p = _import_txi2p()
|
txi2p = _import_txi2p()
|
||||||
if not txi2p:
|
if not txi2p:
|
||||||
raise ValueError("Cannot create I2P Destination without txi2p. "
|
raise ValueError("Cannot create I2P Destination without txi2p. "
|
||||||
|
@ -124,7 +124,7 @@ def _connect_to_tor(reactor, cli_config, txtorcon):
|
|||||||
raise ValueError("unable to reach any default Tor control port")
|
raise ValueError("unable to reach any default Tor control port")
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def create_onion(reactor, cli_config):
|
def create_config(reactor, cli_config):
|
||||||
txtorcon = _import_txtorcon()
|
txtorcon = _import_txtorcon()
|
||||||
if not txtorcon:
|
if not txtorcon:
|
||||||
raise ValueError("Cannot create onion without txtorcon. "
|
raise ValueError("Cannot create onion without txtorcon. "
|
||||||
|
Loading…
Reference in New Issue
Block a user