def default_config(): return dict( autologin=not is_portable(), upload_limit=0, download_limit=0, fs_events_processing_delay=1, fs_events_processing_period=1, fs_folder_timeout=2, sync_directory=FilePath(get_data_dir()), conflict_file_suffix='Conflicted copy from {}'.format( get_device_name()), node_hash=sha512(uuid4().bytes).hexdigest(), user_hash=None, send_statistics=True, license_type=UNKNOWN_LICENSE, # unknown licence by default lang=None, # System language user_email=None, last_user_email=None, user_password_hash=None, http_downloader_timeout=3, excluded_dirs=(), # List of directories excluded from sync max_log_size=100, # Max log file size Mb download_backups=False, remote_events_max_total=5000, max_remote_events_per_request=100, max_relpath_len=3096, sync_dir_size=0, copies_logging=True, excluded_dirs_applied=(), # List of excluded dirs, applied in DB host=REGULAR_URI, tracking_address='https://tracking.pvtbox.net:443/1/', smart_sync=True, )
def _login(self, login, password, user_hash): data = { 'node_devicetype': 'desktop', 'node_ostype': get_platform(), 'node_osname': self._os_name, 'node_name': get_device_name(), 'user_email': login, 'user_password': password, 'user_hash': user_hash, 'is_server': self._is_server, } # Signalize login attempt started (for statistics) if self._tracker: self._tracker.session_login_start() logged_in = False _res = self.create_request(action='login', data=data) if _res is None: if self._tracker: self._tracker.session_login_failed("response is None") return logged_in, _res if 'user_hash' not in _res: if self._tracker: self._tracker.session_login_failed("missing user_hash") logger.error("Server not returned user_hash") return logged_in, _res # Registered successfully if "success" in _res['result']: logged_in = True self.cfg.set_settings({'user_hash': _res['user_hash']}) logger.info("Logged in successfully") return logged_in, _res
def __init__(self, disk_usage, node_status, node_substatus): """ Constructor """ super(TableModel, self).__init__() self._data = [] self._node_id_vs_row_number = {} self._icons = {} # Initialize icons for icon_id, icon_path in list(self._icon_paths.items()): if not icon_path: continue self._icons[icon_id] = QIcon(icon_path) # set font for arrow symbols font_id = QFontDatabase.addApplicationFont(":/fonts/symbol-signs.otf") font_family = QFontDatabase.applicationFontFamilies(font_id)[0] self._arrow_font = QFont(font_family, QFont().pointSize()+5) # Add the node itself node_ostype = get_platform() node_osname, is_server = get_os_name_and_is_server() # show "Downloading share" instead of "Syncing" if share is downlosded status = 30 if node_status == 3 and node_substatus == SUBSTATUS_SHARE \ else node_status self_info = { 'id': 'itself', 'node_ostype': node_ostype, 'node_osname': node_osname, 'node_devicetype': 'desktop', 'node_name': get_device_name(), 'is_online': node_status not in self.OFFLINE_STATUSES, 'is_itself': True, 'disk_usage': disk_usage, 'download_speed': 0., 'node_status': status, 'upload_speed': 0., } QTimer.singleShot(10, lambda: self._add_row(self_info))
def read_config_file(self): need_sync = False with open(self.config_file_name, 'rb') as f: data = f.read() try: decrypted_data = xor_with_key(data) config = loads(decrypted_data) secret = UUID(int=158790876260364472748646807733425668096 + getnode()).bytes if is_portable(): config['user_hash'] = None config['user_password_hash'] = None config['sync_directory'] = FilePath(get_data_dir()) config['conflict_file_suffix'] = 'Conflicted copy from {}'\ .format(get_device_name()) else: try: if config.get('user_hash', None): config['user_hash'] = xor_with_key( bytes.fromhex(config['user_hash']), secret).decode() except Exception as e: logger.debug("Error decoding user hash: %s", e) config["user_hash"] = None try: if config.get('user_password_hash', None): config['user_password_hash'] = xor_with_key( bytes.fromhex(config['user_password_hash']), secret).decode() except Exception as e: logger.debug("Error decoding user password hash: %s", e) config["user_password_hash"] = None except ValueError as e: logger.warning("Error: %s", e) config = loads(data) config["user_hash"] = None config["user_password_hash"] = None need_sync = True return config, need_sync
def _signup(self, fullname, email, password): if self._tracker: self._tracker.session_signup_start() data = { 'node_devicetype': 'desktop', 'node_ostype': get_platform(), 'node_osname': self._os_name, 'node_name': get_device_name(), 'fullname': fullname, 'user_email': email, 'user_password': password, } signed = False _res = self.create_request(action='signup', data=data) if _res and "success" in _res['result'] and 'user_hash' in _res: self.cfg.set_settings({'user_hash': _res['user_hash']}) signed = True logger.info("Registered successfully") return signed, _res