예제 #1
0
    def setUp(self):
        logger = logging.getLogger()
        logger.level = logging.DEBUG
        self.log_file = tempfile.NamedTemporaryFile()

        logger.addHandler(logging.FileHandler(self.log_file.name))
        logger.addHandler(logging.StreamHandler(sys.stdout))

        self.chewie = Chewie('lo', logger, auth_handler, failure_handler,
                             logoff_handler, '127.0.0.1', 1812, 'SECRET',
                             '44:44:44:44:44:44')
        self.fake_scheduler = FakeTimerScheduler()
        self.chewie.timer_scheduler = self.fake_scheduler

        global FROM_SUPPLICANT  # pylint: disable=global-statement
        global TO_SUPPLICANT  # pylint: disable=global-statement
        global FROM_RADIUS  # pylint: disable=global-statement
        global TO_RADIUS  # pylint: disable=global-statement
        global FROM_SUPPLICANT_ACTIVITY  # pylint: disable=global-statement

        FROM_SUPPLICANT = Queue()
        FROM_SUPPLICANT_ACTIVITY = Queue()
        TO_SUPPLICANT = Queue()
        FROM_RADIUS = Queue()
        TO_RADIUS = Queue()
예제 #2
0
 def _create_dot1x_speaker(self, dot1x_intf, chewie_id, radius_ip,
                           radius_port, radius_secret):
     chewie = Chewie(  # pylint: disable=too-many-function-args
         dot1x_intf, self.logger, self.auth_handler, self.failure_handler,
         self.logoff_handler, radius_ip, radius_port, radius_secret,
         chewie_id)
     hub.spawn(chewie.run)
     return chewie
예제 #3
0
    def start_chewie(self):
        """Start Chewie Server"""

        self.chewie_pid = os.fork()
        if self.chewie_pid == 0:
            file = open(os.path.join(self.current_log_dir + "chewie.log"), 'w+')
            logger = get_logger('CHEWIE', file)
            logger.info('Starting chewie.')
            chewie = Chewie(CHEWIE_SUPPLICANT.name, logger, auth_handler,
                            failure_handler, logoff_handler,
                            radius_server_ip=RADIUS_IP, radius_server_secret=RADIUS_SECRET)
            chewie.run()
예제 #4
0
파일: __main__.py 프로젝트: cglewis/chewie
def main():
    """Chewie main function, configure and start a chewie process"""

    parser = argparse.ArgumentParser(
        description='Run Chewie 802.1x Authenticator independently of '
        'Faucet SDN Controller')

    parser.add_argument(
        '-i',
        '--interface',
        dest='interface',
        help='Set the interface for Chewie to listen on - Default: eth0',
        default="eth0")
    parser.add_argument(
        '-ri',
        '--radius_ip',
        dest='radius_ip',
        help=
        'Set the IP Address for the RADIUS Server that Chewie will forward requests to '
        '- DEFAULT: 127.0.0.1',
        default='127.0.0.1')
    parser.add_argument(
        '-rs',
        '--radius_secret',
        dest='radius_secret',
        help=
        'Set the Secret used for connecting to the RADIUS Server - Default: SECRET',
        default='SECRET')
    args = parser.parse_args()

    logger = get_logger("CHEWIE")
    logger.info('Starting Chewie...')

    chewie = Chewie(args.interface,
                    logger,
                    auth_handler,
                    failure_handler,
                    logoff_handler,
                    radius_server_ip=args.radius_ip,
                    radius_server_secret=args.radius_secret)
    chewie.run()
예제 #5
0
 def setUp(self):
     self.chewie = Chewie('lo', FakeLogger('logger name'),
                          None, None, None,
                          '127.0.0.1', 1812, 'SECRET',
                          '44:44:44:44:44:44')
예제 #6
0
 def _create_dot1x_speaker(self):
     chewie = Chewie(self.dot1x_intf, self.CREDENTIALS, self.logger,
                     self.auth_handler,
                     MacAddress.from_string('00:00:00:00:00:01'))
     hub.spawn(chewie.run)
     return chewie
예제 #7
0
import socket
import struct
from select import select
from fcntl import ioctl
from netils import build_byte_string

from chewie.chewie import Chewie


class Logger:
    def info(self, message):
        print("INFO: %s" % message)

    def warning(self, message):
        print("WARNING: %s" % message)


def auth_handler(address, group_address):
    print("Authed address %s on port %s" % (str(address), str(group_address)))


credentials = {"*****@*****.**": "microphone"}
chewie = Chewie("eth0", credentials, Logger(), auth_handler)
chewie.run()
예제 #8
0
        ch.setFormatter(formatter)
        logger.addHandler(ch)
    return logger


def auth_handler(address, group_address):
    print("Authed address %s on port %s" % (str(address), str(group_address)))


def failure_handler(address, group_address):
    print("failure of address %s on port %s" %
          (str(address), str(group_address)))


def logoff_handler(address, group_address):
    print("logoff of address %s on port %s" %
          (str(address), str(group_address)))


logger = get_logger("CHEWIE")
logger.info('starting chewieeeee.')

chewie = Chewie("eth1",
                logger,
                auth_handler,
                failure_handler,
                logoff_handler,
                radius_server_ip="172.24.0.113",
                radius_server_secret="SECRET")
chewie.run()