from allmydata.control import ControlServer
from allmydata.introducer.client import IntroducerClient
from allmydata.util import hashutil, base32, pollmixin, log, keyutil, idlib
-from allmydata.util.encodingutil import get_filesystem_encoding
+from allmydata.util.encodingutil import get_filesystem_encoding, \
+ from_utf8_or_none
+from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.util.abbreviate import parse_abbreviated_size
from allmydata.util.time_format import parse_duration, parse_date
from allmydata.stats import StatsProvider
}
def __init__(self, basedir="."):
+ #print "Client.__init__(%r)" % (basedir,)
node.Node.__init__(self, basedir)
+ self.connected_enough_d = defer.Deferred()
self.started_timestamp = time.time()
self.logSource="Client"
self.encoding_params = self.DEFAULT_ENCODING_PARAMETERS.copy()
# ControlServer and Helper are attached after Tub startup
self.init_ftp_server()
self.init_sftp_server()
- self.init_drop_uploader()
+ self.init_magic_folder()
# If the node sees an exit_trigger file, it will poll every second to see
# whether the file still exists, and what its mtime is. If the file does not
def init_client_storage_broker(self):
# create a StorageFarmBroker object, for use by Uploader/Downloader
# (and everybody else who wants to use storage servers)
- sb = storage_client.StorageFarmBroker(self.tub, permute_peers=True)
+ ps = self.get_config("client", "peers.preferred", "").split(",")
+ preferred_peers = tuple([p.strip() for p in ps if p != ""])
+
+ connection_threshold = min(self.encoding_params["k"],
+ self.encoding_params["happy"] + 1)
+
+ sb = storage_client.StorageFarmBroker(self.tub, True, connection_threshold,
+ self.connected_enough_d, preferred_peers=preferred_peers)
self.storage_broker = sb
# load static server specifications from tahoe.cfg, if any.
from allmydata.webish import WebishServer
nodeurl_path = os.path.join(self.basedir, "node.url")
- staticdir = self.get_config("node", "web.static", "public_html")
- staticdir = os.path.expanduser(staticdir)
+ staticdir_config = self.get_config("node", "web.static", "public_html").decode("utf-8")
+ staticdir = abspath_expanduser_unicode(staticdir_config, base=self.basedir)
ws = WebishServer(self, webport, nodeurl_path, staticdir)
self.add_service(ws)
def init_ftp_server(self):
if self.get_config("ftpd", "enabled", False, boolean=True):
- accountfile = self.get_config("ftpd", "accounts.file", None)
+ accountfile = from_utf8_or_none(
+ self.get_config("ftpd", "accounts.file", None))
+ if accountfile:
+ accountfile = abspath_expanduser_unicode(accountfile, base=self.basedir)
accounturl = self.get_config("ftpd", "accounts.url", None)
ftp_portstr = self.get_config("ftpd", "port", "8021")
def init_sftp_server(self):
if self.get_config("sftpd", "enabled", False, boolean=True):
- accountfile = self.get_config("sftpd", "accounts.file", None)
+ accountfile = from_utf8_or_none(
+ self.get_config("sftpd", "accounts.file", None))
+ if accountfile:
+ accountfile = abspath_expanduser_unicode(accountfile, base=self.basedir)
accounturl = self.get_config("sftpd", "accounts.url", None)
sftp_portstr = self.get_config("sftpd", "port", "8022")
- pubkey_file = self.get_config("sftpd", "host_pubkey_file")
- privkey_file = self.get_config("sftpd", "host_privkey_file")
+ pubkey_file = from_utf8_or_none(self.get_config("sftpd", "host_pubkey_file"))
+ privkey_file = from_utf8_or_none(self.get_config("sftpd", "host_privkey_file"))
from allmydata.frontends import sftpd
s = sftpd.SFTPServer(self, accountfile, accounturl,
sftp_portstr, pubkey_file, privkey_file)
s.setServiceParent(self)
- def init_drop_uploader(self):
+ def init_magic_folder(self):
+ #print "init_magic_folder"
if self.get_config("drop_upload", "enabled", False, boolean=True):
- if self.get_config("drop_upload", "upload.dircap", None):
- raise OldConfigOptionError("The [drop_upload]upload.dircap option is no longer supported; please "
- "put the cap in a 'private/drop_upload_dircap' file, and delete this option.")
-
- upload_dircap = self.get_or_create_private_config("drop_upload_dircap")
- local_dir_utf8 = self.get_config("drop_upload", "local.directory")
-
- try:
- from allmydata.frontends import drop_upload
- s = drop_upload.DropUploader(self, upload_dircap, local_dir_utf8)
- s.setServiceParent(self)
- s.startService()
- except Exception, e:
- self.log("couldn't start drop-uploader: %r", args=(e,))
+ raise OldConfigOptionError("The [drop_upload] section must be renamed to [magic_folder].\n"
+ "See docs/frontends/magic-folder.rst for more information.")
+
+ if self.get_config("magic_folder", "enabled", False, boolean=True):
+ #print "magic folder enabled"
+ upload_dircap = self.get_private_config("magic_folder_dircap")
+ collective_dircap = self.get_private_config("collective_dircap")
+
+ local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
+ local_dir = abspath_expanduser_unicode(local_dir_config, base=self.basedir)
+
+ dbfile = os.path.join(self.basedir, "private", "magicfolderdb.sqlite")
+ dbfile = abspath_expanduser_unicode(dbfile)
+
+ from allmydata.frontends import magic_folder
+ umask = self.get_config("magic_folder", "download.umask", 0077)
+ s = magic_folder.MagicFolder(self, upload_dircap, collective_dircap, local_dir, dbfile, umask)
+ s.setServiceParent(self)
+ s.startService()
+
+ # start processing the upload queue when we've connected to enough servers
+ self.connected_enough_d.addCallback(lambda ign: s.ready())
def _check_exit_trigger(self, exit_trigger_file):
if os.path.exists(exit_trigger_file):