1
0
Fork 0

Since a user can pass a port as well as an alias let's check for it every time.

This commit is contained in:
Alexander Andreev 2024-03-30 04:15:40 +04:00
parent 9288797c03
commit 489d885049
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
1 changed files with 6 additions and 11 deletions

View File

@ -265,8 +265,7 @@ int parse_argv(int argc, const char **argv, struct options *opts) {
case 'a': opts->addressbook_path = argv[i+1]; ++i; continue;
case 'v': return -2;
case 'h': return -3;
default:
return -1;
default: return -1;
}
} else {
if (opts->command == 'c' || opts->command == 's') {
@ -287,17 +286,13 @@ int parse_argv(int argc, const char **argv, struct options *opts) {
}
}
if (command_arg_num == 1) {
int r = inet_pton(AF_INET, opts->addr, NULL);
if (r == -1)
r = inet_pton(AF_INET6, opts->addr, NULL);
opts->is_alias_passed = r == 0;
}
int r = inet_pton(AF_INET, opts->addr, NULL);
if (r == -1)
r = inet_pton(AF_INET6, opts->addr, NULL);
opts->is_alias_passed = r == 0;
// opts->is_alias_passed = ((opts->addr[0]>>4) & 0xf) != 0x3;
if (opts->command == '\0' || opts->addr[0] == '\0'
|| (!opts->is_alias_passed && opts->port[0] == '\0'))
|| (!opts->is_alias_passed && opts->port == NULL))
return -1;
return 0;