コード例 #1
0
    def get_listing_row(self, listingType):
        dst, etc = "", ""

        if listingType == entries.ListingType.IP_ADDRESS:
            dst = self.cliLine.getDestinationLabel(100, includeLocale=True)
            etc = self.cliLine.foreign.getNickname()

        theme = gtkTools.Theme()

        return (dst, etc, self.cliLine.placementLabel, self.cliLine.getType(),
                theme.colors['insensitive'], self)
コード例 #2
0
    def __init__(self, builder):
        self.builder = builder

        self._config = dict(DEFAULT_CONFIG)
        self._lastUpdate = 0

        self.lock = RLock()
        self.msgLog = deque()
        self.loggedEvents = setEventListening(expandEvents(STARTUP_EVENTS))

        torEventBacklog = deque()
        if self._config["features.log.prepopulate"]:
            setRunlevels = list(
                set.intersection(set(self.loggedEvents),
                                 set(log.Runlevel.values())))
            readLimit = self._config["features.log.prepopulateReadLimit"]
            addLimit = self._config["cache.logPanel.size"]
            torEventBacklog = deque(
                getLogFileEntries(setRunlevels, readLimit, addLimit,
                                  self._config))

        armRunlevels = [log.DEBUG, log.INFO, log.NOTICE, log.WARN, log.ERR]
        log.addListeners(armRunlevels, self._register_arm_event)

        setRunlevels = []
        for i in range(len(armRunlevels)):
            if "ARM_" + log.Runlevel.values()[i] in self.loggedEvents:
                setRunlevels.append(armRunlevels[i])

        armEventBacklog = deque()
        for level, msg, eventTime in log._getEntries(setRunlevels):
            theme = gtkTools.Theme()
            armEventEntry = LogEntry(eventTime, "ARM_" + level, msg,
                                     theme.colors[RUNLEVEL_EVENT_COLOR[level]])
            armEventBacklog.appendleft(armEventEntry)

        while armEventBacklog or torEventBacklog:
            if not armEventBacklog:
                self.msgLog.append(torEventBacklog.popleft())
            elif not torEventBacklog:
                self.msgLog.append(armEventBacklog.popleft())
            elif armEventBacklog[0].timestamp < torEventBacklog[0].timestamp:
                self.msgLog.append(torEventBacklog.popleft())
            else:
                self.msgLog.append(armEventBacklog.popleft())

        conn = torTools.getConn()
        conn.addEventListener(TorEventObserver(self.register_event))
        conn.addTorCtlListener(self._register_torctl_event)

        gobject.idle_add(self.fill_log)
コード例 #3
0
    def get_listing_row(self, listingType):
        conn = torTools.getConn()
        myType = self.cliLine.getType()
        dstAddress = self.cliLine.getDestinationLabel(26, includeLocale=True)
        localPort = ":%s" % self.cliLine.local.getPort(
        ) if self.cliLine.includePort else ""

        src, dst, etc = "", "", ""

        if listingType == entries.ListingType.IP_ADDRESS:
            myExternalIpAddr = conn.getInfo("address",
                                            self.cliLine.local.getIpAddr())
            addrDiffer = myExternalIpAddr != self.cliLine.local.getIpAddr()

            isExpansionType = not myType in (Category.SOCKS, Category.HIDDEN,
                                             Category.CONTROL)

            if isExpansionType: srcAddress = myExternalIpAddr + localPort
            else: srcAddress = self.cliLine.local.getIpAddr() + localPort

            if myType in (Category.SOCKS, Category.CONTROL):
                src = dstAddress
                dst = srcAddress
            else:
                src = srcAddress
                dst = dstAddress

            if addrDiffer and isExpansionType and self.cliLine.includeExpandedIpAddr and CONFIG[
                    "features.connection.showColumn.expandedIp"]:
                internalAddress = self.cliLine.local.getIpAddr() + localPort

                if myType == Category.INBOUND:
                    (src, dst) = (src, internalAddress)
                else:
                    (src, dst) = (internalAddress, src)

            etc = self.cliLine.getEtcContent(100, listingType)
        else:
            src = "%s:%s" % (self.cliLine.local.ipAddr,
                             self.cliLine.local.port)
            dst = "%s:%s" % (self.cliLine.foreign.ipAddr,
                             self.cliLine.foreign.port)

        timeLabel = uiTools.getTimeLabel(time.time() - self.cliLine.startTime)
        theme = gtkTools.Theme()

        return (src, dst, timeLabel, self.cliLine.getType(),
                theme.colors['insensitive'], self)
コード例 #4
0
  def _pack_graph_widget(self, name):
    graph = CaGraph()
    graph.set_size_request(200, 200)

    placeholder = self.builder.get_object('placeholder_graph_%s' % name)
    placeholder.pack_start(graph)

    xAxis = CaGraphXAxis(graph)
    yAxis = CaGraphYAxis(graph)

    xAxis.min = 0
    xAxis.max = GRAPH_INTERVAL - 1
    xAxis.axis_style.draw_labels = False
    yAxis.axis_style.label_color = (0, 0, 0)

    graph.axiss.append(xAxis)
    graph.axiss.append(yAxis)

    series = CaGraphSeriesArea(graph, 0, 1)

    theme = gtkTools.Theme()
    primaryColor = theme.colors['normal']
    secondaryColor = theme.colors['insensitive']
    colors = { 'primary' : (primaryColor.red_float, primaryColor.green_float, primaryColor.blue_float, 0.5),
               'secondary' : (secondaryColor.red_float, secondaryColor.green_float, secondaryColor.blue_float, 0.5) }

    series.style.point_radius = 0.0
    series.style.line_color = colors[name]
    series.style.fill_color = colors[name]

    graph.seriess.append(series)
    graph.grid = CaGraphGrid(graph, 0, 1)

    self.graphs[name] = graph

    return graph
コード例 #5
0
    def _fill_entries(self):
        self.valsLock.acquire()

        listStore = self.builder.get_object('liststore_general')
        theme = gtkTools.Theme()

        listStore.clear()

        key = "arm"
        value = "%s (%s %s)" % (self.vals['sys/hostname'], self.vals['sys/os'],
                                self.vals['sys/version'])
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        versionColor = VERSION_STATUS_COLORS[self.vals["tor/versionStatus"]] if \
            self.vals["tor/versionStatus"] in VERSION_STATUS_COLORS else "black"
        key = "Tor"
        value = "%s (<span foreground=\"%s\">%s</span>)" % (
            self.vals['tor/version'], versionColor,
            self.vals['tor/versionStatus'])
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        includeControlPort = True
        key = "Relaying"
        if self.vals["tor/orPort"]:
            myAddress = "Unknown"
            if self.vals["tor/orListenAddr"]:
                myAddress = self.vals["tor/orListenAddr"]
            elif self.vals["tor/address"]:
                myAddress = self.vals["tor/address"]

            dirPortLabel = ", Dir Port: %s" % self.vals[
                "tor/dirPort"] if self.vals["tor/dirPort"] != "0" else ""

            value = "%s%s%s%s" % (self.vals["tor/nickname"], " - " + myAddress,
                                  ":" + self.vals["tor/orPort"], dirPortLabel)
        else:
            if self._isTorConnected:
                value = "Disabled"
            else:
                statusTime = torTools.getConn().getStatus()[1]

                if statusTime:
                    statusTimeLabel = time.strftime("%H:%M %m/%d/%Y, ",
                                                    time.localtime(statusTime))
                else:
                    statusTimeLabel = ""

                value = "%s%s" % ("Tor Disconnected", statusTimeLabel)
                includeControlPort = False
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        key = "Control Port"
        if includeControlPort:
            if self.vals["tor/isAuthPassword"]: authType = "password"
            elif self.vals["tor/isAuthCookie"]: authType = "cookie"
            else: authType = "open"

            authColor = "red" if authType == "open" else "green"
            value = "%s (<span foreground=\"%s\">%s</span>)" % (
                self.vals['tor/controlPort'], authColor, authType)
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        if self.vals["stat/rss"] != "0":
            memoryLabel = uiTools.getSizeLabel(int(self.vals["stat/rss"]))
        else:
            memoryLabel = "0"

        uptimeLabel = "N/A"
        if self.vals["tor/startTime"]:
            if self.isPaused() or not self._isTorConnected:
                uptimeLabel = uiTools.getShortTimeLabel(
                    self.getPauseTime() - self.vals["tor/startTime"])
            else:
                uptimeLabel = uiTools.getShortTimeLabel(
                    time.time() - self.vals["tor/startTime"])

        key = "CPU"
        value = "%s%% Tor, %s%% arm" % (self.vals["stat/%torCpu"],
                                        self.vals["stat/%armCpu"])
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        key = "Memory"
        value = "%s (%s%%)" % (memoryLabel, self.vals["stat/%mem"])
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        key = "PID"
        value = "%s" % (self.vals["tor/pid"] if self._isTorConnected else "")
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        key = "Uptime"
        value = uptimeLabel
        row = (key, value, theme.colors['active'])
        listStore.append(row)

        self.valsLock.release()
コード例 #6
0
 def _register_torctl_event(self, level, msg):
     theme = gtkTools.Theme()
     eventColor = theme.colors[RUNLEVEL_EVENT_COLOR[level]]
     self.register_event(
         LogEntry(time.time(), "TORCTL_%s" % level, msg, eventColor))
コード例 #7
0
 def _register_arm_event(self, level, msg, eventTime):
     theme = gtkTools.Theme()
     eventColor = theme.colors[RUNLEVEL_EVENT_COLOR[level]]
     self.register_event(
         LogEntry(eventTime, "ARM_%s" % level, msg, eventColor))
コード例 #8
0
 def get_listing_row(self, listingType):
     row = connEntry.ConnectionLine.get_listing_row(self, listingType)
     theme = gtkTools.Theme()
     return row[:-2] + (theme.colors['active'], self)