This file is indexed.

/usr/share/arm/cli/graphing/connStats.py is in tor-arm 1.4.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Tracks stats concerning tor's current connections.
"""

from cli.graphing import graphPanel
from util import connections, torTools

class ConnStats(graphPanel.GraphStats):
  """
  Tracks number of connections, counting client and directory connections as 
  outbound. Control connections are excluded from counts.
  """
  
  def __init__(self):
    graphPanel.GraphStats.__init__(self)
    
    # listens for tor reload (sighup) events which can reset the ports tor uses
    conn = torTools.getConn()
    self.orPort, self.dirPort, self.controlPort = "0", "0", "0"
    self.resetListener(conn, torTools.State.INIT) # initialize port values
    conn.addStatusListener(self.resetListener)
  
  def clone(self, newCopy=None):
    if not newCopy: newCopy = ConnStats()
    return graphPanel.GraphStats.clone(self, newCopy)
  
  def resetListener(self, conn, eventType):
    if eventType in (torTools.State.INIT, torTools.State.RESET):
      self.orPort = conn.getOption("ORPort", "0")
      self.dirPort = conn.getOption("DirPort", "0")
      self.controlPort = conn.getOption("ControlPort", "0")
  
  def eventTick(self):
    """
    Fetches connection stats from cached information.
    """
    
    inboundCount, outboundCount = 0, 0
    
    for entry in connections.getResolver("tor").getConnections():
      localPort = entry[1]
      if localPort in (self.orPort, self.dirPort): inboundCount += 1
      elif localPort == self.controlPort: pass # control connection
      else: outboundCount += 1
    
    self._processEvent(inboundCount, outboundCount)
  
  def getTitle(self, width):
    return "Connection Count:"
  
  def getHeaderLabel(self, width, isPrimary):
    avg = (self.primaryTotal if isPrimary else self.secondaryTotal) / max(1, self.tick)
    if isPrimary: return "Inbound (%s, avg: %s):" % (self.lastPrimary, avg)
    else: return "Outbound (%s, avg: %s):" % (self.lastSecondary, avg)
  
  def getRefreshRate(self):
    return 5