add peer blocked alert - micah
This commit is contained in:
parent
af48ec78e6
commit
38ba6e1ecf
|
@ -118,6 +118,8 @@ class EventLogging:
|
||||||
self.manager.connect_event(self.manager.constants['EVENT_BLOCK_DOWNLOADING'], self.tab_log.handle_event)
|
self.manager.connect_event(self.manager.constants['EVENT_BLOCK_DOWNLOADING'], self.tab_log.handle_event)
|
||||||
if self.config.get("enable_block_finished"):
|
if self.config.get("enable_block_finished"):
|
||||||
self.manager.connect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
self.manager.connect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
||||||
|
if self.config.get("enable_peer_blocked"):
|
||||||
|
self.manager.connect_event(self.manager.constants['EVENT_PEER_BLOCKED'], self.tab_log.handle_event)
|
||||||
if self.config.get("enable_other"):
|
if self.config.get("enable_other"):
|
||||||
self.manager.connect_event(self.manager.constants['EVENT_OTHER'], self.tab_log.handle_event)
|
self.manager.connect_event(self.manager.constants['EVENT_OTHER'], self.tab_log.handle_event)
|
||||||
if self.config.get("enable_log_files"):
|
if self.config.get("enable_log_files"):
|
||||||
|
@ -154,6 +156,8 @@ class EventLogging:
|
||||||
self.manager.disconnect_event(self.manager.constants['EVENT_BLOCK_DOWNLOADING'], self.tab_log.handle_event)
|
self.manager.disconnect_event(self.manager.constants['EVENT_BLOCK_DOWNLOADING'], self.tab_log.handle_event)
|
||||||
if self.config.get("enable_block_finished"):
|
if self.config.get("enable_block_finished"):
|
||||||
self.manager.disconnect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
self.manager.disconnect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
||||||
|
if self.config.get("enable_peer_blocked"):
|
||||||
|
self.manager.disconnect_event(self.manager.constants['EVENT_PEER_BLOCKED'], self.tab_log.handle_event)
|
||||||
if self.config.get("enable_other"):
|
if self.config.get("enable_other"):
|
||||||
self.manager.disconnect_event(self.manager.constants['EVENT_OTHER'], self.tab_log.handle_event)
|
self.manager.disconnect_event(self.manager.constants['EVENT_OTHER'], self.tab_log.handle_event)
|
||||||
self.tab_log.clear_log_store()
|
self.tab_log.clear_log_store()
|
||||||
|
@ -245,6 +249,11 @@ class EventLogging:
|
||||||
self.manager.connect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
self.manager.connect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
||||||
else:
|
else:
|
||||||
self.manager.disconnect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
self.manager.disconnect_event(self.manager.constants['EVENT_BLOCK_FINISHED'], self.tab_log.handle_event)
|
||||||
|
if widget == self.glade.get_widget("chk_peer_blocked"):
|
||||||
|
if value:
|
||||||
|
self.manager.connect_event(self.manager.constants['EVENT_PEER_BLOCKED'], self.tab_log.handle_event)
|
||||||
|
else:
|
||||||
|
self.manager.disconnect_event(self.manager.constants['EVENT_PEER_BLOCKED'], self.tab_log.handle_event)
|
||||||
if widget == self.glade.get_widget("chk_other"):
|
if widget == self.glade.get_widget("chk_other"):
|
||||||
if value:
|
if value:
|
||||||
self.manager.connect_event(self.manager.constants['EVENT_OTHER'], self.tab_log.handle_event)
|
self.manager.connect_event(self.manager.constants['EVENT_OTHER'], self.tab_log.handle_event)
|
||||||
|
@ -260,39 +269,75 @@ class EventLogging:
|
||||||
self.dialog_initialize = True
|
self.dialog_initialize = True
|
||||||
try:
|
try:
|
||||||
self.glade.get_widget("chk_finished").set_active(self.config.get("enable_finished"))
|
self.glade.get_widget("chk_finished").set_active(self.config.get("enable_finished"))
|
||||||
self.glade.get_widget("chk_peer_error").set_active(self.config.get("enable_peer_error"))
|
|
||||||
self.glade.get_widget("chk_invalid_request").set_active(self.config.get("enable_invalid_request"))
|
|
||||||
self.glade.get_widget("chk_file_error").set_active(self.config.get("enable_file_error"))
|
|
||||||
self.glade.get_widget("chk_hash_failed_error").set_active(self.config.get("enable_hash_failed_error"))
|
|
||||||
self.glade.get_widget("chk_peer_ban_error").set_active(self.config.get("enable_peer_ban_error"))
|
|
||||||
self.glade.get_widget("chk_fastresume_rejected_error").set_active(self.config.get("enable_fastresume_rejected_error"))
|
|
||||||
self.glade.get_widget("chk_tracker_announce").set_active(self.config.get("enable_tracker_announce"))
|
|
||||||
self.glade.get_widget("chk_tracker_reply").set_active(self.config.get("enable_tracker_reply"))
|
|
||||||
self.glade.get_widget("chk_tracker_alert").set_active(self.config.get("enable_tracker_alert"))
|
|
||||||
self.glade.get_widget("chk_tracker_warning").set_active(self.config.get("enable_tracker_warning"))
|
|
||||||
self.glade.get_widget("chk_storage_moved").set_active(self.config.get("enable_storage_moved"))
|
|
||||||
self.glade.get_widget("chk_piece_finished").set_active(self.config.get("enable_piece_finished"))
|
|
||||||
self.glade.get_widget("chk_block_downloading").set_active(self.config.get("enable_block_downloading"))
|
|
||||||
self.glade.get_widget("chk_block_finished").set_active(self.config.get("enable_block_finished"))
|
|
||||||
self.glade.get_widget("chk_other").set_active(self.config.get("enable_other"))
|
|
||||||
self.glade.get_widget("chk_log_files").set_active(self.config.get("enable_log_files"))
|
|
||||||
except:
|
except:
|
||||||
self.glade.get_widget("chk_finished").set_active(False)
|
self.glade.get_widget("chk_finished").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_peer_error").set_active(self.config.get("enable_peer_error"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_peer_error").set_active(False)
|
self.glade.get_widget("chk_peer_error").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_invalid_request").set_active(self.config.get("enable_invalid_request"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_invalid_request").set_active(False)
|
self.glade.get_widget("chk_invalid_request").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_file_error").set_active(self.config.get("enable_file_error"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_file_error").set_active(False)
|
self.glade.get_widget("chk_file_error").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_hash_failed_error").set_active(self.config.get("enable_hash_failed_error"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_hash_failed_error").set_active(False)
|
self.glade.get_widget("chk_hash_failed_error").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_peer_ban_error").set_active(self.config.get("enable_peer_ban_error"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_peer_ban_error").set_active(False)
|
self.glade.get_widget("chk_peer_ban_error").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_fastresume_rejected_error").set_active(self.config.get("enable_fastresume_rejected_error"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_fastresume_rejected_error").set_active(False)
|
self.glade.get_widget("chk_fastresume_rejected_error").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_tracker_announce").set_active(self.config.get("enable_tracker_announce"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_tracker_announce").set_active(False)
|
self.glade.get_widget("chk_tracker_announce").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_tracker_reply").set_active(self.config.get("enable_tracker_reply"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_tracker_reply").set_active(False)
|
self.glade.get_widget("chk_tracker_reply").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_tracker_alert").set_active(self.config.get("enable_tracker_alert"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_tracker_alert").set_active(False)
|
self.glade.get_widget("chk_tracker_alert").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_tracker_warning").set_active(self.config.get("enable_tracker_warning"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_tracker_warning").set_active(False)
|
self.glade.get_widget("chk_tracker_warning").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_storage_moved").set_active(self.config.get("enable_storage_moved"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_storage_moved").set_active(False)
|
self.glade.get_widget("chk_storage_moved").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_piece_finished").set_active(self.config.get("enable_piece_finished"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_piece_finished").set_active(False)
|
self.glade.get_widget("chk_piece_finished").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_block_downloading").set_active(self.config.get("enable_block_downloading"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_block_downloading").set_active(False)
|
self.glade.get_widget("chk_block_downloading").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_block_finished").set_active(self.config.get("enable_block_finished"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_block_finished").set_active(False)
|
self.glade.get_widget("chk_block_finished").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_peer_blocked").set_active(self.config.get("enable_peer_blocked"))
|
||||||
|
except:
|
||||||
|
self.glade.get_widget("chk_peer_blocked").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_other").set_active(self.config.get("enable_other"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_other").set_active(False)
|
self.glade.get_widget("chk_other").set_active(False)
|
||||||
|
try:
|
||||||
|
self.glade.get_widget("chk_log_files").set_active(self.config.get("enable_log_files"))
|
||||||
|
except:
|
||||||
self.glade.get_widget("chk_log_files").set_active(False)
|
self.glade.get_widget("chk_log_files").set_active(False)
|
||||||
self.dialog_initialize = False
|
self.dialog_initialize = False
|
||||||
self.dialog.show()
|
self.dialog.show()
|
||||||
|
@ -314,5 +359,6 @@ class EventLogging:
|
||||||
self.config.set("enable_piece_finished", self.glade.get_widget("chk_piece_finished").get_active())
|
self.config.set("enable_piece_finished", self.glade.get_widget("chk_piece_finished").get_active())
|
||||||
self.config.set("enable_block_downloading", self.glade.get_widget("chk_block_downloading").get_active())
|
self.config.set("enable_block_downloading", self.glade.get_widget("chk_block_downloading").get_active())
|
||||||
self.config.set("enable_block_finished", self.glade.get_widget("chk_block_finished").get_active())
|
self.config.set("enable_block_finished", self.glade.get_widget("chk_block_finished").get_active())
|
||||||
|
self.config.set("enable_peer_blocked", self.glade.get_widget("chk_peer_blocked").get_active())
|
||||||
self.config.set("enable_other", self.glade.get_widget("chk_other").get_active())
|
self.config.set("enable_other", self.glade.get_widget("chk_other").get_active())
|
||||||
self.config.set("enable_log_files", self.glade.get_widget("chk_log_files").get_active())
|
self.config.set("enable_log_files", self.glade.get_widget("chk_log_files").get_active())
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="table1">
|
<widget class="GtkTable" id="table1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">19</property>
|
<property name="n_rows">20</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label1">
|
<widget class="GtkLabel" id="label1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -249,10 +249,10 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkCheckButton" id="chk_other">
|
<widget class="GtkCheckButton" id="chk_peer_blocked">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">Other</property>
|
<property name="label" translatable="yes">Peer blocked</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">0</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
|
@ -263,14 +263,29 @@
|
||||||
<property name="bottom_attach">17</property>
|
<property name="bottom_attach">17</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="chk_other">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label" translatable="yes">Other</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="toggle_ui"/>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">17</property>
|
||||||
|
<property name="bottom_attach">18</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label2">
|
<widget class="GtkLabel" id="label2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Log files</property>
|
<property name="label" translatable="yes">Log files</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">17</property>
|
<property name="top_attach">18</property>
|
||||||
<property name="bottom_attach">18</property>
|
<property name="bottom_attach">19</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
@ -284,8 +299,8 @@
|
||||||
<signal name="toggled" handler="toggle_ui"/>
|
<signal name="toggled" handler="toggle_ui"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">18</property>
|
<property name="top_attach">19</property>
|
||||||
<property name="bottom_attach">19</property>
|
<property name="bottom_attach">20</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -175,6 +175,14 @@ class LogTabManager(object):
|
||||||
logfile = open(log, "a")
|
logfile = open(log, "a")
|
||||||
logfile.write(time.asctime(time.localtime()) + ", " +event_message + '\n')
|
logfile.write(time.asctime(time.localtime()) + ", " +event_message + '\n')
|
||||||
logfile.close()
|
logfile.close()
|
||||||
|
if event['event_type'] is self.manager.constants['EVENT_PEER_BLOCKED']:
|
||||||
|
event_message = _("Peer blocked") + " {" + _("event message: ") + event['message'] + ", "\
|
||||||
|
+ _("ip address: ") + event['ip'] + "}"
|
||||||
|
if self.log_files:
|
||||||
|
log = os.path.join(self.logdir, 'peer_blocked.log')
|
||||||
|
logfile = open(log, "a")
|
||||||
|
logfile.write(time.asctime(time.localtime()) + ", " +event_message + '\n')
|
||||||
|
logfile.close()
|
||||||
if event['event_type'] is self.manager.constants['EVENT_OTHER']:
|
if event['event_type'] is self.manager.constants['EVENT_OTHER']:
|
||||||
event_message = _("Other") + " {" + _("event message: ") + event['message'] + "}"
|
event_message = _("Other") + " {" + _("event message: ") + event['message'] + "}"
|
||||||
if self.log_files:
|
if self.log_files:
|
||||||
|
|
|
@ -86,6 +86,7 @@ using namespace libtorrent;
|
||||||
#define EVENT_PIECE_FINISHED 15
|
#define EVENT_PIECE_FINISHED 15
|
||||||
#define EVENT_BLOCK_DOWNLOADING 16
|
#define EVENT_BLOCK_DOWNLOADING 16
|
||||||
#define EVENT_BLOCK_FINISHED 17
|
#define EVENT_BLOCK_FINISHED 17
|
||||||
|
#define EVENT_PEER_BLOCKED 18
|
||||||
|
|
||||||
#define STATE_QUEUED 0
|
#define STATE_QUEUED 0
|
||||||
#define STATE_CHECKING 1
|
#define STATE_CHECKING 1
|
||||||
|
@ -371,7 +372,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
M_ses->add_extension(&libtorrent::create_metadata_plugin);
|
M_ses->add_extension(&libtorrent::create_metadata_plugin);
|
||||||
|
|
||||||
M_constants = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}",
|
M_constants = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}",
|
||||||
"EVENT_NULL", EVENT_NULL,
|
"EVENT_NULL", EVENT_NULL,
|
||||||
"EVENT_FINISHED", EVENT_FINISHED,
|
"EVENT_FINISHED", EVENT_FINISHED,
|
||||||
"EVENT_PEER_ERROR", EVENT_PEER_ERROR,
|
"EVENT_PEER_ERROR", EVENT_PEER_ERROR,
|
||||||
|
@ -389,6 +390,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
|
||||||
"EVENT_PIECE_FINISHED", EVENT_PIECE_FINISHED,
|
"EVENT_PIECE_FINISHED", EVENT_PIECE_FINISHED,
|
||||||
"EVENT_BLOCK_DOWNLOADING", EVENT_BLOCK_DOWNLOADING,
|
"EVENT_BLOCK_DOWNLOADING", EVENT_BLOCK_DOWNLOADING,
|
||||||
"EVENT_BLOCK_FINISHED", EVENT_BLOCK_FINISHED,
|
"EVENT_BLOCK_FINISHED", EVENT_BLOCK_FINISHED,
|
||||||
|
"EVENT_PEER_BLOCKED", EVENT_PEER_BLOCKED,
|
||||||
"STATE_QUEUED", STATE_QUEUED,
|
"STATE_QUEUED", STATE_QUEUED,
|
||||||
"STATE_CHECKING", STATE_CHECKING,
|
"STATE_CHECKING", STATE_CHECKING,
|
||||||
"STATE_CONNECTING", STATE_CONNECTING,
|
"STATE_CONNECTING", STATE_CONNECTING,
|
||||||
|
@ -896,6 +898,14 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args)
|
||||||
if (!popped_alert)
|
if (!popped_alert)
|
||||||
{
|
{
|
||||||
Py_INCREF(Py_None); return Py_None;
|
Py_INCREF(Py_None); return Py_None;
|
||||||
|
} else if (dynamic_cast<peer_blocked_alert*>(popped_alert))
|
||||||
|
{
|
||||||
|
std::string peer_IP =
|
||||||
|
(dynamic_cast<peer_blocked_alert*>(popped_alert))->ip.to_string();
|
||||||
|
return Py_BuildValue("{s:i,s:s,s:s}",
|
||||||
|
"event_type", EVENT_PEER_BLOCKED,
|
||||||
|
"ip", peer_IP.c_str(),
|
||||||
|
"message", a->msg().c_str());
|
||||||
} else if (dynamic_cast<block_downloading_alert*>(popped_alert))
|
} else if (dynamic_cast<block_downloading_alert*>(popped_alert))
|
||||||
{
|
{
|
||||||
torrent_handle handle = (dynamic_cast<block_downloading_alert*>(popped_alert))->handle;
|
torrent_handle handle = (dynamic_cast<block_downloading_alert*>(popped_alert))->handle;
|
||||||
|
|
Loading…
Reference in New Issue