本文整理汇总了Python中mixminion.Common.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mixminion.Common.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: regenerateDescriptors
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def regenerateDescriptors(self):
"""Regenerate all server descriptors for all keysets in this
keyring, but keep all old keys intact."""
LOG.info("Regenerating server descriptors; keeping old keys.")
identityKey = self.getIdentityKey()
for _,_,ks in self.keySets:
ks.regenerateServerDescriptor(self.config, identityKey)
示例2: _validateZlib
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def _validateZlib():
"""Internal function: Make sure that zlib is a recognized version, and
that it compresses things as expected. (This check is important,
because using a zlib version that compressed differently from zlib1.1.4
would make senders partitionable by payload compression.)
"""
global _ZLIB_LIBRARY_OK
ver = getattr(zlib, "ZLIB_VERSION", None)
if ver and ver < "1.1.2":
raise MixFatalError("Zlib version %s is not supported"%ver)
_ZLIB_LIBRARY_OK = 0.5
if ver in ("1.1.2", "1.1.3", "1.1.4", "1.2.0", "1.2.0.1", "1.2.0.2",
"1.2.0.3", "1.2.0.4", "1.2.0.5", "1.2.0.6", "1.2.0.7",
"1.2.0.8", "1.2.1", "1.2.1.1", "1.2.1.2", "1.2.2", "1.2.2.2",
"1.2.3", "1.2.7", "1.2.8"):
_ZLIB_LIBRARY_OK = 1
return
LOG.info("Unrecognized zlib version: %r. Spot-checking output", ver)
# This test is inadequate, but it _might_ catch future incompatible
# changes.
_ZLIB_LIBRARY_OK = 0.5
good = '\x78\xda\xed\xc6A\x11\x00 \x08\x00\xb0l\xd4\xf0\x87\x02\xf6o'+\
'`\x0e\xef\xb6\xd7r\xed\x88S=7\xcd\xcc\xcc\xcc\xcc\xcc\xcc'+\
'\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xcc\xbe\xdd\x03'+\
'q\x8d\n\x93'
if compressData("aZbAAcdefg"*1000) == good:
_ZLIB_LIBRARY_OK = 1
else:
_ZLIB_LIBRARY_OK = 0
raise MixFatalError("Zlib output not as exected.")
示例3: removeDeadKeys
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def removeDeadKeys(self, now=None):
"""Remove all keys that have expired."""
self.checkKeys()
keys = self.getDeadKeys(now)
for message, keyset in keys:
LOG.info(message)
keyset.delete()
self.checkKeys()
示例4: configure_trng
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def configure_trng(config):
"""Initialize the true entropy source from a given Config object. If
none is provided, tries some sane defaults."""
global _TRNG_FILENAME
global _theTrueRNG
if sys.platform == 'win32':
# We have two entropy sources on windows: openssl's built-in
# entropy generator that takes data from the screen, and
# Windows's CryptGenRandom function. Because the former is
# insecure, and the latter is closed-source, we xor them.
_ml.win32_openssl_seed()
_ml.openssl_seed(_ml.win32_get_random_bytes(32))
_theTrueRNG = _XorRNG(_OpensslRNG(), _WinTrueRNG())
return
if config is not None:
requestedFile = config['Host'].get('EntropySource')
else:
requestedFile = None
# Build a list of candidates
defaults = PLATFORM_TRNG_DEFAULTS.get(sys.platform,
PLATFORM_TRNG_DEFAULTS['***'])
files = [ requestedFile ] + defaults
# Now find the first of our candidates that exists and is a character
# device.
randFile = None
for filename in files:
if filename is None:
continue
verbose = (filename == requestedFile)
if not os.path.exists(filename):
if verbose:
LOG.warn("No such file as %s", filename)
else:
st = os.stat(filename)
if not (st[stat.ST_MODE] & stat.S_IFCHR):
if verbose:
LOG.error("Entropy source %s isn't a character device",
filename)
else:
randFile = filename
break
if randFile is None and _TRNG_FILENAME is None:
LOG.fatal("No entropy source available: Tried all of %s",
files)
raise MixFatalError("No entropy source available")
elif randFile is None:
LOG.warn("Falling back to previous entropy source %s",
_TRNG_FILENAME)
else:
LOG.info("Setting entropy source to %r", randFile)
_TRNG_FILENAME = randFile
_theTrueRNG = _TrueRNG(1024)
示例5: __loadModules
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def __loadModules(self, section, sectionEntries):
"""Callback from the [Server] section of a config file. Parses
the module options, and adds new sections to the syntax
accordingly."""
self.moduleManager.setPath(section.get('ModulePath'))
for mod in section.get('Module', []):
LOG.info("Loading module %s", mod)
self.moduleManager.loadExtModule(mod)
self._syntax.update(self.moduleManager.getConfigSyntax())
示例6: checkKeys
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def checkKeys(self):
"""Internal method: read information about all this server's
currently-prepared keys from disk.
May raise ConfigError if any of the server descriptors on disk
are invalid.
"""
self.keySets = []
badKeySets = []
firstKey = sys.maxint
lastKey = 0
LOG.debug("Scanning server keystore at %s", self.keyDir)
if not os.path.exists(self.keyDir):
LOG.info("Creating server keystore at %s", self.keyDir)
createPrivateDir(self.keyDir)
# Iterate over the entires in HOME/keys
for dirname in os.listdir(self.keyDir):
# Skip any that aren't directories named "key_INT"
if not os.path.isdir(os.path.join(self.keyDir,dirname)):
continue
if not dirname.startswith('key_'):
LOG.warn("Unexpected directory %s under %s",
dirname, self.keyDir)
continue
keysetname = dirname[4:]
try:
setNum = int(keysetname)
# keep trace of the first and last used key number
if setNum < firstKey: firstKey = setNum
if setNum > lastKey: lastKey = setNum
except ValueError:
LOG.warn("Unexpected directory %s under %s",
dirname, self.keyDir)
continue
# Find the server descriptor...
keyset = ServerKeyset(self.keyDir, keysetname, self.hashDir)
ok = 1
try:
keyset.checkKeys()
except MixError, e:
LOG.warn("Error checking private keys in keyset %s: %s",
keysetname, str(e))
ok = 0
try:
if ok:
keyset.getServerDescriptor()
except (ConfigError, IOError), e:
LOG.warn("Key set %s has invalid/missing descriptor: %s",
keysetname, str(e))
ok = 0
示例7: run
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def run(self):
"""Internal: main body of processing thread."""
try:
while 1:
job = self.mqueue.get()
job()
except ProcessingThread._Shutdown:
LOG.info("Shutting down %s",self.threadName)
return
except:
LOG.error_exc(sys.exc_info(),
"Exception in %s; shutting down thread.",
self.threadName)
示例8: removeIdentityKey
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def removeIdentityKey(self):
"""Remove this server's identity key."""
fn = os.path.join(self.keyDir, "identity.key")
if not os.path.exists(fn):
LOG.info("No identity key to remove.")
else:
LOG.warn("Removing identity key in 10 seconds")
time.sleep(10)
LOG.warn("Removing identity key")
secureDelete([fn], blocking=1)
if os.path.exists(self.dhFile):
LOG.info("Removing diffie-helman parameters file")
secureDelete([self.dhFile], blocking=1)
示例9: publishKeys
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def publishKeys(self, allKeys=0):
"""Publish server descriptors to the directory server. Ordinarily,
only unpublished descriptors are sent. If allKeys is true,
all descriptors are sent."""
keySets = [ ks for _, _, ks in self.keySets ]
if allKeys:
LOG.info("Republishing all known keys to directory server")
else:
keySets = [ ks for ks in keySets if not ks.isPublished() ]
if not keySets:
LOG.trace("publishKeys: no unpublished keys found")
return
LOG.info("Publishing %s keys to directory server...",len(keySets))
rejected = 0
for ks in keySets:
status = ks.publish(DIRECTORY_UPLOAD_URL)
if status == 'error':
LOG.error("Error publishing a key; giving up")
return 0
elif status == 'reject':
rejected += 1
else:
assert status == 'accept'
if rejected == 0:
LOG.info("All keys published successfully.")
return 1
else:
LOG.info("%s/%s keys were rejected." , rejected, len(keySets))
return 0
示例10: regenerateServerDescriptor
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def regenerateServerDescriptor(self, config, identityKey):
"""Regenerate the server descriptor for this keyset, keeping the
original keys."""
self.load()
self.markAsUnpublished()
validAt,validUntil = self.getLiveness()
LOG.info("Regenerating descriptor for keyset %s (%s--%s)",
self.keyname, formatTime(validAt,1),
formatTime(validUntil,1))
generateServerDescriptorAndKeys(config, identityKey,
self.keyroot, self.keyname, self.hashroot,
validAt=validAt, validUntil=validUntil,
useServerKeys=1)
self.serverinfo = self.validAfter = self.validUntil = None
示例11: _getDHFile
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def _getDHFile(self):
"""Return the filename for the diffie-helman parameters for the
server. Creates the file if it doesn't yet exist."""
dhdir = os.path.split(self.dhFile)[0]
createPrivateDir(dhdir)
if not os.path.exists(self.dhFile):
# ???? This is only using 512-bit Diffie-Hellman! That isn't
# ???? remotely enough.
LOG.info("Generating Diffie-Helman parameters for TLS...")
mixminion._minionlib.generate_dh_parameters(self.dhFile, verbose=0)
LOG.info("...done")
else:
LOG.debug("Using existing Diffie-Helman parameter from %s",
self.dhFile)
return self.dhFile
示例12: createKeys
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def createKeys(self, num=1, startAt=None):
"""Generate 'num' public keys for this server. If startAt is provided,
make the first key become valid at 'startAt'. Otherwise, make the
first key become valid right after the last key we currently have
expires. If we have no keys now, make the first key start now."""
# FFFF Use this.
#password = None
if startAt is None:
if self.keySets:
startAt = self.keySets[-1][1]+60
if startAt < time.time():
startAt = time.time()+60
else:
startAt = time.time()+60
startAt = previousMidnight(startAt)
firstKey, lastKey = self.keyRange
for _ in xrange(num):
if firstKey == sys.maxint:
keynum = firstKey = lastKey = 1
elif firstKey > 1:
firstKey -= 1
keynum = firstKey
else:
lastKey += 1
keynum = lastKey
keyname = "%04d" % keynum
lifetime = self.config['Server']['PublicKeyLifetime'].getSeconds()
nextStart = startAt + lifetime
LOG.info("Generating key %s to run from %s through %s (GMT)",
keyname, formatDate(startAt),
formatDate(nextStart-3600))
generateServerDescriptorAndKeys(config=self.config,
identityKey=self.getIdentityKey(),
keyname=keyname,
keydir=self.keyDir,
hashdir=self.hashDir,
validAt=startAt)
startAt = nextStart
self.checkKeys()
示例13: getNextKeygen
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def getNextKeygen(self):
"""Return the time (in seconds) when we should next generate keys.
If -1 is returned, keygen should occur immediately.
"""
if not self.keySets:
return -1
# Our last current key expires at 'lastExpiry'.
lastExpiry = self.keySets[-1][1]
# We want to have keys in the directory valid for
# PREPUBLICATION_INTERVAL seconds after that, and we assume that
# a key takes up to PUBLICATION_LATENCY seconds to make it into the
# directory.
nextKeygen = lastExpiry - PUBLICATION_LATENCY - PREPUBLICATION_INTERVAL
LOG.info("Last expiry at %s; next keygen at %s",
formatTime(lastExpiry,1), formatTime(nextKeygen, 1))
return nextKeygen
示例14: getIdentityKey
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def getIdentityKey(self):
"""Return this server's identity key. Generate one if it doesn't
exist."""
password = None # FFFF Use this, somehow.
fn = os.path.join(self.keyDir, "identity.key")
bits = self.config['Server']['IdentityKeyBits']
if os.path.exists(fn):
checkPrivateFile(fn)
key = mixminion.Crypto.pk_PEM_load(fn, password)
keylen = key.get_modulus_bytes()*8
if keylen != bits:
LOG.warn(
"Stored identity key has %s bits, but you asked for %s.",
keylen, bits)
else:
LOG.info("Generating identity key. (This may take a while.)")
key = mixminion.Crypto.pk_generate(bits)
mixminion.Crypto.pk_PEM_save(key, fn, password)
LOG.info("Generated %s-bit identity key.", bits)
return key
示例15: learnServerID
# 需要导入模块: from mixminion.Common import LOG [as 别名]
# 或者: from mixminion.Common.LOG import info [as 别名]
def learnServerID(self, server):
"""Mark the ID for a server descriptor as the canonical
identity key associated with that server's nickname."""
try:
self._lock()
ident = server.getIdentity()
nickname = server.getNickname()
try:
if self.idCache.containsServer(server):
LOG.warn("Server %s already known", nickname)
except mixminion.directory.MismatchedID:
raise MixFatalError("Mismatched ID for server %s" % nickname)
LOG.info("Learning identity for new server %s", nickname)
self.idCache.insertServer(server)
writePickled(os.path.join(self.serverIDDir,
nickname+"-"+formatFnameTime()),
("V0", (nickname, pk_encode_public_key(ident))))
self.idCache.save()
finally:
self._unlock()