Skip to content

Commit 4ba6ca2

Browse files
committed
transport: Renamed misleading is_multi to should_switch_transport in the proxy and in its init
Signed-off-by: Hofi <[email protected]>
1 parent e51a2ec commit 4ba6ca2

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

lib/transport/transport-socket-proxy.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ _parse_proxy_header(LogTransportSocketProxy *self)
316316
static LogTransport *
317317
_active_log_transport(LogTransportSocketProxy *self)
318318
{
319-
return (self->is_multi ?
319+
return (self->should_switch_transport ?
320320
&((MultiTransport *)self->base_transport)->super :
321321
self->base_transport);
322322
}
@@ -325,7 +325,7 @@ static LogTransportSocket *
325325
_active_log_transport_socket(LogTransportSocketProxy *self)
326326
{
327327
LogTransport *active_log_transport = _active_log_transport(self);
328-
return (self->is_multi ?
328+
return (self->should_switch_transport ?
329329
(LogTransportSocket *) ((MultiTransport *)active_log_transport)->active_transport :
330330
(LogTransportSocket *) active_log_transport);
331331
}
@@ -548,7 +548,7 @@ _proccess_proxy_header(LogTransportSocketProxy *self)
548548
if (parsable)
549549
{
550550
msg_trace("PROXY protocol header parsed successfully");
551-
if (self->is_multi && !_switch_to_tls(self))
551+
if (self->should_switch_transport && !_switch_to_tls(self))
552552
return FALSE;
553553
return TRUE;
554554
}
@@ -606,12 +606,12 @@ log_transport_socket_proxy_free(LogTransportSocketProxy *self)
606606
}
607607

608608
LogTransportSocketProxy *
609-
log_transport_socket_proxy_new(LogTransport *base_transport, gboolean is_multi)
609+
log_transport_socket_proxy_new(LogTransport *base_transport, gboolean should_switch_transport)
610610
{
611611
LogTransportSocketProxy *self = g_new0(LogTransportSocketProxy, 1);
612612

613613
self->base_transport = base_transport;
614-
self->is_multi = is_multi;
614+
self->should_switch_transport = should_switch_transport;
615615

616616
/* As the proxy is presented now only in LogTransportSocket (not in LogTransport :( )
617617
* we cannot simply manipulate the MultiTransport read/write because in that case we do not have

lib/transport/transport-socket-proxy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct _LogTransportSocketProxy
3939
LogTransport *base_transport;
4040
gssize (*base_read)(LogTransport *self, gpointer buf, gsize count, LogTransportAuxData *aux);
4141
gssize (*base_write)(LogTransport *self, const gpointer buf, gsize count);
42-
gboolean is_multi;
42+
gboolean should_switch_transport;
4343

4444
/* Info received from the proxy that should be added as LogTransportAuxData to
4545
* any message received through this server instance. */

modules/afsocket/transport-mapper-inet.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ _construct_multitransport_with_tls_factory(TransportMapperInet *self, gint fd)
9393
}
9494

9595
static LogTransport *
96-
_construct_tls_transport(TransportMapperInet *self, gint fd)
96+
_construct_tls_or_multi_transport(TransportMapperInet *self, gboolean create_multi_transport, gint fd)
9797
{
98-
if (self->super.create_multitransport)
98+
if (create_multi_transport)
9999
return _construct_multitransport_with_tls_factory(self, fd);
100100

101101
TLSSession *tls_session = tls_context_setup_session(self->tls_context);
@@ -127,9 +127,9 @@ _construct_multitransport_with_plain_and_tls_factories(TransportMapperInet *self
127127
}
128128

129129
static LogTransport *
130-
_construct_plain_tcp_transport(TransportMapperInet *self, gint fd)
130+
_construct_plain_tcp_or_multi_transport(TransportMapperInet *self, gboolean create_multi_transport, gint fd)
131131
{
132-
if (self->super.create_multitransport)
132+
if (create_multi_transport)
133133
return _construct_multitransport_with_plain_tcp_factory(self, fd);
134134

135135
if (self->super.sock_type == SOCK_DGRAM)
@@ -143,25 +143,25 @@ transport_mapper_inet_construct_log_transport(TransportMapper *s, gint fd)
143143
{
144144
TransportMapperInet *self = (TransportMapperInet *) s;
145145

146-
gboolean is_multi = FALSE;
146+
gboolean proxy_should_switch_transport = FALSE;
147147
LogTransport *transport = NULL;
148148

149149
if (self->tls_context && _is_tls_required(self))
150150
{
151-
transport = _construct_tls_transport(self, fd);
151+
transport = _construct_tls_or_multi_transport(self, self->super.create_multitransport, fd);
152152
}
153153
else if (self->tls_context)
154154
{
155-
is_multi = TRUE;
155+
proxy_should_switch_transport = TRUE;
156156
transport = _construct_multitransport_with_plain_and_tls_factories(self, fd);
157157
}
158158
else
159159
{
160-
transport = _construct_plain_tcp_transport(self, fd);
160+
transport = _construct_plain_tcp_or_multi_transport(self, self->super.create_multitransport, fd);
161161
}
162162

163163
if (self->proxied)
164-
log_transport_socket_proxy_new(transport, is_multi);
164+
log_transport_socket_proxy_new(transport, proxy_should_switch_transport);
165165

166166
return transport;
167167
}
@@ -411,7 +411,7 @@ transport_mapper_network_apply_transport(TransportMapper *s, GlobalConfig *cfg)
411411
self->super.sock_type = SOCK_STREAM;
412412
self->super.sock_proto = IPPROTO_TCP;
413413
self->proxied = TRUE;
414-
self->super.transport_name = g_strdup("rfc3164+proxied-tcp"); // ???
414+
self->super.transport_name = g_strdup("rfc3164+proxied-tcp");
415415
}
416416
else if (strcasecmp(transport, "tls") == 0)
417417
{
@@ -437,7 +437,7 @@ transport_mapper_network_apply_transport(TransportMapper *s, GlobalConfig *cfg)
437437
self->super.sock_proto = IPPROTO_TCP;
438438
self->proxied = TRUE;
439439
self->allow_tls = TRUE;
440-
self->super.transport_name = g_strdup("rfc3164+proxied-tls-passthrough"); // ???
440+
self->super.transport_name = g_strdup("rfc3164+proxied-tls-passthrough");
441441
}
442442
else
443443
{
@@ -510,7 +510,7 @@ transport_mapper_syslog_apply_transport(TransportMapper *s, GlobalConfig *cfg)
510510
self->super.sock_type = SOCK_STREAM;
511511
self->super.sock_proto = IPPROTO_TCP;
512512
self->proxied = TRUE;
513-
self->super.transport_name = g_strdup("rfc6587+proxied-tcp"); // ???
513+
self->super.transport_name = g_strdup("rfc6587+proxied-tcp");
514514
}
515515
else if (strcasecmp(transport, "tls") == 0)
516516
{
@@ -536,7 +536,7 @@ transport_mapper_syslog_apply_transport(TransportMapper *s, GlobalConfig *cfg)
536536
self->super.sock_proto = IPPROTO_TCP;
537537
self->proxied = TRUE;
538538
self->require_tls = TRUE;
539-
self->super.transport_name = g_strdup("rfc5424+proxied-tls"); // ???
539+
self->super.transport_name = g_strdup("rfc5424+proxied-tls");
540540
}
541541
else if (strcasecmp(transport, "proxied-tls-passthrough") == 0)
542542
{
@@ -546,7 +546,7 @@ transport_mapper_syslog_apply_transport(TransportMapper *s, GlobalConfig *cfg)
546546
self->super.sock_proto = IPPROTO_TCP;
547547
self->proxied = TRUE;
548548
self->allow_tls = TRUE;
549-
self->super.transport_name = g_strdup("rfc5424+proxied-tls-passthrough"); // ???
549+
self->super.transport_name = g_strdup("rfc5424+proxied-tls-passthrough");
550550
}
551551
else
552552
{

0 commit comments

Comments
 (0)