예제 #1
0
def write_node_config(c, config):
    # this is shared between clients and introducers
    c.write("# -*- mode: conf; coding: utf-8 -*-\n")
    c.write("\n")
    c.write("# This file controls the configuration of the Tahoe node that\n")
    c.write("# lives in this directory. It is only read at node startup.\n")
    c.write("# For details about the keys that can be set here, please\n")
    c.write("# read the 'docs/configuration.rst' file that came with your\n")
    c.write("# Tahoe installation.\n")
    c.write("\n\n")

    c.write("[node]\n")
    nickname = argv_to_unicode(config.get("nickname") or "")
    c.write("nickname = %s\n" % (nickname.encode('utf-8'),))

    # TODO: validate webport
    webport = argv_to_unicode(config.get("webport") or "none")
    if webport.lower() == "none":
        webport = ""
    c.write("web.port = %s\n" % (webport.encode('utf-8'),))
    c.write("web.static = public_html\n")
    c.write("#tub.port =\n")
    c.write("#tub.location = \n")
    c.write("#log_gatherer.furl =\n")
    c.write("#timeout.keepalive =\n")
    c.write("#timeout.disconnect =\n")
    c.write("#ssh.port = 8022\n")
    c.write("#ssh.authorized_keys_file = ~/.ssh/authorized_keys\n")
    c.write("\n")
예제 #2
0
def write_node_config(c, config):
    # this is shared between clients and introducers
    c.write("# -*- mode: conf; coding: utf-8 -*-\n")
    c.write("\n")
    c.write("# This file controls the configuration of the Tahoe node that\n")
    c.write("# lives in this directory. It is only read at node startup.\n")
    c.write("# For details about the keys that can be set here, please\n")
    c.write("# read the 'docs/configuration.rst' file that came with your\n")
    c.write("# Tahoe installation.\n")
    c.write("\n\n")

    if config["hide-ip"]:
        c.write("[connections]\n")
        c.write("tcp = tor\n")

    c.write("[node]\n")
    nickname = argv_to_unicode(config.get("nickname") or "")
    c.write("nickname = %s\n" % (nickname.encode("utf-8"),))
    if config["hide-ip"]:
        c.write("reveal-IP-address = false\n")
    else:
        c.write("reveal-IP-address = true\n")

    # TODO: validate webport
    webport = argv_to_unicode(config.get("webport") or "none")
    if webport.lower() == "none":
        webport = ""
    c.write("web.port = %s\n" % (webport.encode("utf-8"),))
    c.write("web.static = public_html\n")

    listeners = config["listen"].split(",")
    if listeners == ["none"]:
        c.write("tub.port = disabled\n")
        c.write("tub.location = disabled\n")
    else:
        if "tor" in listeners:
            raise NotImplementedError("--listen=tor is under development, " "see ticket #2490 for details")
        if "i2p" in listeners:
            raise NotImplementedError("--listen=i2p is under development, " "see ticket #2490 for details")
        if "tcp" in listeners:
            if config["port"]:  # --port/--location are a pair
                c.write("tub.port = %s\n" % config["port"].encode("utf-8"))
                c.write("tub.location = %s\n" % config["location"].encode("utf-8"))
            else:
                assert "hostname" in config
                hostname = config["hostname"]
                new_port = iputil.allocate_tcp_port()
                c.write("tub.port = tcp:%s\n" % new_port)
                c.write("tub.location = tcp:%s:%s\n" % (hostname.encode("utf-8"), new_port))

    c.write("#log_gatherer.furl =\n")
    c.write("#timeout.keepalive =\n")
    c.write("#timeout.disconnect =\n")
    c.write("#ssh.port = 8022\n")
    c.write("#ssh.authorized_keys_file = ~/.ssh/authorized_keys\n")
    c.write("\n")
예제 #3
0
 def parseArgs(self, alias, nickname=None):
     BasedirOptions.parseArgs(self)
     alias = argv_to_unicode(alias)
     if not alias.endswith(u':'):
         raise usage.UsageError("An alias must end with a ':' character.")
     self.alias = alias[:-1]
     self.nickname = argv_to_unicode(nickname)
     node_url_file = os.path.join(self['node-directory'], u"node.url")
     self['node-url'] = open(node_url_file, "r").read().strip()
     aliases = get_aliases(self['node-directory'])
     self.aliases = aliases
예제 #4
0
파일: cli.py 프로젝트: drewp/tahoe-lafs
    def parseArgs(self, arg1=None, arg2=None):
        # see Examples below

        if arg1 is not None and arg2 is not None:
            self.from_file = argv_to_unicode(arg1)
            self.to_file =  argv_to_unicode(arg2)
        elif arg1 is not None and arg2 is None:
            self.from_file = argv_to_unicode(arg1) # might be "-"
            self.to_file = None
        else:
            self.from_file = None
            self.to_file = None
        if self.from_file == u"-":
            self.from_file = None
예제 #5
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
    def parseArgs(self, arg1, arg2=None):
        # tahoe get FOO |less            # write to stdout
        # tahoe get tahoe:FOO |less      # same
        # tahoe get FOO bar              # write to local file
        # tahoe get tahoe:FOO bar        # same

        self.from_file = argv_to_unicode(arg1)

        if arg2:
            self.to_file = argv_to_unicode(arg2)
        else:
            self.to_file = None

        if self.to_file == "-":
            self.to_file = None
예제 #6
0
    def parseArgs(self, alias, nickname=None, local_dir=None):
        BasedirOptions.parseArgs(self)
        alias = argv_to_unicode(alias)
        if not alias.endswith(u':'):
            raise usage.UsageError("An alias must end with a ':' character.")
        self.alias = alias[:-1]
        self.nickname = None if nickname is None else argv_to_unicode(nickname)

        # Expand the path relative to the current directory of the CLI command, not the node.
        self.local_dir = None if local_dir is None else argv_to_abspath(local_dir, long_path=False)

        if self.nickname and not self.local_dir:
            raise usage.UsageError("If NICKNAME is specified then LOCAL_DIR must also be specified.")
        node_url_file = os.path.join(self['node-directory'], u"node.url")
        self['node-url'] = fileutil.read(node_url_file).strip()
예제 #7
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
 def opt_exclude(self, pattern):
     """Ignore files matching a glob pattern. You may give multiple
     '--exclude' options."""
     g = argv_to_unicode(pattern).strip()
     if g:
         exclude = self["exclude"]
         exclude.add(g)
예제 #8
0
파일: cli.py 프로젝트: jsgf/tahoe-lafs
    def parseArgs(self, where=""):
        self.where = argv_to_unicode(where)

        if self['mutable-type']:
            if self['mutable-type'].lower() not in ("sdmf", "mdmf"):
                raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
            self['mutable-type'] = self['mutable-type'].lower()
예제 #9
0
    def test_argv_to_unicode(self, mock):
        if 'argv' not in dir(self):
            return

        mock.encoding = self.output_encoding
        argu = lumiere_nfc
        argv = self.argv
        _reload()
        self.failUnlessReallyEqual(argv_to_unicode(argv), argu)
예제 #10
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
    def parseArgs(self, arg1=None, arg2=None):
        # see Examples below

        if arg1 is not None and arg2 is not None:
            self.from_file = argv_to_unicode(arg1)
            self.to_file = argv_to_unicode(arg2)
        elif arg1 is not None and arg2 is None:
            self.from_file = argv_to_unicode(arg1)  # might be "-"
            self.to_file = None
        else:
            self.from_file = None
            self.to_file = None
        if self.from_file == u"-":
            self.from_file = None

        if self["format"]:
            if self["format"].upper() not in ("SDMF", "MDMF", "CHK"):
                raise usage.UsageError("%s is an invalid format" % self["format"])
예제 #11
0
    def parseArgs(self, arg1, arg2=None):
        # tahoe get FOO |less            # write to stdout
        # tahoe get tahoe:FOO |less      # same
        # tahoe get FOO bar              # write to local file
        # tahoe get tahoe:FOO bar        # same

        if arg2 == "-":
            arg2 = None

        self.from_file = argv_to_unicode(arg1)
        self.to_file   = None if arg2 is None else argv_to_abspath(arg2)
예제 #12
0
    def parseArgs(self, arg1=None, arg2=None):
        # see Examples below

        if arg1 == "-":
            arg1 = None

        self.from_file = None if arg1 is None else argv_to_abspath(arg1)
        self.to_file   = None if arg2 is None else argv_to_unicode(arg2)

        if self['format']:
            if self['format'].upper() not in ("SDMF", "MDMF", "CHK"):
                raise usage.UsageError("%s is an invalid format" % self['format'])
예제 #13
0
    def test_argv_to_unicode(self):
        if 'argv' not in dir(self):
            return

        mock_stdout = MockStdout()
        mock_stdout.encoding = self.io_encoding
        self.patch(sys, 'stdout', mock_stdout)

        argu = lumiere_nfc
        argv = self.argv
        _reload()
        self.failUnlessReallyEqual(argv_to_unicode(argv), argu)
예제 #14
0
    def parseArgs(self, invite_code, local_dir):
        BasedirOptions.parseArgs(self)

        try:
            if int(self['poll-interval']) <= 0:
                raise ValueError("should be positive")
        except ValueError:
            raise usage.UsageError(
                "--poll-interval must be a positive integer"
            )
        # Expand the path relative to the current directory of the CLI command, not the node.
        self.local_dir = None if local_dir is None else argv_to_abspath(local_dir, long_path=False)
        self.invite_code = to_str(argv_to_unicode(invite_code))
예제 #15
0
파일: cli.py 프로젝트: jsgf/tahoe-lafs
    def parseArgs(self, arg1=None, arg2=None):
        # see Examples below

        if arg1 is not None and arg2 is not None:
            self.from_file = argv_to_unicode(arg1)
            self.to_file =  argv_to_unicode(arg2)
        elif arg1 is not None and arg2 is None:
            self.from_file = argv_to_unicode(arg1) # might be "-"
            self.to_file = None
        else:
            self.from_file = None
            self.to_file = None
        if self.from_file == u"-":
            self.from_file = None

        if self['mutable-type']:
            if self['mutable-type'].lower() not in ("sdmf", "mdmf"):
                raise usage.UsageError("%s is an invalid format" % self['mutable-type'])
            self['mutable-type'] = self['mutable-type'].lower()

        if self['mutable-type']:
            self['mutable'] = True
예제 #16
0
 def parseArgs(self, localdir, topath):
     self.from_dir = argv_to_abspath(localdir)
     self.to_dir = argv_to_unicode(topath)
예제 #17
0
 def parseArgs(self, frompath, topath):
     self.from_file = argv_to_unicode(frompath)
     self.to_file = argv_to_unicode(topath)
예제 #18
0
 def parseArgs(self, *args):
     if len(args) < 2:
         raise usage.UsageError("cp requires at least two arguments")
     self.sources = [argv_to_unicode(arg) for arg in args[:-1]]
     self.destination = argv_to_unicode(args[-1])
예제 #19
0
 def parseArgs(self, alias, cap):
     self.alias = argv_to_unicode(alias)
     if self.alias.endswith(u':'):
         self.alias = self.alias[:-1]
     self.cap = cap
예제 #20
0
def write_node_config(c, config):
    # this is shared between clients and introducers
    c.write("# -*- mode: conf; coding: utf-8 -*-\n")
    c.write("\n")
    c.write("# This file controls the configuration of the Tahoe node that\n")
    c.write("# lives in this directory. It is only read at node startup.\n")
    c.write("# For details about the keys that can be set here, please\n")
    c.write("# read the 'docs/configuration.rst' file that came with your\n")
    c.write("# Tahoe installation.\n")
    c.write("\n\n")

    if config["hide-ip"]:
        c.write("[connections]\n")
        c.write("tcp = tor\n")
        c.write("\n")

    c.write("[node]\n")
    nickname = argv_to_unicode(config.get("nickname") or "")
    c.write("nickname = %s\n" % (nickname.encode('utf-8'),))
    if config["hide-ip"]:
        c.write("reveal-IP-address = false\n")
    else:
        c.write("reveal-IP-address = true\n")

    # TODO: validate webport
    webport = argv_to_unicode(config.get("webport") or "none")
    if webport.lower() == "none":
        webport = ""
    c.write("web.port = %s\n" % (webport.encode('utf-8'),))
    c.write("web.static = public_html\n")

    listeners = config['listen'].split(",")

    tor_config = {}
    i2p_config = {}
    tub_ports = []
    tub_locations = []
    if listeners == ["none"]:
        c.write("tub.port = disabled\n")
        c.write("tub.location = disabled\n")
    else:
        if "tor" in listeners:
            (tor_config, tor_port, tor_location) = \
                         yield tor_provider.create_onion(reactor, config)
            tub_ports.append(tor_port)
            tub_locations.append(tor_location)
        if "i2p" in listeners:
            (i2p_config, i2p_port, i2p_location) = \
                         yield i2p_provider.create_dest(reactor, config)
            tub_ports.append(i2p_port)
            tub_locations.append(i2p_location)
        if "tcp" in listeners:
            if config["port"]: # --port/--location are a pair
                tub_ports.append(config["port"].encode('utf-8'))
                tub_locations.append(config["location"].encode('utf-8'))
            else:
                assert "hostname" in config
                hostname = config["hostname"]
                new_port = iputil.allocate_tcp_port()
                tub_ports.append("tcp:%s" % new_port)
                tub_locations.append("tcp:%s:%s" % (hostname.encode('utf-8'),
                                                    new_port))
        c.write("tub.port = %s\n" % ",".join(tub_ports))
        c.write("tub.location = %s\n" % ",".join(tub_locations))
    c.write("\n")

    c.write("#log_gatherer.furl =\n")
    c.write("#timeout.keepalive =\n")
    c.write("#timeout.disconnect =\n")
    c.write("#ssh.port = 8022\n")
    c.write("#ssh.authorized_keys_file = ~/.ssh/authorized_keys\n")
    c.write("\n")

    if tor_config:
        c.write("[tor]\n")
        for key, value in tor_config.items():
            c.write("%s = %s\n" % (key, value))
        c.write("\n")

    if i2p_config:
        c.write("[i2p]\n")
        for key, value in i2p_config.items():
            c.write("%s = %s\n" % (key, value))
        c.write("\n")
예제 #21
0
파일: cli.py 프로젝트: ducki2p/tahoe-lafs
 def parseArgs(self, alias):
     self.alias = argv_to_unicode(alias)
예제 #22
0
def write_node_config(c, config):
    # this is shared between clients and introducers
    c.write("# -*- mode: conf; coding: utf-8 -*-\n")
    c.write("\n")
    c.write("# This file controls the configuration of the Tahoe node that\n")
    c.write("# lives in this directory. It is only read at node startup.\n")
    c.write("# For details about the keys that can be set here, please\n")
    c.write("# read the 'docs/configuration.rst' file that came with your\n")
    c.write("# Tahoe installation.\n")
    c.write("\n\n")

    if config["hide-ip"]:
        c.write("[connections]\n")
        if tor_provider._import_txtorcon():
            c.write("tcp = tor\n")
        else:
            c.write("tcp = disabled\n")
        c.write("\n")

    c.write("[node]\n")
    nickname = argv_to_unicode(config.get("nickname") or "")
    c.write("nickname = %s\n" % (nickname.encode('utf-8'), ))
    if config["hide-ip"]:
        c.write("reveal-IP-address = false\n")
    else:
        c.write("reveal-IP-address = true\n")

    # TODO: validate webport
    webport = argv_to_unicode(config.get("webport") or "none")
    if webport.lower() == "none":
        webport = ""
    c.write("web.port = %s\n" % (webport.encode('utf-8'), ))
    c.write("web.static = public_html\n")

    listeners = config['listen'].split(",")

    tor_config = {}
    i2p_config = {}
    tub_ports = []
    tub_locations = []
    if listeners == ["none"]:
        c.write("tub.port = disabled\n")
        c.write("tub.location = disabled\n")
    else:
        if "tor" in listeners:
            (tor_config, tor_port, tor_location) = \
                         yield tor_provider.create_config(reactor, config)
            tub_ports.append(tor_port)
            tub_locations.append(tor_location)
        if "i2p" in listeners:
            (i2p_config, i2p_port, i2p_location) = \
                         yield i2p_provider.create_config(reactor, config)
            tub_ports.append(i2p_port)
            tub_locations.append(i2p_location)
        if "tcp" in listeners:
            if config["port"]:  # --port/--location are a pair
                tub_ports.append(config["port"].encode('utf-8'))
                tub_locations.append(config["location"].encode('utf-8'))
            else:
                assert "hostname" in config
                hostname = config["hostname"]
                new_port = iputil.allocate_tcp_port()
                tub_ports.append("tcp:%s" % new_port)
                tub_locations.append("tcp:%s:%s" %
                                     (hostname.encode('utf-8'), new_port))
        c.write("tub.port = %s\n" % ",".join(tub_ports))
        c.write("tub.location = %s\n" % ",".join(tub_locations))
    c.write("\n")

    c.write("#log_gatherer.furl =\n")
    c.write("#timeout.keepalive =\n")
    c.write("#timeout.disconnect =\n")
    c.write("#ssh.port = 8022\n")
    c.write("#ssh.authorized_keys_file = ~/.ssh/authorized_keys\n")
    c.write("\n")

    if tor_config:
        c.write("[tor]\n")
        for key, value in tor_config.items():
            c.write("%s = %s\n" % (key, value))
        c.write("\n")

    if i2p_config:
        c.write("[i2p]\n")
        for key, value in i2p_config.items():
            c.write("%s = %s\n" % (key, value))
        c.write("\n")
예제 #23
0
 def parseArgs(self, where=''):
     self.where = argv_to_unicode(where)
예제 #24
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
 def parseArgs(self, frompath, topath):
     self.from_file = argv_to_unicode(frompath)
     self.to_file = argv_to_unicode(topath)
예제 #25
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
 def parseArgs(self, *args):
     if len(args) < 2:
         raise usage.UsageError("cp requires at least two arguments")
     self.sources = map(argv_to_unicode, args[:-1])
     self.destination = argv_to_unicode(args[-1])
예제 #26
0
 def parseArgs(self, nickname):
     super(InviteOptions, self).parseArgs()
     self.nickname = argv_to_unicode(nickname)
예제 #27
0
 def parseArgs(self, alias, cap):
     self.alias = argv_to_unicode(alias)
     if self.alias.endswith(u':'):
         self.alias = self.alias[:-1]
     self.cap = cap
예제 #28
0
파일: cli.py 프로젝트: ducki2p/tahoe-lafs
 def parseArgs(self, alias, cap):
     self.alias = argv_to_unicode(alias)
     self.cap = cap
예제 #29
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
 def parseArgs(self, where=""):
     self.where = argv_to_unicode(where)
예제 #30
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
    def parseArgs(self, where=""):
        self.where = argv_to_unicode(where)

        if self["format"]:
            if self["format"].upper() not in ("SDMF", "MDMF"):
                raise usage.UsageError("%s is an invalid format" % self["format"])
예제 #31
0
    def parseArgs(self, invite_code, local_dir):
        BasedirOptions.parseArgs(self)

        # Expand the path relative to the current directory of the CLI command, not the node.
        self.local_dir = None if local_dir is None else argv_to_abspath(local_dir, long_path=False)
        self.invite_code = to_str(argv_to_unicode(invite_code))
예제 #32
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
 def parseArgs(self, alias):
     self.alias = argv_to_unicode(alias)
     if self.alias.endswith(u":"):
         self.alias = self.alias[:-1]
예제 #33
0
파일: cli.py 프로젝트: kytvi2p/tahoe-lafs
 def parseArgs(self, localdir, topath):
     self.from_dir = argv_to_unicode(localdir)
     self.to_dir = argv_to_unicode(topath)
예제 #34
0
파일: cli.py 프로젝트: AMJ-dev/tahoe-lafs
    def parseArgs(self, where=""):
        self.where = argv_to_unicode(where)

        if self['format']:
            if self['format'].upper() not in ("SDMF", "MDMF"):
                raise usage.UsageError("%s is an invalid format" % self['format'])