mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-09 10:03:40 +00:00
Fix some issues with creating torrent files, was putting the announce list in the wrong key
Add support for using a system installed GeoIP db file. It will look for /usr/share/GeoIP/GeoIP.dat first and try to load that
This commit is contained in:
parent
49e27a33bf
commit
a24c07a9bd
@ -65,7 +65,7 @@ class AlertManager(component.Component):
|
|||||||
lt.alert.category_t.storage_notification |
|
lt.alert.category_t.storage_notification |
|
||||||
lt.alert.category_t.tracker_notification |
|
lt.alert.category_t.tracker_notification |
|
||||||
lt.alert.category_t.status_notification |
|
lt.alert.category_t.status_notification |
|
||||||
lt.alert.category_t.ip_block_notification|
|
lt.alert.category_t.ip_block_notification |
|
||||||
lt.alert.category_t.performance_warning)
|
lt.alert.category_t.performance_warning)
|
||||||
|
|
||||||
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
|
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
|
||||||
|
@ -95,16 +95,6 @@ class Core(component.Component):
|
|||||||
# Load the session state if available
|
# Load the session state if available
|
||||||
self.__load_session_state()
|
self.__load_session_state()
|
||||||
|
|
||||||
# Load the GeoIP DB for country look-ups if available
|
|
||||||
geoip_db = pkg_resources.resource_filename("deluge", os.path.join("data", "GeoIP.dat"))
|
|
||||||
if os.path.exists(geoip_db):
|
|
||||||
try:
|
|
||||||
self.session.load_country_db(geoip_db)
|
|
||||||
except Exception, e:
|
|
||||||
log.error("Unable to load geoip database!")
|
|
||||||
log.exception(e)
|
|
||||||
|
|
||||||
|
|
||||||
# Set the user agent
|
# Set the user agent
|
||||||
self.settings = lt.session_settings()
|
self.settings = lt.session_settings()
|
||||||
self.settings.user_agent = "Deluge %s" % deluge.common.get_version()
|
self.settings.user_agent = "Deluge %s" % deluge.common.get_version()
|
||||||
@ -141,6 +131,22 @@ class Core(component.Component):
|
|||||||
# Get the core config
|
# Get the core config
|
||||||
self.config = deluge.configmanager.ConfigManager("core.conf")
|
self.config = deluge.configmanager.ConfigManager("core.conf")
|
||||||
|
|
||||||
|
# Load the GeoIP DB for country look-ups if available
|
||||||
|
geoip_db = ""
|
||||||
|
if os.path.exists(self.config["geoip_db_location"]):
|
||||||
|
geoip_db = self.config["geoip_db_location"]
|
||||||
|
elif os.path.exists(pkg_resources.resource_filename("deluge", os.path.join("data", "GeoIP.dat"))):
|
||||||
|
geoip_db = pkg_resources.resource_filename("deluge", os.path.join("data", "GeoIP.dat"))
|
||||||
|
else:
|
||||||
|
log.warning("Unable to find GeoIP database file!")
|
||||||
|
|
||||||
|
if geoip_db:
|
||||||
|
try:
|
||||||
|
self.session.load_country_db(geoip_db)
|
||||||
|
except Exception, e:
|
||||||
|
log.error("Unable to load geoip database!")
|
||||||
|
log.exception(e)
|
||||||
|
|
||||||
# If there was an interface value from the command line, use it, but
|
# If there was an interface value from the command line, use it, but
|
||||||
# store the one in the config so we can restore it on shutdown
|
# store the one in the config so we can restore it on shutdown
|
||||||
self.__old_interface = None
|
self.__old_interface = None
|
||||||
@ -626,7 +632,7 @@ class Core(component.Component):
|
|||||||
|
|
||||||
@export
|
@export
|
||||||
def create_torrent(self, path, tracker, piece_length, comment, target,
|
def create_torrent(self, path, tracker, piece_length, comment, target,
|
||||||
url_list, private, created_by, httpseeds, add_to_session):
|
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||||
|
|
||||||
log.debug("creating torrent..")
|
log.debug("creating torrent..")
|
||||||
threading.Thread(target=_create_torrent_thread,
|
threading.Thread(target=_create_torrent_thread,
|
||||||
@ -640,10 +646,11 @@ class Core(component.Component):
|
|||||||
private,
|
private,
|
||||||
created_by,
|
created_by,
|
||||||
httpseeds,
|
httpseeds,
|
||||||
|
trackers,
|
||||||
add_to_session)).start()
|
add_to_session)).start()
|
||||||
|
|
||||||
def _create_torrent_thread(self, path, tracker, piece_length, comment, target,
|
def _create_torrent_thread(self, path, tracker, piece_length, comment, target,
|
||||||
url_list, private, created_by, httpseeds, add_to_session):
|
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||||
import deluge.metafile
|
import deluge.metafile
|
||||||
deluge.metafile.make_meta_file(
|
deluge.metafile.make_meta_file(
|
||||||
path,
|
path,
|
||||||
@ -654,7 +661,8 @@ class Core(component.Component):
|
|||||||
url_list=url_list,
|
url_list=url_list,
|
||||||
private=private,
|
private=private,
|
||||||
created_by=created_by,
|
created_by=created_by,
|
||||||
httpseeds=httpseeds)
|
httpseeds=httpseeds,
|
||||||
|
trackers=trackers)
|
||||||
log.debug("torrent created!")
|
log.debug("torrent created!")
|
||||||
if add_to_session:
|
if add_to_session:
|
||||||
self.add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None)
|
self.add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None)
|
||||||
|
@ -142,7 +142,8 @@ DEFAULT_PREFS = {
|
|||||||
"outgoing_ports": [0, 0],
|
"outgoing_ports": [0, 0],
|
||||||
"random_outgoing_ports": True,
|
"random_outgoing_ports": True,
|
||||||
"peer_tos": "0x00",
|
"peer_tos": "0x00",
|
||||||
"rate_limit_ip_overhead": True
|
"rate_limit_ip_overhead": True,
|
||||||
|
"geoip_db_location": "/usr/share/GeoIP/GeoIP.dat"
|
||||||
}
|
}
|
||||||
|
|
||||||
class PreferencesManager(component.Component):
|
class PreferencesManager(component.Component):
|
||||||
|
@ -58,7 +58,7 @@ def dummy(v):
|
|||||||
def make_meta_file(path, url, piece_length, progress=dummy,
|
def make_meta_file(path, url, piece_length, progress=dummy,
|
||||||
title=None, comment=None, safe=None, content_type=None,
|
title=None, comment=None, safe=None, content_type=None,
|
||||||
target=None, url_list=None, name=None, private=False,
|
target=None, url_list=None, name=None, private=False,
|
||||||
created_by=None, httpseeds=None):
|
created_by=None, httpseeds=None, trackers=None):
|
||||||
data = {'creation date': int(gmtime())}
|
data = {'creation date': int(gmtime())}
|
||||||
if url:
|
if url:
|
||||||
data['announce'] = url.strip()
|
data['announce'] = url.strip()
|
||||||
@ -88,6 +88,8 @@ def make_meta_file(path, url, piece_length, progress=dummy,
|
|||||||
data['created by'] = created_by
|
data['created by'] = created_by
|
||||||
if httpseeds:
|
if httpseeds:
|
||||||
data['httpseeds'] = httpseeds
|
data['httpseeds'] = httpseeds
|
||||||
|
if trackers:
|
||||||
|
data['announce-list'] = trackers
|
||||||
|
|
||||||
h.write(bencode(data))
|
h.write(bencode(data))
|
||||||
h.close()
|
h.close()
|
||||||
|
@ -288,10 +288,11 @@ class CreateTorrentDialog:
|
|||||||
piece_length,
|
piece_length,
|
||||||
comment,
|
comment,
|
||||||
result,
|
result,
|
||||||
trackers,
|
None,
|
||||||
private,
|
private,
|
||||||
author,
|
author,
|
||||||
webseeds,
|
webseeds,
|
||||||
|
trackers,
|
||||||
add_to_session)
|
add_to_session)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -312,13 +313,14 @@ class CreateTorrentDialog:
|
|||||||
private,
|
private,
|
||||||
author,
|
author,
|
||||||
webseeds,
|
webseeds,
|
||||||
|
trackers,
|
||||||
add_to_session)).start()
|
add_to_session)).start()
|
||||||
|
|
||||||
chooser.destroy()
|
chooser.destroy()
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
|
||||||
def create_torrent(self, path, tracker, piece_length, progress, comment, target,
|
def create_torrent(self, path, tracker, piece_length, progress, comment, target,
|
||||||
url_list, private, created_by, httpseeds, add_to_session):
|
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||||
import deluge.metafile
|
import deluge.metafile
|
||||||
deluge.metafile.make_meta_file(
|
deluge.metafile.make_meta_file(
|
||||||
path,
|
path,
|
||||||
@ -330,7 +332,8 @@ class CreateTorrentDialog:
|
|||||||
url_list=url_list,
|
url_list=url_list,
|
||||||
private=private,
|
private=private,
|
||||||
created_by=created_by,
|
created_by=created_by,
|
||||||
httpseeds=httpseeds)
|
httpseeds=httpseeds,
|
||||||
|
trackers=trackers)
|
||||||
self.glade.get_widget("progress_dialog").hide_all()
|
self.glade.get_widget("progress_dialog").hide_all()
|
||||||
if add_to_session:
|
if add_to_session:
|
||||||
client.core.add_torrent_file(
|
client.core.add_torrent_file(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user