2015-01-12 02:03:45 +01:00
|
|
|
import json, logging, time, re, os
|
|
|
|
import gevent
|
version 0.2.8, Namecoin domains using internal resolver site, --disable_zeromq option to skip backward compatiblity layer and save some memory, connectionserver firstchar error fixes, missing unpacker crash fix, sitemanager class to allow extensions, add loaded plugin list to websocket api, faster content publishing, mark updating file as bad, remove coppersurfer tracker add eddie4, internal server error with error displaying, allow site domains in UiRequest, better progress bar, wait for siteinfo before before using localstorage, csslater hide only if opacity is 0
2015-03-30 23:44:29 +02:00
|
|
|
from Plugin import PluginManager
|
2015-01-12 02:03:45 +01:00
|
|
|
|
|
|
|
TRACKERS = [
|
|
|
|
("udp", "open.demonii.com", 1337),
|
version 0.2.0, new lib for bitcoin ecc, dont display or track notify errors, dont reload again within 1 sec, null peer ip fix, signingmoved to ContentManager, content.json include support, content.json multisig ready, content.json proper bitcoincore compatible signing, content.json include permissions, multithreaded publish, publish timeout 60s, no exception on invalid bitcoin address, testcase for new lib, bip32 based persite privatekey generation, multiuser ready, simple json database query command, websocket api fileGet, wrapper loading title stuck bugfix
2015-02-09 02:09:02 +01:00
|
|
|
("udp", "sugoi.pomf.se", 2710),
|
version 0.2.8, Namecoin domains using internal resolver site, --disable_zeromq option to skip backward compatiblity layer and save some memory, connectionserver firstchar error fixes, missing unpacker crash fix, sitemanager class to allow extensions, add loaded plugin list to websocket api, faster content publishing, mark updating file as bad, remove coppersurfer tracker add eddie4, internal server error with error displaying, allow site domains in UiRequest, better progress bar, wait for siteinfo before before using localstorage, csslater hide only if opacity is 0
2015-03-30 23:44:29 +02:00
|
|
|
#("udp", "tracker.coppersurfer.tk", 80),
|
2015-01-12 02:03:45 +01:00
|
|
|
("udp", "tracker.leechers-paradise.org", 6969),
|
2015-01-30 18:46:48 +01:00
|
|
|
("udp", "9.rarbg.com", 2710),
|
version 0.2.8, Namecoin domains using internal resolver site, --disable_zeromq option to skip backward compatiblity layer and save some memory, connectionserver firstchar error fixes, missing unpacker crash fix, sitemanager class to allow extensions, add loaded plugin list to websocket api, faster content publishing, mark updating file as bad, remove coppersurfer tracker add eddie4, internal server error with error displaying, allow site domains in UiRequest, better progress bar, wait for siteinfo before before using localstorage, csslater hide only if opacity is 0
2015-03-30 23:44:29 +02:00
|
|
|
("udp", "www.eddie4.nl", 6969),
|
|
|
|
#("udp", "trackr.sytes.net", 80), #Backup trackers
|
version 0.2.0, new lib for bitcoin ecc, dont display or track notify errors, dont reload again within 1 sec, null peer ip fix, signingmoved to ContentManager, content.json include support, content.json multisig ready, content.json proper bitcoincore compatible signing, content.json include permissions, multithreaded publish, publish timeout 60s, no exception on invalid bitcoin address, testcase for new lib, bip32 based persite privatekey generation, multiuser ready, simple json database query command, websocket api fileGet, wrapper loading title stuck bugfix
2015-02-09 02:09:02 +01:00
|
|
|
#("udp", "tracker4.piratux.com", 6969)
|
2015-01-12 02:03:45 +01:00
|
|
|
]
|
|
|
|
|
version 0.2.8, Namecoin domains using internal resolver site, --disable_zeromq option to skip backward compatiblity layer and save some memory, connectionserver firstchar error fixes, missing unpacker crash fix, sitemanager class to allow extensions, add loaded plugin list to websocket api, faster content publishing, mark updating file as bad, remove coppersurfer tracker add eddie4, internal server error with error displaying, allow site domains in UiRequest, better progress bar, wait for siteinfo before before using localstorage, csslater hide only if opacity is 0
2015-03-30 23:44:29 +02:00
|
|
|
|
|
|
|
@PluginManager.acceptPlugins
|
|
|
|
class SiteManager(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.sites = None
|
|
|
|
|
|
|
|
# Load all sites from data/sites.json
|
|
|
|
def load(self):
|
|
|
|
from Site import Site
|
|
|
|
if not self.sites: self.sites = {}
|
|
|
|
address_found = []
|
|
|
|
added = 0
|
|
|
|
# Load new adresses
|
|
|
|
for address in json.load(open("data/sites.json")):
|
|
|
|
if address not in self.sites and os.path.isfile("data/%s/content.json" % address):
|
|
|
|
self.sites[address] = Site(address)
|
|
|
|
added += 1
|
|
|
|
address_found.append(address)
|
|
|
|
|
|
|
|
# Remove deleted adresses
|
|
|
|
for address in self.sites.keys():
|
|
|
|
if address not in address_found:
|
|
|
|
del(self.sites[address])
|
|
|
|
logging.debug("Removed site: %s" % address)
|
|
|
|
|
|
|
|
if added: logging.debug("SiteManager added %s sites" % added)
|
|
|
|
|
|
|
|
|
|
|
|
# Checks if its a valid address
|
|
|
|
def isAddress(self, address):
|
|
|
|
return re.match("^[A-Za-z0-9]{26,35}$", address)
|
|
|
|
|
|
|
|
|
|
|
|
# Return: Site object or None if not found
|
|
|
|
def get(self, address):
|
|
|
|
if self.sites == None: # Not loaded yet
|
|
|
|
self.load()
|
|
|
|
return self.sites.get(address)
|
|
|
|
|
|
|
|
|
|
|
|
# Return or create site and start download site files
|
|
|
|
def need(self, address, all_file=True):
|
|
|
|
from Site import Site
|
|
|
|
new = False
|
|
|
|
site = self.get(address)
|
|
|
|
if not site: # Site not exits yet
|
|
|
|
if not self.isAddress(address): return False # Not address: %s % address
|
|
|
|
logging.debug("Added new site: %s" % address)
|
|
|
|
site = Site(address)
|
|
|
|
self.sites[address] = site
|
|
|
|
if not site.settings["serving"]: # Maybe it was deleted before
|
|
|
|
site.settings["serving"] = True
|
|
|
|
site.saveSettings()
|
|
|
|
new = True
|
|
|
|
|
|
|
|
if all_file: site.download()
|
|
|
|
return site
|
|
|
|
|
|
|
|
|
|
|
|
def delete(self, address):
|
|
|
|
logging.debug("SiteManager deleted site: %s" % address)
|
|
|
|
del(self.sites[address])
|
|
|
|
|
|
|
|
|
|
|
|
# Lazy load sites
|
|
|
|
def list(self):
|
|
|
|
if self.sites == None: # Not loaded yet
|
|
|
|
self.load()
|
|
|
|
return self.sites
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
site_manager = SiteManager() # Singletone
|
|
|
|
|
2015-01-12 02:03:45 +01:00
|
|
|
peer_blacklist = [] # Dont download from this peers
|