wget-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wget2 | Draft: CIDR support added for No Proxy. Testing Code Added (


From: @rockdaboot
Subject: Re: wget2 | Draft: CIDR support added for No Proxy. Testing Code Added (!521)
Date: Sun, 09 Apr 2023 18:24:09 +0000



Tim Rühsen started a new discussion on libwget/http.c: 
https://gitlab.com/gnuwget/wget2/-/merge_requests/521#note_1346188323

>       return 0;
>  }
>  
> +wget_vector* wget_http_get_no_proxy(void){
> +     return no_proxies;
> +}
> +
> +static bool wget_http_cidr_match(const char *cidr, struct in_addr *addr)
> +{
> +     struct in_addr network_addr;
> +     uint32_t network, test_addr, mask = 0;
> +     const char *slash_pos = strchr(cidr, '/');
> +     const char *prefix = wget_strmemdup(cidr, slash_pos - cidr);

`prefix` needs to be freed. Best move this line directly above the 
`inet_aton()` call (no need to declare variables at the top of the function, we 
can use any C99 and C11 benefits because gnulib is C11). Sometimes it is easier 
to read the code, if variables are declared at the top, though. So use it 
reasonably.

IMO it's easier to read if you declare the variables like network, test_addr, 
mask where you need them, like
```
uint32_t mask = ...
uint32_t network = ntohl(network_addr.s_addr) & mask;
uint32_t test_addr = ntohl(addr->s_addr);
return (test_addr & mask) == network;
```

-- 
Reply to this email directly or view it on GitLab: 
https://gitlab.com/gnuwget/wget2/-/merge_requests/521#note_1346188323
You're receiving this email because of your account on gitlab.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]