def get_exit_node(self): ret = copy.copy(self.last_exit) # GIL FTW if ret: plog("DEBUG", "Got last exit of " + ret.idhex) else: plog("DEBUG", "No last exit.") return ret
def notlambda(this): cond.acquire() SQLSupport.tc_session.close() try: shutil.copy(sql_file, new_file) except Exception, e: plog("WARN", "Error moving sql file: " + str(e))
def get_continent(country_code): """ Perform country -- continent mapping """ for c in continents: if c.contains(country_code): return c plog("INFO", country_code + " is not on any continent") return None
def notlambda(sm): plog("DEBUG", "Job for setexit: "+exit_name) cond.acquire() # Clear last successful exit, we're running a new test self.last_exit = None sm.set_exit(exit_name) cond.notify() cond.release()
def notlambda(sm): plog("DEBUG", "Job for setexit: " + exit_name) cond.acquire() # Clear last successful exit, we're running a new test self.last_exit = None sm.set_exit(exit_name) cond.notify() cond.release()
def notlambda(this): if this.sql_consensus_listener.last_desc_at != SQLSupport.ConsensusTrackerListener.CONSENSUS_DONE: this.sql_consensus_listener.wait_for_signal = False plog("INFO", "Waiting on consensus result: " + str(this.run_all_jobs)) this.schedule_low_prio(notlambda) else: cond.acquire() this.sql_consensus_listener.wait_for_signal = True cond.notify() cond.release()
def notlambda(this): if this.sql_consensus_listener.last_desc_at \ != SQLSupport.ConsensusTrackerListener.CONSENSUS_DONE: this.sql_consensus_listener.wait_for_signal = False plog("INFO", "Waiting on consensus result: "+str(this.run_all_jobs)) this.schedule_low_prio(notlambda) else: cond.acquire() this.sql_consensus_listener.wait_for_signal = True cond.notify() cond.release()
def notlambda(this): cond.acquire() this.new_nym = True if this.selmgr.bad_restrictions: plog("NOTICE", "Clearing bad restrictions with reconfigure..") this.selmgr.reconfigure(this.current_consensus()) lines = this.c.sendAndRecv("SIGNAL CLEARDNSCACHE\r\n") for _, msg, more in lines: plog("DEBUG", msg) cond.notify() cond.release()
def __init__(self, router): self.__dict__ = router.__dict__ self.country_code = get_country(self.get_ip_dotted()) if self.country_code != None: c = get_continent(self.country_code) if c != None: self.continent = c.code self.cont_group = c.group else: plog("INFO", self.nickname + ": Country code not found") self.continent = None
def close_streams(self, reason): cond = threading.Condition() plog("NOTICE", "Wedged Tor stream. Closing all streams") def notlambda(this): cond.acquire() this.close_all_streams(reason) cond.notify() cond.release() cond.acquire() self.schedule_low_prio(notlambda) cond.wait() cond.release()
def set_exit_node(self, arg): cond = threading.Condition() exit_name = arg plog("DEBUG", "Got Setexit: "+exit_name) def notlambda(sm): plog("DEBUG", "Job for setexit: "+exit_name) cond.acquire() sm.set_exit(exit_name) cond.notify() cond.release() cond.acquire() self.schedule_selmgr(notlambda) cond.wait() cond.release()
def set_exit_node(self, arg): cond = threading.Condition() exit_name = arg plog("DEBUG", "Got Setexit: "+exit_name) def notlambda(sm): plog("DEBUG", "Job for setexit: "+exit_name) cond.acquire() # Clear last successful exit, we're running a new test self.last_exit = None sm.set_exit(exit_name) cond.notify() cond.release() cond.acquire() self.schedule_selmgr(notlambda) cond.wait() cond.release()
def set_exit_node(self, arg): cond = threading.Condition() exit_name = arg plog("DEBUG", "Got Setexit: " + exit_name) def notlambda(sm): plog("DEBUG", "Job for setexit: " + exit_name) cond.acquire() # Clear last successful exit, we're running a new test self.last_exit = None sm.set_exit(exit_name) cond.notify() cond.release() cond.acquire() self.schedule_selmgr(notlambda) cond.wait() cond.release()
def wait_for_consensus(self): cond = threading.Condition() def notlambda(this): if this.sql_consensus_listener.last_desc_at \ != SQLSupport.ConsensusTrackerListener.CONSENSUS_DONE: this.sql_consensus_listener.wait_for_signal = False plog("INFO", "Waiting on consensus result: "+str(this.run_all_jobs)) this.schedule_low_prio(notlambda) else: cond.acquire() this.sql_consensus_listener.wait_for_signal = True cond.notify() cond.release() plog("DEBUG", "Checking for consensus") cond.acquire() self.schedule_low_prio(notlambda) cond.wait() cond.release() plog("INFO", "Consensus OK")
def commit(self): plog("INFO", "Scanner committing jobs...") cond = threading.Condition() def notlambda2(this): cond.acquire() this.run_all_jobs = False plog("INFO", "Commit done.") cond.notify() cond.release() def notlambda1(this): plog("INFO", "Committing jobs...") this.run_all_jobs = True self.schedule_low_prio(notlambda2) cond.acquire() self.schedule_immediate(notlambda1) cond.wait() cond.release() plog("INFO", "Scanner commit done.")
def notlambda2(this): cond.acquire() this.run_all_jobs = False plog("INFO", "Commit done.") cond.notify() cond.release()
def notlambda(sm): plog("DEBUG", "Job for setexit: " + exit_name) cond.acquire() sm.set_exit(exit_name) cond.notify() cond.release()
def attach_sql_listener(self, db_uri): plog("DEBUG", "Got sqlite: " + db_uri) SQLSupport.setup_db(db_uri, echo=False, drop=True) self.sql_consensus_listener = SQLSupport.ConsensusTrackerListener() self.add_event_listener(self.sql_consensus_listener) self.add_event_listener(SQLSupport.StreamListener())
def notlambda1(this): plog("INFO", "Committing jobs...") this.run_all_jobs = True self.schedule_low_prio(notlambda2)
#!/usr/bin/python # Copyright 2007 Johannes Renner and Mike Perry. See LICENSE file. import struct import socket import TorCtl import StatsSupport from TorUtil import plog try: import GeoIP # GeoIP data object: choose database here geoip = GeoIP.new(GeoIP.GEOIP_STANDARD) #geoip = GeoIP.open("./GeoLiteCity.dat", GeoIP.GEOIP_STANDARD) except: plog("NOTICE", "No GeoIP library. GeoIPSupport.py will not work correctly") # XXX: How do we bail entirely.. class Continent: """ Continent class: The group attribute is to partition the continents in groups, to determine the number of ocean crossings """ def __init__(self, continent_code): self.code = continent_code self.group = None self.countries = [] def contains(self, country_code): return country_code in self.countries # Set countries to continents
#!/usr/bin/python import struct import socket import TorCtl import StatsSupport from TorUtil import plog try: import GeoIP # GeoIP data object: choose database here geoip = GeoIP.new(GeoIP.GEOIP_STANDARD) #geoip = GeoIP.open("./GeoLiteCity.dat", GeoIP.GEOIP_STANDARD) except: plog("NOTICE", "No GeoIP library. GeoIPSupport.py will not work correctly") # XXX: How do we bail entirely.. class Continent: """ Continent class: The group attribute is to partition the continents in groups, to determine the number of ocean crossings """ def __init__(self, continent_code): self.code = continent_code self.group = None self.countries = [] def contains(self, country_code): return country_code in self.countries # Set countries to continents africa = Continent("AF")