mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-24 17:12:34 +02:00
use resolve_host in acl handlign too, simplificates the code
Originally committed as revision 8819 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
1840587402
commit
2bd8416e7c
14
ffserver.c
14
ffserver.c
@ -1120,7 +1120,7 @@ static int validate_acl(FFStream *stream, HTTPContext *c)
|
|||||||
enum IPAddressAction last_action = IP_DENY;
|
enum IPAddressAction last_action = IP_DENY;
|
||||||
IPAddressACL *acl;
|
IPAddressACL *acl;
|
||||||
struct in_addr *src = &c->from_addr.sin_addr;
|
struct in_addr *src = &c->from_addr.sin_addr;
|
||||||
unsigned long src_addr = ntohl(src->s_addr);
|
unsigned long src_addr = src->s_addr;
|
||||||
|
|
||||||
for (acl = stream->acl; acl; acl = acl->next) {
|
for (acl = stream->acl; acl; acl = acl->next) {
|
||||||
if (src_addr >= acl->first.s_addr && src_addr <= acl->last.s_addr) {
|
if (src_addr >= acl->first.s_addr && src_addr <= acl->last.s_addr) {
|
||||||
@ -4268,7 +4268,6 @@ static int parse_ffconfig(const char *filename)
|
|||||||
audio_id = CODEC_ID_NONE;
|
audio_id = CODEC_ID_NONE;
|
||||||
} else if (!strcasecmp(cmd, "ACL")) {
|
} else if (!strcasecmp(cmd, "ACL")) {
|
||||||
IPAddressACL acl;
|
IPAddressACL acl;
|
||||||
struct hostent *he;
|
|
||||||
|
|
||||||
get_arg(arg, sizeof(arg), &p);
|
get_arg(arg, sizeof(arg), &p);
|
||||||
if (strcasecmp(arg, "allow") == 0) {
|
if (strcasecmp(arg, "allow") == 0) {
|
||||||
@ -4283,28 +4282,21 @@ static int parse_ffconfig(const char *filename)
|
|||||||
|
|
||||||
get_arg(arg, sizeof(arg), &p);
|
get_arg(arg, sizeof(arg), &p);
|
||||||
|
|
||||||
he = gethostbyname(arg);
|
if (resolve_host(&acl.first, arg) != 0) {
|
||||||
if (!he) {
|
|
||||||
fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n",
|
fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n",
|
||||||
filename, line_num, arg);
|
filename, line_num, arg);
|
||||||
errors++;
|
errors++;
|
||||||
} else {
|
} else {
|
||||||
/* Only take the first */
|
|
||||||
acl.first.s_addr = ntohl(((struct in_addr *) he->h_addr_list[0])->s_addr);
|
|
||||||
acl.last = acl.first;
|
acl.last = acl.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
get_arg(arg, sizeof(arg), &p);
|
get_arg(arg, sizeof(arg), &p);
|
||||||
|
|
||||||
if (arg[0]) {
|
if (arg[0]) {
|
||||||
he = gethostbyname(arg);
|
if (resolve_host(&acl.last, arg) != 0) {
|
||||||
if (!he) {
|
|
||||||
fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n",
|
fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n",
|
||||||
filename, line_num, arg);
|
filename, line_num, arg);
|
||||||
errors++;
|
errors++;
|
||||||
} else {
|
|
||||||
/* Only take the first */
|
|
||||||
acl.last.s_addr = ntohl(((struct in_addr *) he->h_addr_list[0])->s_addr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user