def _get_auth(self): self.auth = None if self.host: try: if self.host and self.host.startswith('scgi:'): self.username = self.password = None self.auth = RTorrent(self.host, self.username, self.password, True) except (AssertionError, xmlrpclib.ProtocolError) as e: pass return self.auth
def _get_auth(self): self.auth = None if self.auth is not None: return self.auth if not self.host: return tp_kwargs = {} if sickbeard.TORRENT_AUTH_TYPE is not 'none': tp_kwargs['authtype'] = sickbeard.TORRENT_AUTH_TYPE if not sickbeard.TORRENT_VERIFY_CERT: tp_kwargs['check_ssl_cert'] = False if self.username and self.password: self.auth = RTorrent(self.host, self.username, self.password, True, tp_kwargs=tp_kwargs) else: self.auth = RTorrent(self.host, None, None, True) return self.auth
def connect(self, host, username, password, auth): if self.conn is not None: return self.conn if not host: return False url = helpers.cleanHost(host, protocol = True, ssl = mylar.RTORRENT_SSL) # Automatically add '+https' to 'httprpc' protocol if SSL is enabled if mylar.RTORRENT_SSL and url.startswith('httprpc://'): url = url.replace('httprpc://', 'httprpc+https://') parsed = urlparse(url) # rpc_url is only used on http/https scgi pass-through if parsed.scheme in ['http', 'https']: url += mylar.RTORRENT_RPC_URL logger.info(url) if username and password: try: self.conn = RTorrent( url,(auth, username, password), verify_server=True, verify_ssl=self.getVerifySsl() ) except: return False else: try: self.conn = RTorrent(host) except: return False return self.conn
def _get_auth(self): auth = None if self.auth is not None: return self.auth if not self.host: return if self.username and self.password: self.auth = Rtorrent(self.host, self.username, self.password) else: self.auth = RTorrent(self.host, None, None, True) return self.auth
def connect(self, host, username, password, auth, verify, rpc_url, ca_bundle, test=False): if self.conn is not None: return self.conn if not host: return {'status': False, 'error': 'No host specified'} url = host if host.startswith('https:'): ssl = True else: if not host.startswith('http://'): url = 'http://' + url ssl = False #add on the slash .. if not url.endswith('/'): url += '/' url = helpers.cleanHost(host, protocol=True, ssl=ssl) # Automatically add '+https' to 'httprpc' protocol if SSL is enabled if ssl is True and url.startswith('httprpc://'): url = url.replace('httprpc://', 'httprpc+https://') if ssl is False and not url.startswith('http://'): url = 'http://' + url parsed = urlparse(url) # rpc_url is only used on http/https scgi pass-through if parsed.scheme in ['http', 'https'] and rpc_url is not None: url += rpc_url logger.fdebug(url) if username and password: try: # logger.debug('SECURE: username and password') if parsed.scheme == 'https': newurl = url.replace( 'https://', 'https://%s:%s@' % (username, password)) elif parsed.scheme == 'http': newurl = url.replace( 'http://', 'http://%s:%s@' % (username, password)) else: newurl = url logger.fdebug('NEWURL: %s' % newurl.replace(password, '[REDACTED]')) authinfo = tuple(([auth, username, password])) self.conn = RTorrent( url, authinfo, verify_server=True, verify_ssl=False #self.getVerifySsl(verify, ca_bundle) ) except Exception as err: logger.error( 'Make sure you have the right protocol specified for the rtorrent host. Failed to connect to rTorrent - error: %s.' % err) return {'status': False, 'error': err} else: logger.fdebug('NO username %s / NO password %s' % (username, password)) try: self.conn = RTorrent(url, (auth, username, password), verify_server=True, verify_ssl=self.getVerifySsl( verify, ca_bundle)) except Exception as err: logger.error('Failed to connect to rTorrent: %s' % err) return {'status': False, 'error': err} if test is True: return {'status': True, 'version': self.conn.get_client_version()} else: return self.conn