2019-07-27 22:44:32 +08:00
|
|
|
|
// DnsGateway.cpp : 定义控制台应用程序的入口点。
|
2015-07-13 16:28:09 +08:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "configure.h"
|
|
|
|
|
#include "service_main.h"
|
|
|
|
|
|
|
|
|
|
static SERVICE *__service;
|
|
|
|
|
|
2019-05-24 16:59:47 +08:00
|
|
|
|
static const char *__conf_file = "dgate.cf";
|
2015-07-13 16:28:09 +08:00
|
|
|
|
|
|
|
|
|
static void init(void)
|
|
|
|
|
{
|
|
|
|
|
acl_socket_init();
|
|
|
|
|
conf_load(__conf_file);
|
2019-05-24 16:59:47 +08:00
|
|
|
|
|
|
|
|
|
printf("local port: %d\r\n", var_cfg_server_port);
|
|
|
|
|
|
2015-07-13 16:28:09 +08:00
|
|
|
|
//acl_msg_open("dgate.log", "dgate");
|
|
|
|
|
acl_msg_stdout_enable(1);
|
2019-05-24 16:59:47 +08:00
|
|
|
|
|
|
|
|
|
__service = service_create("0.0.0.0", (short) var_cfg_server_port,
|
|
|
|
|
var_cfg_dns_neighbor_ip, var_cfg_dns_neighbor_port);
|
|
|
|
|
|
2015-07-13 16:28:09 +08:00
|
|
|
|
printf("neighbor dns_ip: %s, dns_port: %d\r\n",
|
|
|
|
|
var_cfg_dns_neighbor_ip, var_cfg_dns_neighbor_port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void run(void)
|
|
|
|
|
{
|
|
|
|
|
service_start(__service);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void usage(const char *procname)
|
|
|
|
|
{
|
|
|
|
|
printf("usage: %s -h [help] -f conf_file\r\n", procname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
char ch;
|
|
|
|
|
|
|
|
|
|
while ((ch = getopt(argc, argv, "hf:")) > 0) {
|
|
|
|
|
switch (ch) {
|
|
|
|
|
case 'h':
|
|
|
|
|
usage(argv[0]);
|
2019-05-24 16:59:47 +08:00
|
|
|
|
return 0;
|
2015-07-13 16:28:09 +08:00
|
|
|
|
case 'f':
|
|
|
|
|
__conf_file = acl_mystrdup(optarg);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
run();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|