コード例 #1
0
        static void Main(string[] args)
        {
            UmleitungServer server = new UmleitungServer();

            m_log = new m0Logger(m0Logger.m0LogDestination.LOG_CONSOLE);
            server.EnableLogging(m_log);

            if (args.Length == 0)
            {
                Console.WriteLine("[!] usage: program.exe <dnsmasq.conf>");
                return;
            }

            server.ReadMasqConfig(args[0]);
            server.DumpRunningConfig();
            server.RunConsole();
        }
コード例 #2
0
        public UmleitungManagerForm(Boolean autostart)
        {
            InitializeComponent();

            m_props                  = new UmleitungProperties();
            m_props.DebugLevel       = Properties.Settings.Default.umlDebug;
            m_props.UseCustomDns     = Properties.Settings.Default.useCustomUpstream;
            m_props.CustomDnsServers = new List <IPAddress>();

            m_log = new m0Logger(m0Logger.m0LogDestination.LOG_TEXTBOX, textLog);
            m_log.SetDebuglevel(Properties.Settings.Default.umlDebug);

            if (m_props.UseCustomDns)
            {
                try
                {
                    IPAddress ip = IPAddress.Parse(Properties.Settings.Default.upstreamDNS1);
                    m_props.CustomDnsServers.Add(ip);
                }
                catch (Exception e)
                {
                    if (!(Properties.Settings.Default.upstreamDNS1 == ""))
                    {
                        m_log.WriteLine(2, "[!] UmleitungManagerForm.ctor: failed to add upstreamDNS1: " + e.Message);
                    }
                    Properties.Settings.Default.upstreamDNS1 = "";
                    Properties.Settings.Default.Save();
                }

                try
                {
                    IPAddress ip = IPAddress.Parse(Properties.Settings.Default.upstreamDNS2);
                    m_props.CustomDnsServers.Add(ip);
                }
                catch (Exception e)
                {
                    if (!(Properties.Settings.Default.upstreamDNS2 == ""))
                    {
                        m_log.WriteLine(2, "[!] UmleitungManagerForm.ctor: failed to add upstreamDNS2: " + e.Message);
                    }
                    Properties.Settings.Default.upstreamDNS2 = "";
                    Properties.Settings.Default.Save();
                }
            }

            m_log.WriteLine(2, "[d] UmleitungManagerForm.ctor: Debug Level     = " + Properties.Settings.Default.umlDebug);
            m_log.WriteLine(2, "[d] UmleitungManagerForm.ctor: Use Custom DNS  = " + Properties.Settings.Default.useCustomUpstream);
            m_log.WriteLine(2, "[d] UmleitungManagerForm.ctor: Primary DNS     = " + Properties.Settings.Default.upstreamDNS1);
            m_log.WriteLine(2, "[d] UmleitungManagerForm.ctor: Alternate DNS   = " + Properties.Settings.Default.upstreamDNS2);

            m_server = new UmleitungServer(m_props);
            m_server.EnableLogging(m_log);

            m_server.ReadMasqConfig();
            m_server.DumpRunningConfig();

            create_main_menu();

            statusText.BackColor = Color.LightCoral;
            statusText.Text      = "Stopped";

            m_status_label = toolStripStatusLabel1;

            set_status_modified(false);
            m_server_running = false;

            if (autostart)
            {
                this.start_server();
            }
        }