def _Config_ChangeVal(self): if not is_alive(): import TrackTor.Home.MessageBox MessageBox.box.showMessageBox( MessageBox.box, 'Message', 'Unable to connect to Tor! Hence can not update Configurations!' ) else: self.ui.Conf_Label.hide() name = self.ui.Config_Options.currentText() new_val = self.ui.Config_NewVal.text() self.ui.Config_CurrentVal.setText(new_val) self.ui.Config_NewVal.setText('') if new_val != Configurations[name]: try: if Value_Type[name] == 'Boolean': if new_val.lower() == 'true': new_val = '1' elif new_val.lower() == 'false': new_val = '0' elif Value_Type[name] == 'LineList': new_val = new_val.split( ',') # set_conf accepts list inputs set_conf(name, new_val) self.ui.Conf_Label.setText( "<html><head/><body><p align=\"center\"><span style=\" color:#227319;\">Value has been updated</span></p></body></html>" ) self.ui.Conf_Label.show() except Exception as exc: self.ui.Conf_Label.setText(str(exc)) self.ui.Conf_Label.show()
def _Config_Reset(self): if not is_alive(): import MessageBox MessageBox.box.showMessageBox( MessageBox.box, 'Message', 'Unable to connect to Tor! Hence can not Reset Configurations') else: name = self.ui.Config_Options.currentText() reset_conf(name)
def connections(): args = StaticInfo.args if not (is_alive()): return pid = StaticInfo.pid policy = get_exit_policy() relays = {} # address => [orports...] list_add,list_or=get_network_statuses() for desc_add,desc_or in zip(list_add,list_or): relays.setdefault(desc_add, []).append(desc_or) exit_connections = {} # port => [connections] for conn in get_connection(): global categories if conn.local_port in get_ports('OR'): categories['INBOUND_OR'].append(conn) elif conn.local_port in get_ports('DIR'): categories['INBOUND_DIR'].append(conn) elif conn.local_port in get_ports('CONTROL'): categories['INBOUND_CONTROL'].append(conn) elif conn.remote_port in relays.get(conn.remote_address, []): categories['OUTBOUND'].append(conn) elif can_exit_to(policy,conn.remote_address, conn.remote_port): categories['EXIT'].append(conn) exit_connections.setdefault(conn.remote_port, []).append(conn) else: categories['OUTBOUND'].append(conn) circ = get_circuits() for conn in circ: categories['CIRCUIT'].append(conn) if exit_connections: total_ipv4, total_ipv6 = 0, 0 for port in sorted(exit_connections): connections = exit_connections[port] ipv4_count = len([conn for conn in connections if is_valid_ipv4_address(conn.remote_address)]) ipv6_count = len(connections) - ipv4_count total_count = len(connections) total_ipv4, total_ipv6 = total_ipv4 + ipv4_count, total_ipv6 + ipv6_count usage = port_usage(port) label = '%s (%s)' % (port, usage) if usage else port
def _Inbound_Outbound(self): global Row_Count if not (is_alive()): return else: #Length Calculation self.ui.Relay_Table.setRowCount(length_all) #Printng Connections if (len(CIRCUIT)): Row_Count = self._Connections_All(CIRCUIT, Row_Count, 'Circuit') if (len(INBOUND_CONTROL)): if (Row_Count): Row_Count = self._Connections_All(INBOUND_CONTROL, Row_Count + 1, 'Control') else: Row_Count = self._Connections_All(INBOUND_CONTROL, Row_Count, 'Control') if (len(INBOUND_DIR)): if (Row_Count): Row_Count = self._Connections_All(INBOUND_DIR, Row_Count + 1, 'DIR') else: Row_Count = self._Connections_All(INBOUND_DIR, Row_Count, 'DIR') if (len(INBOUND_OR)): if (Row_Count): Row_Count = self._Connections_All(INBOUND_OR, Row_Count + 1, 'OR') else: Row_Count = self._Connections_All(INBOUND_OR, Row_Count, 'OR') if (len(OUTBOUND)): if (Row_Count): Row_Count = self._Connections_All(OUTBOUND, Row_Count + 1, 'Outbound') else: Row_Count = self._Connections_All(OUTBOUND, Row_Count, 'Outbound') if (len(EXIT)): if (Row_Count): Row_Count = self._Connections_All(EXIT, Row_Count + 1, 'Exit') else: Row_Count = self._Connections_All(EXIT, Row_Count, 'Exit')
def Inbound(self): if not (is_alive()): return global inbound_y global inbound_databuffer inbound_count = 0 for conn in get_connection(): if conn.local_port in get_ports('OR'): inbound_count += 1 elif conn.local_port in get_ports('DIR'): inbound_count += 1 elif conn.local_port in get_ports('CONTROL'): inbound_count += 1 inbound_databuffer.append(inbound_count) inbound_y[:] = inbound_databuffer self.ui.Inbound_Conn1.setText(str(inbound_count) + " /Sec") self.ui.inbound_curve.setData(inbound_x, inbound_y)
def Outbound(self): if not (is_alive()): return global outbound_y global outbound_databuffer global relays outbound_count = 0 for conn in get_connection(): if conn.remote_port in relays.get(conn.remote_address, []): outbound_count += 1 elif can_exit_to(self.policy, conn.remote_address, conn.remote_port): outbound_count += 1 else: outbound_count += 1 self.ui.Outbound_Conn1.setText(str(outbound_count) + " /Sec") outbound_databuffer.append(outbound_count) outbound_y[:] = outbound_databuffer self.ui.outbound_curve.setData(outbound_x, outbound_y)
def Downloads(self): if not (is_alive()): return def Get_Downloads_Data(): global downloads_y global downloads_databuffer exitpolicy = self.control_socket.recv(4096).decode('utf-8') exitpolicy = exitpolicy.split() read = 0 if exitpolicy[0] == '650' and exitpolicy[1] == 'BW': read = int(exitpolicy[2]) written = int(exitpolicy[3]) downloads_databuffer.append(read) downloads_y[:] = downloads_databuffer self.ui.Downloads_Speed1.setText(str((read) / 1000) + " kB/s") thread_data = threading.Thread(target=Get_Downloads_Data) thread_data.start() self.ui.downloads_curve.setData(downloads_x, downloads_y) thread_data.join()
def __init__(self, ui): self.ui = ui if not is_alive(): import sys sys.stderr = open("Error.txt", "w")