def on_settings_changed(self): if Tor.get().settings.beRelay: self.relayToggleButton.label.set_text(_("Stop")) self.relayToggleButton.image.set_from_pixbuf(Images.STOP_RELAY_PIXBUF) else: self.relayToggleButton.label.set_text(_("Start")) self.relayToggleButton.image.set_from_pixbuf(Images.START_RELAY_PIXBUF)
def _send(self, s, id): try: #self.transport.sendto(s, 0, self.addr) if self.transport != None and self.transport.disconnected != 1: self.transport.write(s, self.addr) else: log_msg("Tried writing DHT while transport was closed", 1) except socket.error, e: df = self.tids[id] del (self.tids[id]) df.errback((KRPC_SOCKET_ERROR, _("socket error %s") % (e)))
def _send(self, s, id): try: #self.transport.sendto(s, 0, self.addr) if self.transport != None and self.transport.disconnected != 1: self.transport.write(s, self.addr) else: log_msg("Tried writing DHT while transport was closed", 1) except socket.error, e: df = self.tids[id] del(self.tids[id]) df.errback((KRPC_SOCKET_ERROR, _("socket error %s") % (e)))
def timeOut(self, id): if self.tids.has_key(id): df = self.tids[id] del (self.tids[id]) df.errback((KRPC_ERROR_TIMEOUT, _("timeout")))
# if error # lookup tid if self.tids.has_key(msg[TID]): df = self.tids[msg[TID]] # callback df.errback(msg[ERR]) del (self.tids[msg[TID]]) else: # day late and dollar short pass else: # unknown message type df = self.tids[msg[TID]] # callback df.errback((KRPC_ERROR_RECEIVED_UNKNOWN, _("received unknown message type"))) del (self.tids[msg[TID]]) def sendRequest(self, method, args): # make message # send it msg = {TID: chr(self.mtid), TYP: REQ, REQ: method, ARG: args} self.mtid = (self.mtid + 1) % 256 s = bencode(msg) d = Deferred() self.tids[msg[TID]] = d self.call_later(KRPC_TIMEOUT, self.timeOut, msg[TID]) self.call_later(0, self._send, s, msg[TID]) return d def timeOut(self, id):
#!/usr/bin/python #Copyright 2008-2009 InnomiNet """Window for controlling FireFox settings""" import gtk from common.utils.Basic import log_msg, log_ex, _ # pylint: disable-msg=W0611 from gui.gtk.utils import Images from gui.gtk.utils import WrapLabel from gui.gtk.utils import GTKUtils from gui.gtk.dialog import BaseDialog from core import ClientUtil PADDING = 10 helperText = [_("No Anonymity: your traffic is not proxied at all and exits directly to the Internet from your local address."), _("Speedy: fast but not very anonymous since the single relay knows both who you are and the destination of your traffic."), _("Recommended: a decent compromise as it provides some anonymity from the proxies themselves and is reasonably fast."), _("The Tor Standard: the strongest anonymity possible but also the slowest and the most expensive.")] infoText = _("BitBlinder gives you the option of making your traffic more or less anonymous. \ A tradeoff exists between speed and anonymity, so you should choose whats right for you.") greaterInfoText = _(" \ The numbers below the slider correspond to the number of relays that your traffic is proxied through. \ Longer path lengths entail better anonymity but also come at the price of higher latency, lower throughput, and higher cost in credits. \ Specifically, longer paths introduce some latency for each relay and also restrict the throughput to the smallest of the relays in the path. \ Similarly, you must pay credits to each relay in your path so longer paths are proportionally more expensive.\ \n \ In terms of anonymity, a path of length two is significantly better than a path of length one since no relay knows the complete picture; \ the first relay knows who you are, but not the destination of your traffic while the second relay knows the opposite information. \ A path of length three is most likely better than a length of two though the degree to which is difficult to know. \
def __init__(self, controller): GeneratorMixin.GeneratorMixin.__init__(self) ListenerMixin.ListenerMixin.__init__(self) self.controller = controller self.torApp = Tor.get() self._add_events("show_settings", "toggle_server", "show_setup", "done") ClientUtil.add_updater(self) self.bwGraph = BWGraph.BWGraph(BWHistory.remoteBandwidth, root=controller.serverWindow) self.bwGraph.container.set_size_request(400, 200) self.bwGraph.label = gtk.Label("Relay Traffic") self.statusRows = [] self.statistics = {} self.torStatus = None self.rows = [] iconSize = 24 tooltips = gtk.Tooltips() def make_row_box(name, labelText, childWidget): """packs a gui row with a label, childWidget, and an image. it then adds the row and a separator to a vbox which it returns as well as the label it created as for use in homogenizing all the label widths""" image = gtk.Image() image.set_from_pixbuf(Images.GREY_CIRCLE) imageAlign = gtk.Alignment(0, 0, 0, 0) #push the widget over imageAlign.set_padding(0, 0, 0, 10) imageAlign.add(image) textLabel = gtk.Label() textLabel.set_markup("<span size='large' weight='bold'>%s</span>" % (labelText)) #stick the align on the left textLabel.set_alignment(0, 0.5) row = StatusHBox(name, textLabel, childWidget, image) self.statusRows.append(row) row.pack_start(imageAlign, False, False, 0) row.pack_start(textLabel, False, False, 0) row.pack_start(childWidget, False, False, 0) #pad the whole row rowAlign = gtk.Alignment(0, 0, 1, 1) rowAlign.set_padding(0, 0, 5, 5) rowAlign.add(row) sep = gtk.HSeparator() vBox = gtk.VBox() vBox.pack_start(rowAlign, False, False, 10) vBox.pack_start(sep, False, False, 0) return (vBox, row) creditsValueLabel = gtk.Label("0") creditsBox, self.creditsRow = make_row_box('credits', 'Credits: ', creditsValueLabel) statusValueLabel = gtk.Label("Unknown") statusBox, self.statusRow = make_row_box('status', 'Status: ', statusValueLabel) def on_toggle(widget): self._trigger_event("toggle_server") self.relayToggleButton = GTKUtils.make_image_button(_("Start"), on_toggle, "exit.png") self.relayToggleButton.set_size_request(75, -1) relayBox, self.relayRow = make_row_box('relay', "Relay:", self.relayToggleButton) textLabel = gtk.Label("Unknown") relayPortBox, self.tcpRelayPortRow = make_row_box('orPort', "TCP Relay Port:", textLabel) textLabel = gtk.Label("Unknown") udpRelayPortBox, self.udpRelayPortRow = make_row_box('dhtPort', "UDP Relay Port:", textLabel) textLabel = gtk.Label() textLabel.set_markup('<span size="large"> 55555 is unreachable </span>') dirPortBox, self.dirPortRow = make_row_box('dirPort', "Directory Port:", textLabel) labels = [box.rowLabel for box in \ self.creditsRow, self.statusRow, self.relayRow, self.tcpRelayPortRow, self.udpRelayPortRow, self.dirPortRow] maxLabelWidth = 5 + max([label.size_request()[0] for label in labels]) for label in labels: label.set_size_request(maxLabelWidth, -1) hideButton = gtk.Button("Hide") hideButton.connect("clicked", self._hide_cb) settingsButton = gtk.Button("Settings") def on_settings(widget): self._trigger_event("show_settings") settingsButton.connect("clicked", on_settings) buttonBox = gtk.HBox() buttonBox.pack_start(hideButton, False, False, 0) buttonBox.pack_end(settingsButton, False, False, 0) self.serverBox = gtk.VBox() for box in [relayBox, statusBox, relayPortBox, udpRelayPortBox, dirPortBox, creditsBox]: self.serverBox.pack_start(box, True, False, 0) self.serverBox.pack_start(buttonBox, True, False, 0) align = gtk.Alignment(0, 0, 0, 0) align.set_padding(0, 0, 5, 5) align.add(self.serverBox) serverFrame = GTKUtils.add_frame(align) makeAuroraFramesRounded = gtk.HBox() makeAuroraFramesRounded.set_size_request(0,0) serverFrame.set_label_widget(makeAuroraFramesRounded) self.notebook = ClosableTabNotebook.ClosableTabNotebook() self.notebook.show_display(self.bwGraph) notebookAlign = gtk.Alignment(0, 0, 1, 1) notebookAlign.set_padding(5, 5, 0, 5) notebookAlign.add(self.notebook) hbox = gtk.HBox() hbox.pack_start(serverFrame, False, False, 0) hbox.pack_start(notebookAlign, True, True, 0) hbox.show_all() self.catch_event("settings_changed") # self.container = hbox self.label = gtk.Label("Server Status %s" % (Globals.VERSION)) vbox = gtk.VBox() self.menuBar = BaseMenuBar.BaseMenuBar(self.controller) vbox.pack_start(self.menuBar.create_menus(), False, False, 0) vbox.pack_start(hbox, True, True, 0) vbox.show_all() self.container = vbox
#!/usr/bin/python #Copyright 2008-2009 InnomiNet """Window for controlling FireFox settings""" import gtk from common.utils.Basic import log_msg, log_ex, _ # pylint: disable-msg=W0611 from gui.gtk.utils import Images from gui.gtk.utils import WrapLabel from gui.gtk.utils import GTKUtils from gui.gtk.dialog import BaseDialog from core import ClientUtil PADDING = 10 helperText = [ _("No Anonymity: your traffic is not proxied at all and exits directly to the Internet from your local address." ), _("Speedy: fast but not very anonymous since the single relay knows both who you are and the destination of your traffic." ), _("Recommended: a decent compromise as it provides some anonymity from the proxies themselves and is reasonably fast." ), _("The Tor Standard: the strongest anonymity possible but also the slowest and the most expensive." ) ] infoText = _( "BitBlinder gives you the option of making your traffic more or less anonymous. \ A tradeoff exists between speed and anonymity, so you should choose whats right for you." ) greaterInfoText = _(" \ The numbers below the slider correspond to the number of relays that your traffic is proxied through. \
def __init__(self, controller): GeneratorMixin.GeneratorMixin.__init__(self) ListenerMixin.ListenerMixin.__init__(self) self.controller = controller self.torApp = Tor.get() self._add_events("show_settings", "toggle_server", "show_setup", "done") ClientUtil.add_updater(self) self.bwGraph = BWGraph.BWGraph(BWHistory.remoteBandwidth, root=controller.serverWindow) self.bwGraph.container.set_size_request(400, 200) self.bwGraph.label = gtk.Label("Relay Traffic") self.statusRows = [] self.statistics = {} self.torStatus = None self.rows = [] iconSize = 24 tooltips = gtk.Tooltips() def make_row_box(name, labelText, childWidget): """packs a gui row with a label, childWidget, and an image. it then adds the row and a separator to a vbox which it returns as well as the label it created as for use in homogenizing all the label widths""" image = gtk.Image() image.set_from_pixbuf(Images.GREY_CIRCLE) imageAlign = gtk.Alignment(0, 0, 0, 0) # push the widget over imageAlign.set_padding(0, 0, 0, 10) imageAlign.add(image) textLabel = gtk.Label() textLabel.set_markup("<span size='large' weight='bold'>%s</span>" % (labelText)) # stick the align on the left textLabel.set_alignment(0, 0.5) row = StatusHBox(name, textLabel, childWidget, image) self.statusRows.append(row) row.pack_start(imageAlign, False, False, 0) row.pack_start(textLabel, False, False, 0) row.pack_start(childWidget, False, False, 0) # pad the whole row rowAlign = gtk.Alignment(0, 0, 1, 1) rowAlign.set_padding(0, 0, 5, 5) rowAlign.add(row) sep = gtk.HSeparator() vBox = gtk.VBox() vBox.pack_start(rowAlign, False, False, 10) vBox.pack_start(sep, False, False, 0) return (vBox, row) creditsValueLabel = gtk.Label("0") creditsBox, self.creditsRow = make_row_box("credits", "Credits: ", creditsValueLabel) statusValueLabel = gtk.Label("Unknown") statusBox, self.statusRow = make_row_box("status", "Status: ", statusValueLabel) def on_toggle(widget): self._trigger_event("toggle_server") self.relayToggleButton = GTKUtils.make_image_button(_("Start"), on_toggle, "exit.png") self.relayToggleButton.set_size_request(75, -1) relayBox, self.relayRow = make_row_box("relay", "Relay:", self.relayToggleButton) textLabel = gtk.Label("Unknown") relayPortBox, self.tcpRelayPortRow = make_row_box("orPort", "TCP Relay Port:", textLabel) textLabel = gtk.Label("Unknown") udpRelayPortBox, self.udpRelayPortRow = make_row_box("dhtPort", "UDP Relay Port:", textLabel) textLabel = gtk.Label() textLabel.set_markup('<span size="large"> 55555 is unreachable </span>') dirPortBox, self.dirPortRow = make_row_box("dirPort", "Directory Port:", textLabel) labels = [ box.rowLabel for box in self.creditsRow, self.statusRow, self.relayRow, self.tcpRelayPortRow, self.udpRelayPortRow, self.dirPortRow, ] maxLabelWidth = 5 + max([label.size_request()[0] for label in labels]) for label in labels: label.set_size_request(maxLabelWidth, -1) hideButton = gtk.Button("Hide") hideButton.connect("clicked", self._hide_cb) settingsButton = gtk.Button("Settings") def on_settings(widget): self._trigger_event("show_settings") settingsButton.connect("clicked", on_settings) buttonBox = gtk.HBox() buttonBox.pack_start(hideButton, False, False, 0) buttonBox.pack_end(settingsButton, False, False, 0) self.serverBox = gtk.VBox() for box in [relayBox, statusBox, relayPortBox, udpRelayPortBox, dirPortBox, creditsBox]: self.serverBox.pack_start(box, True, False, 0) self.serverBox.pack_start(buttonBox, True, False, 0) align = gtk.Alignment(0, 0, 0, 0) align.set_padding(0, 0, 5, 5) align.add(self.serverBox) serverFrame = GTKUtils.add_frame(align) makeAuroraFramesRounded = gtk.HBox() makeAuroraFramesRounded.set_size_request(0, 0) serverFrame.set_label_widget(makeAuroraFramesRounded) self.notebook = ClosableTabNotebook.ClosableTabNotebook() self.notebook.show_display(self.bwGraph) notebookAlign = gtk.Alignment(0, 0, 1, 1) notebookAlign.set_padding(5, 5, 0, 5) notebookAlign.add(self.notebook) hbox = gtk.HBox() hbox.pack_start(serverFrame, False, False, 0) hbox.pack_start(notebookAlign, True, True, 0) hbox.show_all() self.catch_event("settings_changed") # self.container = hbox self.label = gtk.Label("Server Status %s" % (Globals.VERSION)) vbox = gtk.VBox() self.menuBar = BaseMenuBar.BaseMenuBar(self.controller) vbox.pack_start(self.menuBar.create_menus(), False, False, 0) vbox.pack_start(hbox, True, True, 0) vbox.show_all() self.container = vbox
def timeOut(self, id): if self.tids.has_key(id): df = self.tids[id] del(self.tids[id]) df.errback((KRPC_ERROR_TIMEOUT, _("timeout")))
elif msg[TYP] == ERR: # if error # lookup tid if self.tids.has_key(msg[TID]): df = self.tids[msg[TID]] # callback df.errback(msg[ERR]) del(self.tids[msg[TID]]) else: # day late and dollar short pass else: # unknown message type df = self.tids[msg[TID]] # callback df.errback((KRPC_ERROR_RECEIVED_UNKNOWN, _("received unknown message type"))) del(self.tids[msg[TID]]) def sendRequest(self, method, args): # make message # send it msg = {TID : chr(self.mtid), TYP : REQ, REQ : method, ARG : args} self.mtid = (self.mtid + 1) % 256 s = bencode(msg) d = Deferred() self.tids[msg[TID]] = d self.call_later(KRPC_TIMEOUT, self.timeOut, msg[TID]) self.call_later(0, self._send, s, msg[TID]) return d def timeOut(self, id):