Example #1
0
 def __init__(self, eventTypes, logName):
     #: mapping from events to their event classes:
     self._eventTypes = eventTypes
     #: used to track events, so they can be logged hourly, for better anonymity and performance
     self._reset_events()
     #open the logs:
     EventLogging.open_logs(logName)
     #schedule a flush of the logs for the end of the hour:
     self._schedule_next_flush()
Example #2
0
 def __init__(self, eventTypes, logName):
   #: mapping from events to their event classes:
   self._eventTypes = eventTypes
   #: used to track events, so they can be logged hourly, for better anonymity and performance
   self._reset_events()
   #open the logs:
   EventLogging.open_logs(logName)
   #schedule a flush of the logs for the end of the hour:
   self._schedule_next_flush()
Example #3
0
#!/usr/bin/python
import os
import random
from serverCommon import EventLogging
from serverCommon import Events

os.system("rm ./testevents.ou*") == 0
EventLogging.open_logs("testevents.out")

def random_hex(size):
  size /= 2
  data = "".join(chr(random.randrange(0, 256)) for i in xrange(size))
  return data.encode("hex")

def reduce_size(data, amount):
  keys = data.keys()
  count = 0
  for key in keys:
    del data[key]
    count += 1
    if count >= amount:
      return

emails = {}
for i in range(0,40):
  emails["*****@*****.**"%(random_hex(10))] = random_hex(20)

for email, ref in emails.iteritems():
  EventLogging.save_event(Events.EmailSent(address=email, hexkey=ref))
reduce_size(emails, 5)
Example #4
0
parser.add_option("--live", action="store_true", dest="is_live", default=False)
parser.add_option("--dev", action="store_true", dest="is_dev", default=False)
(options, args) = parser.parse_args()
if options.is_live:
  from common.conf import Live as Conf
else:
  if not options.is_dev:
    print("You must use either the --live or --dev switches")
    sys.exit(1)
  from common.conf import Dev as Conf

#open the event logs
LOG_DIR = "/mnt/logs/consensus/"
if not os.path.exists(LOG_DIR):
  os.makedirs(LOG_DIR)
EventLogging.open_logs(os.path.join(LOG_DIR, "consensus_events.out"))

#get the document
conn = httplib.HTTPConnection("%s:%s" % (Conf.AUTH_SERVERS[0]["address"], Conf.AUTH_SERVERS[0]["dirport"]))
conn.request("GET", "/tor/status-vote/current/consensus")
response = conn.getresponse()
responseData = response.read()

#parse all of the bandwidths out of it
bandwidthRe = re.compile('w Bandwidth=(\d{1,10})')

#get bandwidth
bandwidths = [int(r) for r in bandwidthRe.findall(responseData)]
totalBandwidth = sum(bandwidths)
numRelays = len(bandwidths)
bandwidths.sort()
Example #5
0
parser.add_option("--live", action="store_true", dest="is_live", default=False)
parser.add_option("--dev", action="store_true", dest="is_dev", default=False)
(options, args) = parser.parse_args()
if options.is_live:
    from common.conf import Live as Conf
else:
    if not options.is_dev:
        print("You must use either the --live or --dev switches")
        sys.exit(1)
    from common.conf import Dev as Conf

#open the event logs
LOG_DIR = "/mnt/logs/consensus/"
if not os.path.exists(LOG_DIR):
    os.makedirs(LOG_DIR)
EventLogging.open_logs(os.path.join(LOG_DIR, "consensus_events.out"))

#get the document
conn = httplib.HTTPConnection(
    "%s:%s" %
    (Conf.AUTH_SERVERS[0]["address"], Conf.AUTH_SERVERS[0]["dirport"]))
conn.request("GET", "/tor/status-vote/current/consensus")
response = conn.getresponse()
responseData = response.read()

#parse all of the bandwidths out of it
bandwidthRe = re.compile('w Bandwidth=(\d{1,10})')

#get bandwidth
bandwidths = [int(r) for r in bandwidthRe.findall(responseData)]
totalBandwidth = sum(bandwidths)
Example #6
0
#!/usr/bin/python
import os
import random
from serverCommon import EventLogging
from serverCommon import Events

os.system("rm ./testevents.ou*") == 0
EventLogging.open_logs("testevents.out")


def random_hex(size):
    size /= 2
    data = "".join(chr(random.randrange(0, 256)) for i in xrange(size))
    return data.encode("hex")


def reduce_size(data, amount):
    keys = data.keys()
    count = 0
    for key in keys:
        del data[key]
        count += 1
        if count >= amount:
            return


emails = {}
for i in range(0, 40):
    emails["*****@*****.**" % (random_hex(10))] = random_hex(20)

for email, ref in emails.iteritems():
Example #7
0
from common.utils.Basic import log_msg, log_ex, _ # pylint: disable-msg=W0611
from common import Globals
from common.system import Files
from common.utils import Basic
from common.utils import TorUtils
from common.classes import Logger
from common.classes import SymmetricKey
from common.classes import PublicKey
from serverCommon.DBUtil import format_auth
from serverCommon import db
from serverCommon.Events import BankLogin
from serverCommon import EventLogging
import BankUtil
import AccountCreation
EventLogging.open_logs("/mnt/logs/bank/login_events.out")

cert = '/etc/apache2/ssl/server.crt'
privateKey = '/etc/apache2/ssl/server.key'

if os.path.exists("THIS_IS_KANS_MACHINE"):
  from common.conf import Dev as Conf
  bank1Address = address.IPv4Address('TCP', '24.131.16.34', 10001) #
  Conf.LOGIN_PORT = 1092
elif os.path.exists("THIS_IS_DEBUG"):
  from common.conf import Dev as Conf
  bank1Address = address.IPv4Address('TCP', Conf.DEV_SERVER, Conf.SERVER_PORT) #innomi.net
  cert = '/home/certificate_authority/server.crt'
else:
  from common.conf import Live as Conf
  bank1Address = address.IPv4Address('TCP', '174.129.199.15', Conf.SERVER_PORT) #login.bitblinder.com