AddAnyPortMapping(): support wildcard in NewExternalPort

supported wildcard is either 0 or *
This commit is contained in:
Thomas Bernard 2020-06-20 16:35:31 +02:00
parent de71eef493
commit 686b41fc52
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 5 additions and 2 deletions

View File

@ -615,9 +615,12 @@ AddAnyPortMapping(struct upnphttp * h, const char * action, const char * ns)
return;
}
eport = (unsigned short)atoi(ext_port);
eport = (0 == strcmp(ext_port, "*")) ? 0 : (unsigned short)atoi(ext_port);
if (eport == 0) {
eport = 1024 + ((random() & 0x7ffffffL) % (65536-1024));
}
iport = (unsigned short)atoi(int_port);
if(iport == 0 || !is_numeric(ext_port)) {
if(iport == 0 || (!is_numeric(ext_port) && 0 != strcmp(ext_port, "*"))) {
ClearNameValueList(&data);
SoapError(h, 402, "Invalid Args");
return;