-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: return formerr when recv malformed packet.
- Loading branch information
Showing
8 changed files
with
143 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,18 +177,28 @@ static void _help(void) | |
printf("%s", help); | ||
} | ||
|
||
static void _show_version(void) | ||
static void _smartdns_get_version(char *str_ver, int str_ver_len) | ||
{ | ||
char str_ver[256] = {0}; | ||
char commit_ver[TMP_BUFF_LEN_32] = {0}; | ||
#ifdef COMMIT_VERION | ||
snprintf(commit_ver, sizeof(commit_ver), " (%s)", COMMIT_VERION); | ||
#endif | ||
|
||
#ifdef SMARTDNS_VERION | ||
const char *ver = SMARTDNS_VERION; | ||
snprintf(str_ver, sizeof(str_ver), "%s", ver); | ||
snprintf(str_ver, str_ver_len, "%s%s", ver, commit_ver); | ||
#else | ||
struct tm tm; | ||
get_compiled_time(&tm); | ||
snprintf(str_ver, sizeof(str_ver), "1.%.4d%.2d%.2d-%.2d%.2d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
tm.tm_hour, tm.tm_min); | ||
snprintf(str_ver, str_ver_len, "1.%.4d%.2d%.2d-%.2d%.2d%s", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
tm.tm_hour, tm.tm_min, commit_ver); | ||
#endif | ||
} | ||
|
||
static void _show_version(void) | ||
{ | ||
char str_ver[256] = {0}; | ||
_smartdns_get_version(str_ver, sizeof(str_ver)); | ||
printf("smartdns %s\n", str_ver); | ||
} | ||
|
||
|
@@ -618,14 +628,16 @@ static int _smartdns_init_load_from_resolv(void) | |
static int _smartdns_init(void) | ||
{ | ||
int ret = 0; | ||
char str_ver[256] = {0}; | ||
|
||
if (_smartdns_init_log() != 0) { | ||
tlog(TLOG_ERROR, "init log failed."); | ||
goto errout; | ||
} | ||
|
||
tlog(TLOG_NOTICE, "smartdns starting...(Copyright (C) Nick Peng <[email protected]>, build: %s %s)", __DATE__, | ||
__TIME__); | ||
_smartdns_get_version(str_ver, sizeof(str_ver)); | ||
|
||
tlog(TLOG_NOTICE, "smartdns starting...(Copyright (C) Nick Peng <[email protected]>, build: %s)", str_ver); | ||
|
||
if (dns_timer_init() != 0) { | ||
tlog(TLOG_ERROR, "init timer failed."); | ||
|