mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-08 08:07:10 +02:00
MINOR: connection: Use a struct ist
to store proxy_authority
This makes the code cleaner, because proxy_authority can be handled like proxy_unique_id.
This commit is contained in:
parent
002bd77a6e
commit
615f81eb5a
@ -533,9 +533,8 @@ struct connection {
|
|||||||
void (*destroy_cb)(struct connection *conn); /* callback to notify of imminent death of the connection */
|
void (*destroy_cb)(struct connection *conn); /* callback to notify of imminent death of the connection */
|
||||||
struct sockaddr_storage *src; /* source address (pool), when known, otherwise NULL */
|
struct sockaddr_storage *src; /* source address (pool), when known, otherwise NULL */
|
||||||
struct sockaddr_storage *dst; /* destination address (pool), when known, otherwise NULL */
|
struct sockaddr_storage *dst; /* destination address (pool), when known, otherwise NULL */
|
||||||
char *proxy_authority; /* Value of authority TLV received via PROXYv2 */
|
struct ist proxy_authority; /* Value of the authority TLV received via PROXYv2 */
|
||||||
uint8_t proxy_authority_len; /* Length of authority TLV received via PROXYv2 */
|
struct ist proxy_unique_id; /* Value of the unique ID TLV received via PROXYv2 */
|
||||||
struct ist proxy_unique_id; /* Value of the unique ID TLV received via PROXYv2 */
|
|
||||||
struct quic_conn *qc; /* Only present if this connection is a QUIC one */
|
struct quic_conn *qc; /* Only present if this connection is a QUIC one */
|
||||||
|
|
||||||
/* used to identify a backend connection for http-reuse,
|
/* used to identify a backend connection for http-reuse,
|
||||||
|
@ -355,7 +355,7 @@ static inline void conn_init(struct connection *conn, void *target)
|
|||||||
conn->subs = NULL;
|
conn->subs = NULL;
|
||||||
conn->src = NULL;
|
conn->src = NULL;
|
||||||
conn->dst = NULL;
|
conn->dst = NULL;
|
||||||
conn->proxy_authority = NULL;
|
conn->proxy_authority = IST_NULL;
|
||||||
conn->proxy_unique_id = IST_NULL;
|
conn->proxy_unique_id = IST_NULL;
|
||||||
conn->hash_node = NULL;
|
conn->hash_node = NULL;
|
||||||
}
|
}
|
||||||
@ -553,8 +553,8 @@ static inline void conn_free(struct connection *conn)
|
|||||||
sockaddr_free(&conn->src);
|
sockaddr_free(&conn->src);
|
||||||
sockaddr_free(&conn->dst);
|
sockaddr_free(&conn->dst);
|
||||||
|
|
||||||
pool_free(pool_head_authority, conn->proxy_authority);
|
pool_free(pool_head_authority, istptr(conn->proxy_authority));
|
||||||
conn->proxy_authority = NULL;
|
conn->proxy_authority = IST_NULL;
|
||||||
|
|
||||||
pool_free(pool_head_uniqueid, istptr(conn->proxy_unique_id));
|
pool_free(pool_head_uniqueid, istptr(conn->proxy_unique_id));
|
||||||
conn->proxy_unique_id = IST_NULL;
|
conn->proxy_unique_id = IST_NULL;
|
||||||
|
@ -487,13 +487,19 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case PP2_TYPE_AUTHORITY: {
|
case PP2_TYPE_AUTHORITY: {
|
||||||
if (tlv_len > PP2_AUTHORITY_MAX)
|
const struct ist tlv = ist2((const char *)tlv_packet->value, tlv_len);
|
||||||
|
|
||||||
|
if (istlen(tlv) > PP2_AUTHORITY_MAX)
|
||||||
goto bad_header;
|
goto bad_header;
|
||||||
conn->proxy_authority = pool_alloc(pool_head_authority);
|
conn->proxy_authority = ist2(pool_alloc(pool_head_authority), 0);
|
||||||
if (conn->proxy_authority == NULL)
|
if (!isttest(conn->proxy_authority))
|
||||||
goto fail;
|
goto fail;
|
||||||
memcpy(conn->proxy_authority, (const char *)tlv_packet->value, tlv_len);
|
if (istcpy(&conn->proxy_authority, tlv, PP2_AUTHORITY_MAX) < 0) {
|
||||||
conn->proxy_authority_len = tlv_len;
|
/* This is technically unreachable, because we verified above
|
||||||
|
* that the TLV value fits.
|
||||||
|
*/
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PP2_TYPE_UNIQUE_ID: {
|
case PP2_TYPE_UNIQUE_ID: {
|
||||||
@ -1188,9 +1194,9 @@ int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connec
|
|||||||
|
|
||||||
if (srv->pp_opts & SRV_PP_V2_AUTHORITY) {
|
if (srv->pp_opts & SRV_PP_V2_AUTHORITY) {
|
||||||
value = NULL;
|
value = NULL;
|
||||||
if (remote && remote->proxy_authority) {
|
if (remote && isttest(remote->proxy_authority)) {
|
||||||
value = remote->proxy_authority;
|
value = istptr(remote->proxy_authority);
|
||||||
value_len = remote->proxy_authority_len;
|
value_len = istlen(remote->proxy_authority);
|
||||||
}
|
}
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
else {
|
else {
|
||||||
@ -1354,13 +1360,13 @@ int smp_fetch_fc_pp_authority(const struct arg *args, struct sample *smp, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->proxy_authority == NULL)
|
if (!isttest(conn->proxy_authority))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
smp->flags = 0;
|
smp->flags = 0;
|
||||||
smp->data.type = SMP_T_STR;
|
smp->data.type = SMP_T_STR;
|
||||||
smp->data.u.str.area = conn->proxy_authority;
|
smp->data.u.str.area = istptr(conn->proxy_authority);
|
||||||
smp->data.u.str.data = conn->proxy_authority_len;
|
smp->data.u.str.data = istlen(conn->proxy_authority);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user