connect_ports: use sblist
This commit is contained in:
parent
e929e81a55
commit
487f2aba47
@ -99,7 +99,7 @@ struct config_s {
|
|||||||
/*
|
/*
|
||||||
* Store the list of port allowed by CONNECT.
|
* Store the list of port allowed by CONNECT.
|
||||||
*/
|
*/
|
||||||
vector_t connect_ports;
|
sblist *connect_ports;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map of headers which should be let through when the
|
* Map of headers which should be let through when the
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
* Now, this routine adds a "port" to the list. It also creates the list if
|
* Now, this routine adds a "port" to the list. It also creates the list if
|
||||||
* it hasn't already by done.
|
* it hasn't already by done.
|
||||||
*/
|
*/
|
||||||
void add_connect_port_allowed (int port, vector_t *connect_ports)
|
void add_connect_port_allowed (int port, sblist **connect_ports)
|
||||||
{
|
{
|
||||||
if (!*connect_ports) {
|
if (!*connect_ports) {
|
||||||
*connect_ports = vector_create ();
|
*connect_ports = sblist_new (sizeof(int), 16);
|
||||||
if (!*connect_ports) {
|
if (!*connect_ports) {
|
||||||
log_message (LOG_WARNING,
|
log_message (LOG_WARNING,
|
||||||
"Could not create a list of allowed CONNECT ports");
|
"Could not create a list of allowed CONNECT ports");
|
||||||
@ -38,7 +38,7 @@ void add_connect_port_allowed (int port, vector_t *connect_ports)
|
|||||||
|
|
||||||
log_message (LOG_INFO,
|
log_message (LOG_INFO,
|
||||||
"Adding Port [%d] to the list allowed by CONNECT", port);
|
"Adding Port [%d] to the list allowed by CONNECT", port);
|
||||||
vector_append (*connect_ports, &port, sizeof (port));
|
sblist_add (*connect_ports, &port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -47,7 +47,7 @@ void add_connect_port_allowed (int port, vector_t *connect_ports)
|
|||||||
* Returns: 1 if allowed
|
* Returns: 1 if allowed
|
||||||
* 0 if denied
|
* 0 if denied
|
||||||
*/
|
*/
|
||||||
int check_allowed_connect_ports (int port, vector_t connect_ports)
|
int check_allowed_connect_ports (int port, sblist *connect_ports)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int *data;
|
int *data;
|
||||||
@ -59,8 +59,8 @@ int check_allowed_connect_ports (int port, vector_t connect_ports)
|
|||||||
if (!connect_ports)
|
if (!connect_ports)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i != (size_t) vector_length (connect_ports); ++i) {
|
for (i = 0; i < sblist_getsize (connect_ports); ++i) {
|
||||||
data = (int *) vector_getentry (connect_ports, i, NULL);
|
data = sblist_get (connect_ports, i);
|
||||||
if (data && *data == port)
|
if (data && *data == port)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ int check_allowed_connect_ports (int port, vector_t connect_ports)
|
|||||||
/**
|
/**
|
||||||
* Free a connect_ports list.
|
* Free a connect_ports list.
|
||||||
*/
|
*/
|
||||||
void free_connect_ports_list (vector_t connect_ports)
|
void free_connect_ports_list (sblist *connect_ports)
|
||||||
{
|
{
|
||||||
vector_delete (connect_ports);
|
sblist_free (connect_ports);
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
#define _TINYPROXY_CONNECT_PORTS_H_
|
#define _TINYPROXY_CONNECT_PORTS_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "vector.h"
|
#include "sblist.h"
|
||||||
|
|
||||||
extern void add_connect_port_allowed (int port, vector_t *connect_ports);
|
extern void add_connect_port_allowed (int port, sblist **connect_ports);
|
||||||
int check_allowed_connect_ports (int port, vector_t connect_ports);
|
int check_allowed_connect_ports (int port, sblist *connect_ports);
|
||||||
void free_connect_ports_list (vector_t connect_ports);
|
void free_connect_ports_list (sblist *connect_ports);
|
||||||
|
|
||||||
#endif /* _TINYPROXY_CONNECT_PORTS_ */
|
#endif /* _TINYPROXY_CONNECT_PORTS_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user