diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-07-15 09:47:42 +0200 | 
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-07-15 09:47:42 +0200 | 
| commit | 33c957d43fe4c779d0601ff3c440c785190e3a80 (patch) | |
| tree | 87a5f5c9f173123465a6d7ad42a493b070f71348 /src/tc-socket.c | |
| parent | 1842e4ff88f93490966398ae9b763f6dba069799 (diff) | |
| parent | eac2a2cc668f491c7d265c5fe6c50f51a60c6256 (diff) | |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src/tc-socket.c')
| -rw-r--r-- | src/tc-socket.c | 31 | 
1 files changed, 30 insertions, 1 deletions
diff --git a/src/tc-socket.c b/src/tc-socket.c index 9904ba8..3cdeb90 100644 --- a/src/tc-socket.c +++ b/src/tc-socket.c @@ -12,12 +12,30 @@  #ifndef AI_V4MAPPED  #	define AI_V4MAPPED 0  #endif +#include "internal.h" -int main(void) +static int t_parse(void) +{ +	char host[32] = "bogus"; +	if (HX_addrport_split("[::1]", host, sizeof(host), nullptr) != 1 || +	    strcmp(host, "::1") != 0) +		return 1; +	if (HX_addrport_split("[]", host, sizeof(host), nullptr) != 1 || +	    strcmp(host, "") != 0) +		return 1; +	if (HX_addrport_split("", host, sizeof(host), nullptr) != 1 || +	    strcmp(host, "") != 0) +		return 1; +	return 0; +} + +static int t_local(void)  {  	static const char *addrs[] = {  		"::1", "::2", "::ffff:127.0.0.1", "::", +		"[::1]", "[::2]", "[::ffff:127.0.0.1]", "[::]",  		"127.0.0.1", "127.0.0.2", "1.1.1.1", "255.255.255.255", +		"[127.0.0.1]", "[127.0.0.2]", "[1.1.1.1]", "[255.255.255.255]",  	};  	for (size_t i = 0; i < ARRAY_SIZE(addrs); ++i) {  		char host[32] = {}; @@ -73,3 +91,14 @@ int main(void)  	}  	return EXIT_SUCCESS;  } + +int main(void) +{ +	int ret = t_parse(); +	if (ret != 0) +		return ret; +	ret = t_local(); +	if (ret != EXIT_SUCCESS) +		return ret; +	return EXIT_SUCCESS; +}  | 
