Ejemplo n.º 1
0
                    port = None

                if len(a2) == 2:
                    proto = a2[1]
                else:
                    proto = None

            if proto == None and port != None:
                action(host, 'tcp', port)
                action(host, 'udp', port)
            else:
                action(host, proto, port)


# begin!
config = ConfigParserPlus(DEFAULT_SETTINGS)

if len(argv) >= 2:
    SETTINGS_FILE = argv[1]

print "Loading configuration: %s" % SETTINGS_FILE
config.read(SETTINGS_FILE)

print "Setting configuration values..."
iptables.IPTABLES = config.get('tollgate', 'iptables')
iptables.INTERN_IFACE = config.get('tollgate', 'internal_iface')
iptables.EXTERN_IFACE = config.get('tollgate', 'external_iface')
iptables.CAPTIVE_RULE = config.get('tollgate', 'captive_rule')
iptables.ALLOWED_RULE = config.get('tollgate', 'allowed_rule')
iptables.UNMETERED_RULE = config.get('tollgate', 'unmetered_rule')
iptables.BLACKLIST_RULE = config.get('tollgate', 'blacklist_rule')
Ejemplo n.º 2
0
def main(daemon_enable, pid_file, settings_file=SETTINGS_FILE):
	# begin!
	config = ConfigParserPlus(DEFAULT_SETTINGS)

	print "Loading configuration: %s" % settings_file
	
	if not config.read(settings_file):
		print "Failure reading configuration file!"
		exit(1)

	print "Setting configuration values..."
	iptables.IPTABLES = config.get('tollgate', 'iptables')
	iptables.INTERN_IFACE = config.get('tollgate', 'internal_iface')
	iptables.EXTERN_IFACE = config.get('tollgate', 'external_iface')
	iptables.CAPTIVE_RULE = config.get('tollgate', 'captive_rule')
	iptables.ALLOWED_RULE = config.get('tollgate', 'allowed_rule')
	iptables.UNMETERED_RULE = config.get('tollgate', 'unmetered_rule')
	iptables.BLACKLIST_RULE = config.get('tollgate', 'blacklist_rule')
	iptables.IP4PF_RULE = config.get('tollgate', 'ip4pf_rule')
	iptables.USER_RULE_PREFIX = config.get('tollgate', 'user_rule_prefix')
	iptables.LIMIT_RULE_PREFIX = config.get('tollgate', 'limit_rule_prefix')
	iptables.REJECT_MODE = config.get('tollgate', 'reject_mode')
	iptables.REJECT_TCP_RESET = config.getboolean('tollgate', 'reject_reset_tcp')
	iptables.DEBUG = config.getboolean('tollgate', 'debug')

	iptables.CAPTIVE_ENABLED = config.getboolean('captive', 'enable')
	iptables.CAPTIVE_PORT = config.getint('captive', 'port')

	if config.has_option('tollgate', 'arp_table_size'):
		iptables.GC_THRESH = config.getint('tollgate', 'arp_table_size')

	if iptables.USER_RULE_PREFIX == iptables.LIMIT_RULE_PREFIX:
		raise Exception, "user rule prefix must be different to the limit rule prefix"

	# get unmetered firewall rules
	unmetered_hosts = None
	if config.has_section('unmetered'):
		unmetered_hosts = config.items('unmetered')

	# get blacklist
	blacklist_hosts = None
	if config.has_section('blacklist'):
		blacklist_hosts = config.items('blacklist')

	print "Creating DBUS API..."
	b = iptables.setup_dbus()

	print "Creating NAT..."
	iptables.create_nat()

	if unmetered_hosts != None:
		print "Setting unmetered hosts..."
		parse_hostlist(unmetered_hosts, iptables.add_unmetered)
	if blacklist_hosts != None:
		print "Setting blacklist hosts..."
		parse_hostlist(blacklist_hosts, iptables.add_blacklist)


	print "Starting DBUS Server (only debug messages will appear now)"
	try:
		iptables.boot_dbus(daemon_enable, b, pid_file)
	except KeyboardInterrupt:
		print "Got Control-C!"
		exit(0)
Ejemplo n.º 3
0
from subprocess import Popen, PIPE
from thread import start_new_thread

DEFAULT_CONFIG = {
    'feedbot': {
        'server': 'localhost',
        'port': DEFAULT_PORT,
        'ipv6': 'no',
        'nick': 'feedbot',
        'channel': '#test',
        'update_frequency': 300,
        'version': 'feedbot; https://github.com/micolous/ircbots/',
    }
}

config = ConfigParserPlus(DEFAULT_CONFIG)
try:
    config.readfp(open(argv[1]))
except:
    try:
        config.readfp(open('feedbot.ini'))
    except:
        print "Syntax:"
        print "  %s [config]" % argv[0]
        print ""
        print "If no configuration file is specified or there was an error, it will default to `feedbot.ini'."
        print "If there was a failure reading the configuration, it will display this message."
        exit(1)

# read config
SERVER = config.get('feedbot', 'server')
Ejemplo n.º 4
0
	geocoder = None


DEFAULT_CONFIG = {
	'twitterbot': {
		'server': 'localhost',
		'port': DEFAULT_PORT,
		'ipv6': 'no',
		'nick': 'twitterbot',
		'channel': '#test',
		'flood_cooldown': 5,
		'version': 'twitterbot; https://github.com/micolous/ircbots/',
	}
}

config = ConfigParserPlus(DEFAULT_CONFIG)
try:
	config.readfp(open(argv[1]))
except:
	try:
		config.readfp(open('twitterbot.ini'))
	except:
		print "Syntax:"
		print "  %s [config]" % argv[0]
		print ""
		print "If no configuration file is specified or there was an error, it will default to `twitterbot.ini'."
		print "If there was a failure reading the configuration, it will display this message."
		exit(1)

SERVER = config.get('twitterbot', 'server')
PORT = config.getint('twitterbot', 'port')
Ejemplo n.º 5
0
ETHICAL_STATES_COUNT = len(ETHICAL_STATES)

DEFAULT_CONFIG = {
	'ethicsbot': {
		'server': 'localhost',
		'port': DEFAULT_PORT,
		'ipv6': 'no',
		'nick': 'ethicsbot',
		'channel': '#test',
		'flood_cooldown': 5,
		'version': 'ethicsbot; https://github.com/micolous/ircbots/',
	}
}

config = ConfigParserPlus(DEFAULT_CONFIG)
try:
	config.readfp(open(argv[1]))
except:
	try:
		config.readfp(open('ethicsbot.ini'))
	except:
		print "Syntax:"
		print "  %s [config]" % argv[0]
		print ""
		print "If no configuration file is specified or there was an error, it will default to `ethicsbot.ini'."
		print "If there was a failure reading the configuration, it will display this message."
		exit(1)

# read config
SERVER = config.get('ethicsbot', 'server')
Ejemplo n.º 6
0
from Queue import Queue, Full
from libcbus import *

DEFAULT_SETTINGS = {
	'cbusbot': {
		'server': 'localhost',
		'port': 6667,
		'nick': 'cbusbot',
		'channel': 'test',
		
		'pcidev': '/dev/ttyUSB0'
	}
}


config = ConfigParserPlus(DEFAULT_SETTINGS)
try:
	config.readfp(open(argv[1]))
except:
	try:
		config.readfp(open('cbusbot.ini'))
	except:
		print "Syntax:"
		print "  %s [config]" % argv[0]
		print ""
		print "If no configuration file is specified or there was an error, it will default to `cbusbot.ini'."
		print "If there was a failure reading the configuration, it will display this message."
		exit(1)

# get version information from git
try: VERSION = config.get('cbusbot', 'version') + '; %s'
Ejemplo n.º 7
0
def main(daemon_enable, pid_file, settings_file=SETTINGS_FILE):
    # begin!
    config = ConfigParserPlus(DEFAULT_SETTINGS)

    print "Loading configuration: %s" % settings_file

    if not config.read(settings_file):
        print "Failure reading configuration file!"
        exit(1)

    print "Setting configuration values..."
    iptables.IPTABLES = config.get('tollgate', 'iptables')
    iptables.INTERN_IFACE = config.get('tollgate', 'internal_iface')
    iptables.EXTERN_IFACE = config.get('tollgate', 'external_iface')
    iptables.CAPTIVE_RULE = config.get('tollgate', 'captive_rule')
    iptables.ALLOWED_RULE = config.get('tollgate', 'allowed_rule')
    iptables.UNMETERED_RULE = config.get('tollgate', 'unmetered_rule')
    iptables.BLACKLIST_RULE = config.get('tollgate', 'blacklist_rule')
    iptables.IP4PF_RULE = config.get('tollgate', 'ip4pf_rule')
    iptables.USER_RULE_PREFIX = config.get('tollgate', 'user_rule_prefix')
    iptables.LIMIT_RULE_PREFIX = config.get('tollgate', 'limit_rule_prefix')
    iptables.REJECT_MODE = config.get('tollgate', 'reject_mode')
    iptables.REJECT_TCP_RESET = config.getboolean('tollgate',
                                                  'reject_reset_tcp')
    iptables.DEBUG = config.getboolean('tollgate', 'debug')

    iptables.CAPTIVE_ENABLED = config.getboolean('captive', 'enable')
    iptables.CAPTIVE_PORT = config.getint('captive', 'port')

    if config.has_option('tollgate', 'arp_table_size'):
        iptables.GC_THRESH = config.getint('tollgate', 'arp_table_size')

    if iptables.USER_RULE_PREFIX == iptables.LIMIT_RULE_PREFIX:
        raise Exception, "user rule prefix must be different to the limit rule prefix"

    # get unmetered firewall rules
    unmetered_hosts = None
    if config.has_section('unmetered'):
        unmetered_hosts = config.items('unmetered')

    # get blacklist
    blacklist_hosts = None
    if config.has_section('blacklist'):
        blacklist_hosts = config.items('blacklist')

    print "Creating DBUS API..."
    b = iptables.setup_dbus()

    print "Creating NAT..."
    iptables.create_nat()

    if unmetered_hosts != None:
        print "Setting unmetered hosts..."
        parse_hostlist(unmetered_hosts, iptables.add_unmetered)
    if blacklist_hosts != None:
        print "Setting blacklist hosts..."
        parse_hostlist(blacklist_hosts, iptables.add_blacklist)

    print "Starting DBUS Server (only debug messages will appear now)"
    try:
        iptables.boot_dbus(daemon_enable, b, pid_file)
    except KeyboardInterrupt:
        print "Got Control-C!"
        exit(0)
Ejemplo n.º 8
0
				else:
					port = None

				if len(a2) == 2:
					proto = a2[1]
				else:
					proto = None

			if proto == None and port != None:
				action(host, 'tcp', port)
				action(host, 'udp', port)
			else:
				action(host, proto, port)

# begin!
config = ConfigParserPlus(DEFAULT_SETTINGS)

if len(argv) >= 2:
	SETTINGS_FILE = argv[1]

print "Loading configuration: %s" % SETTINGS_FILE
config.read(SETTINGS_FILE)

print "Setting configuration values..."
iptables.IPTABLES = config.get('tollgate', 'iptables')
iptables.INTERN_IFACE = config.get('tollgate', 'internal_iface')
iptables.EXTERN_IFACE = config.get('tollgate', 'external_iface')
iptables.CAPTIVE_RULE = config.get('tollgate', 'captive_rule')
iptables.ALLOWED_RULE = config.get('tollgate', 'allowed_rule')
iptables.UNMETERED_RULE = config.get('tollgate', 'unmetered_rule')
iptables.BLACKLIST_RULE = config.get('tollgate', 'blacklist_rule')
Ejemplo n.º 9
0
		'max_messages': 25
	},
		
	'linkbot2': {
		'server': 'localhost',
		'port': DEFAULT_PORT,
		'ipv6': 'no',
		'nick': 'linkbot2',
		'channel': '#test2',
		'process_every': 1,
		'max_message_length': 512,
		'max_messages': 25
	},
}	

config = ConfigParserPlus(DEFAULT_CONFIG)
try:
	config.readfp(open(argv[1]))
except:
	try:
		config.readfp(open('linkbot.ini'))
	except:
		print "Syntax:"
		print "  %s [config]" % argv[0]
		print ""
		print "If no configuration file is specified or there was an error, it will default to `linkbot.ini'."
		print "If there was a failure reading the configuration, it will display this message."
		exit(1)

# get version information from git
try: VERSION = config.get('linkbot', 'version') + '; %s'
Ejemplo n.º 10
0
from subprocess import Popen, PIPE
from thread import start_new_thread

DEFAULT_CONFIG = {
	'feedbot': {
		'server': 'localhost',
		'port': DEFAULT_PORT,
		'ipv6': 'no',
		'nick': 'feedbot',
		'channel': '#test',
		'update_frequency': 300,
		'version': 'feedbot; https://github.com/micolous/ircbots/',
	}
}		

config = ConfigParserPlus(DEFAULT_CONFIG)
try:
	config.readfp(open(argv[1]))
except:
	try:
		config.readfp(open('feedbot.ini'))
	except:
		print "Syntax:"
		print "  %s [config]" % argv[0]
		print ""
		print "If no configuration file is specified or there was an error, it will default to `feedbot.ini'."
		print "If there was a failure reading the configuration, it will display this message."
		exit(1)

# read config
SERVER = config.get('feedbot', 'server')
Ejemplo n.º 11
0
    print "geopy isn't installed, geocoder support disabled."
    geocoder = None

DEFAULT_CONFIG = {
    'twitterbot': {
        'server': 'localhost',
        'port': DEFAULT_PORT,
        'ipv6': 'no',
        'nick': 'twitterbot',
        'channel': '#test',
        'flood_cooldown': 5,
        'version': 'twitterbot; https://github.com/micolous/ircbots/',
    }
}

config = ConfigParserPlus(DEFAULT_CONFIG)
try:
    config.readfp(open(argv[1]))
except:
    try:
        config.readfp(open('twitterbot.ini'))
    except:
        print "Syntax:"
        print "  %s [config]" % argv[0]
        print ""
        print "If no configuration file is specified or there was an error, it will default to `twitterbot.ini'."
        print "If there was a failure reading the configuration, it will display this message."
        exit(1)

SERVER = config.get('twitterbot', 'server')
PORT = config.getint('twitterbot', 'port')