def get_access_info(self): ''' Build up a list of url's that sabnzbd can be accessed from ''' # Access_url is used to provide the user a link to sabnzbd depending on the host access_uri = 'localhost' cherryhost = cfg.cherryhost() if cherryhost == '0.0.0.0': import socket host = socket.gethostname() socks = [host] # Grab a list of all ips for the hostname try: addresses = socket.getaddrinfo(host, None) except: addresses = [] for addr in addresses: address = addr[4][0] # Filter out ipv6 addresses (should not be allowed) if ':' not in address and address not in socks: socks.append(address) if cherrypy.request.headers.has_key('host'): host = cherrypy.request.headers['host'] host = host.rsplit(':')[0] access_uri = host socks.insert(0, host) else: socks.insert(0, 'localhost') elif cherryhost == '::': import socket host = socket.gethostname() socks = [host] # Grab a list of all ips for the hostname addresses = socket.getaddrinfo(host, None) for addr in addresses: address = addr[4][0] # Only ipv6 addresses will work if ':' in address: address = '[%s]' % address if address not in socks: socks.append(address) if cherrypy.request.headers.has_key('host'): host = cherrypy.request.headers['host'] host = host.rsplit(':')[0] access_uri = host socks.insert(0, host) else: socks.insert(0, 'localhost') elif not cherryhost: import socket socks = [socket.gethostname()] access_uri = socket.gethostname() else: socks = [cherryhost] access_uri = cherryhost urls = [] for sock in socks: if sock: if cfg.enable_https(): url = 'https://%s:%s/sabnzbd/' % (sock, cfg.https_port()) else: url = 'http://%s:%s/sabnzbd/' % (sock, cfg.cherryport()) urls.append(url) if cfg.enable_https(): access_url = 'https://%s:%s/sabnzbd/' % (access_uri, cfg.https_port()) else: access_url = 'http://%s:%s/sabnzbd/' % (access_uri, cfg.cherryport()) return access_url, urls