2017-12-29 22:15:27 +05:30
|
|
|
|
/*
|
|
|
|
|
Technitium DNS Server
|
2019-01-19 15:14:46 +05:30
|
|
|
|
Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
|
2017-12-29 22:15:27 +05:30
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using DnsServerCore;
|
|
|
|
|
using System;
|
2018-12-30 16:46:42 +05:30
|
|
|
|
using System.Threading;
|
2017-12-29 22:15:27 +05:30
|
|
|
|
|
|
|
|
|
namespace DnsServerApp
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
string configFolder = null;
|
|
|
|
|
|
|
|
|
|
if (args.Length == 1)
|
|
|
|
|
configFolder = args[0];
|
|
|
|
|
|
2019-06-29 14:00:57 +05:30
|
|
|
|
WebService service = null;
|
2017-12-29 22:15:27 +05:30
|
|
|
|
|
2018-12-30 16:46:42 +05:30
|
|
|
|
try
|
2017-12-29 22:15:27 +05:30
|
|
|
|
{
|
2019-06-29 14:00:57 +05:30
|
|
|
|
service = new WebService(configFolder, new Uri("https://go.technitium.com/?id=21"));
|
2018-12-30 16:46:42 +05:30
|
|
|
|
service.Start();
|
2017-12-29 22:15:27 +05:30
|
|
|
|
|
2018-12-30 16:46:42 +05:30
|
|
|
|
Console.WriteLine("Technitium DNS Server was started successfully.");
|
|
|
|
|
Console.WriteLine("Using config folder: " + service.ConfigFolder);
|
|
|
|
|
Console.WriteLine("");
|
2019-04-28 17:01:55 +05:30
|
|
|
|
Console.WriteLine("Note: Open http://" + service.WebServiceHostname + ":" + service.WebServicePort + "/ in web browser to access web console.");
|
2018-12-30 16:46:42 +05:30
|
|
|
|
Console.WriteLine("");
|
2019-01-19 15:14:46 +05:30
|
|
|
|
Console.WriteLine("Press [CTRL + C] to stop...");
|
2018-12-30 16:46:42 +05:30
|
|
|
|
|
2019-01-19 15:14:46 +05:30
|
|
|
|
Thread main = Thread.CurrentThread;
|
|
|
|
|
|
|
|
|
|
Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e)
|
2018-12-30 16:46:42 +05:30
|
|
|
|
{
|
2019-01-19 15:14:46 +05:30
|
|
|
|
e.Cancel = true;
|
|
|
|
|
main.Interrupt();
|
|
|
|
|
};
|
2017-12-29 22:15:27 +05:30
|
|
|
|
|
2019-01-19 15:14:46 +05:30
|
|
|
|
AppDomain.CurrentDomain.ProcessExit += delegate (object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (service != null)
|
2018-12-30 16:46:42 +05:30
|
|
|
|
{
|
2019-01-19 15:14:46 +05:30
|
|
|
|
Console.WriteLine("");
|
|
|
|
|
Console.WriteLine("Technitium DNS Server is stopping...");
|
|
|
|
|
service.Dispose();
|
|
|
|
|
service = null;
|
|
|
|
|
Console.WriteLine("Technitium DNS Server was stopped successfully.");
|
2018-12-30 16:46:42 +05:30
|
|
|
|
}
|
2019-01-19 15:14:46 +05:30
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(Timeout.Infinite);
|
2018-12-30 16:46:42 +05:30
|
|
|
|
}
|
2019-01-19 15:14:46 +05:30
|
|
|
|
catch (ThreadInterruptedException)
|
|
|
|
|
{ }
|
2018-12-30 16:46:42 +05:30
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (service != null)
|
|
|
|
|
{
|
2019-01-19 15:14:46 +05:30
|
|
|
|
Console.WriteLine("");
|
2018-12-30 16:46:42 +05:30
|
|
|
|
Console.WriteLine("Technitium DNS Server is stopping...");
|
|
|
|
|
service.Dispose();
|
2019-01-19 15:14:46 +05:30
|
|
|
|
service = null;
|
2018-12-30 16:46:42 +05:30
|
|
|
|
Console.WriteLine("Technitium DNS Server was stopped successfully.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-29 22:15:27 +05:30
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|