import os import iptc from .drawbridge import DrawBridge from .net_queue import NetQueue def is_root(): return os.geteuid() == 0 def check_nfqueue(): try: import nfqueue return True except ImportError: return False def check_iptables(): try: iptc.Table(iptc.Table.FILTER) return True except iptc.ip4tc.IPTCError: return False def check_requirements(): if not is_root(): raise RuntimeError("Must be run as root") if not check_nfqueue(): raise RuntimeError("nfqueue is not installed or is not supported on your platform") if not check_iptables(): raise RuntimeError("iptables not installed or is not supported on your platform") if __name__ == "__main__": check_requirements()