Skip to content

Commit dee1b62

Browse files
d12fkdsommers
authored andcommitted
fix occ proto strings
There are two things addressed here. 1) regression introduced by commit f1bdbe5: Since TCP is not an alias for TCPv4 anymore the occ string contained TCP_CLIENT as proto, which is not understood by peers. Since only the "v4" version of the proto strings are understood the code was simplified. 2) wrong occ proto string for TCP servers: Servers were also sending out the proto with client suffix. Fixed by passing in a boolean and returning the server version if true. Also renamed the method to reflect better what it is used for. Signed-off-by: Heiko Hund <heiko@openvpn.net>
1 parent cbbe9d1 commit dee1b62

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

openvpn/ssl/proto.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ namespace openvpn {
803803
out << ",dev-type " << layer.dev_type();
804804
out << ",link-mtu " << tun_mtu + link_mtu_adjust() + l2extra;
805805
out << ",tun-mtu " << tun_mtu + l2extra;
806-
out << ",proto " << protocol.str_client(true);
806+
out << ",proto " << protocol.occ_str(server);
807807

808808
{
809809
const char *compstr = comp_ctx.options_string();

openvpn/transport/protocol.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,28 +245,24 @@ namespace openvpn {
245245
}
246246
}
247247

248-
const char *str_client(const bool force_ipv4) const
248+
// OpenVPN has always sent UDPv4, TCPv4_* over the wire.
249+
// Keep all strings v4 for backward compatibility.
250+
const char *occ_str(const bool server) const
249251
{
250252
switch (type_)
251253
{
252254
case UDP:
253-
return "UDP";
254255
case UDPv4:
255-
return "UDPv4";
256256
case UDPv6:
257-
return force_ipv4 ? "UDPv4" : "UDPv6";
257+
return "UDPv4";
258258
case TCP:
259-
return "TCP_CLIENT";
260259
case TCPv4:
261-
return "TCPv4_CLIENT";
262260
case TCPv6:
263-
return force_ipv4 ? "TCPv4_CLIENT" : "TCPv6_CLIENT";
261+
return server ? "TCPv4_SERVER" : "TCPv4_CLIENT";
264262
case TLS:
265-
return "TLS";
266263
case TLSv4:
267-
return "TLSv4";
268264
case TLSv6:
269-
return force_ipv4 ? "TLSv4" : "TLSv6";
265+
return "TLSv4";
270266
default:
271267
return "UNDEF_PROTO";
272268
}

0 commit comments

Comments
 (0)