Since a user can pass a port as well as an alias let's check for it every time.
This commit is contained in:
parent
9288797c03
commit
489d885049
17
src/main.c
17
src/main.c
@ -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 'a': opts->addressbook_path = argv[i+1]; ++i; continue;
|
||||||
case 'v': return -2;
|
case 'v': return -2;
|
||||||
case 'h': return -3;
|
case 'h': return -3;
|
||||||
default:
|
default: return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (opts->command == 'c' || opts->command == 's') {
|
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);
|
||||||
int r = inet_pton(AF_INET, opts->addr, NULL);
|
if (r == -1)
|
||||||
if (r == -1)
|
r = inet_pton(AF_INET6, opts->addr, NULL);
|
||||||
r = inet_pton(AF_INET6, opts->addr, NULL);
|
opts->is_alias_passed = r == 0;
|
||||||
opts->is_alias_passed = r == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// opts->is_alias_passed = ((opts->addr[0]>>4) & 0xf) != 0x3;
|
|
||||||
|
|
||||||
if (opts->command == '\0' || opts->addr[0] == '\0'
|
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 -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user