예제 #1
0
파일: client.py 프로젝트: rafaelang/tinyids
    def __init__(self, command):

        # Client configuration (config.TinyIDSConfigParser instance)
        self.cfg = config.get_client_configuration()

        # Holds the current command
        self.command = command  # TEST | CHECK | UPDATE | DELETE | CHANGEPHRASE

        # Default hashing delay
        self.default_hashing_delay = self._get_hashing_delay()

        # Debug protocol
        self.debug_protocol = self.cfg.getboolean("main", "debug_protocol")

        # Data hashing object
        self.hasher = sha1()
        # Immediately hash the machine's hostname to avoid possible
        # identical hashes among identical machines (issue: #248)
        self.hash_data(socket.gethostname())

        # PKI Module
        _keys_dir = self.cfg.get("main", "keys_dir")
        self.pki = crypto.RSAModule(_keys_dir)

        # This is socket.socket object while connected to server
        # Should be set to None as soon the connection is closed
        # or a socket error occurs.
        self.sock = None

        # Should hold the name of the server as long as there is a
        # valid connection to it.
        self.server_name = None
예제 #2
0
    def __init__(self, command):

        # Client configuration (config.TinyIDSConfigParser instance)
        self.cfg = config.get_client_configuration()

        # Holds the current command
        self.command = command  # TEST | CHECK | UPDATE | DELETE | CHANGEPHRASE

        # Default hashing delay
        self.default_hashing_delay = self._get_hashing_delay()

        # Debug protocol
        self.debug_protocol = self.cfg.getboolean('main', 'debug_protocol')

        # Data hashing object
        self.hasher = sha1()
        # Immediately hash the machine's hostname to avoid possible
        # identical hashes among identical machines (issue: #248)
        self.hash_data(socket.gethostname())

        # PKI Module
        _keys_dir = self.cfg.get('main', 'keys_dir')
        self.pki = crypto.RSAModule(_keys_dir)

        # This is socket.socket object while connected to server
        # Should be set to None as soon the connection is closed
        # or a socket error occurs.
        self.sock = None

        # Should hold the name of the server as long as there is a
        # valid connection to it.
        self.server_name = None
예제 #3
0
파일: main.py 프로젝트: triplekill/tinyids
def main():
    opts = cmdline.parse_client()
    config_path = os.path.abspath(opts.confpath)
    try:
        cfg = config.get_client_configuration(config_path)
    except config.ConfigFileNotFoundError:
        sys.stderr.write('ERROR: Configuration file not found: %s\n' %
                         config_path)
        sys.stderr.flush()
        sys.exit(1)

    # Initialize logging
    logger = logging.getLogger()
    if opts.debug:
        applogger.init_std_stream_loggers(verbose=True)
        logger.debug('tinyids started in debug mode')
    else:
        applogger.init_std_stream_loggers()

    logger.debug('Using client configuration from: %s' % config_path)
    logger.debug('Logging to standard streams: STDOUT, STDERR')

    command = None
    if opts.test:
        command = 'TEST'
    if opts.check:
        command = 'CHECK'
    elif opts.update:
        command = 'UPDATE'
    elif opts.delete:
        command = 'DELETE'
    elif opts.changephrase:
        command = 'CHANGEPHRASE'

    client = TinyIDSClient(command)
    logger.info('TinyIDS Client v%s initialized' % info.version)
    logger.info('Running in mode: %s' % command)

    client.run()

    logger.debug('terminated')
예제 #4
0
파일: main.py 프로젝트: rafaelang/tinyids
def main():
    opts = cmdline.parse_client()
    config_path = os.path.abspath(opts.confpath)
    try:
        cfg = config.get_client_configuration(config_path)
    except config.ConfigFileNotFoundError:
        sys.stderr.write("ERROR: Configuration file not found: %s\n" % config_path)
        sys.stderr.flush()
        sys.exit(1)

    # Initialize logging
    logger = logging.getLogger()
    if opts.debug:
        applogger.init_std_stream_loggers(verbose=True)
        logger.debug("tinyids started in debug mode")
    else:
        applogger.init_std_stream_loggers()

    logger.debug("Using client configuration from: %s" % config_path)
    logger.debug("Logging to standard streams: STDOUT, STDERR")

    command = None
    if opts.test:
        command = "TEST"
    if opts.check:
        command = "CHECK"
    elif opts.update:
        command = "UPDATE"
    elif opts.delete:
        command = "DELETE"
    elif opts.changephrase:
        command = "CHANGEPHRASE"

    client = TinyIDSClient(command)
    logger.info("TinyIDS Client v%s initialized" % info.version)
    logger.info("Running in mode: %s" % command)

    client.run()

    logger.debug("terminated")