Change in openvpn[master]: proxy: factor out recv_char code common with socks proxy
A message that is not in the archive (sent off-list or not yet received): gerrit.1760525463000.I70620aca638847168f06b0fb23cc04bd279d7df9@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email
to review the following change.
Change subject: proxy: factor out recv_char code common with socks proxy
......................................................................
proxy: factor out recv_char code common with socks proxy
---
M src/openvpn/proxy.c
M src/openvpn/proxy.h
M src/openvpn/socks.c
3 files changed, 65 insertions(+), 94 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/1278/1
src/openvpn/proxy.c +46 -46
@@ -57,6 +57,50 @@/* cached proxy username/password */ static struct user_pass static_proxy_user_pass; +bool +proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +const int status =openvpn_select (sd +1 , &reads,NULL ,NULL , timeout); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, (void *)c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool recv_line (socket_descriptor_t sd,char *buf,int len,const int timeout_sec,const bool verbose,struct buffer *lookahead,volatile int *signal_received)
@@ -72,9 +116,6 @@while (true) { -int status; -ssize_t size; -fd_set reads;struct timeval tv;uint8_t c;
@@ -83,50 +124,12 @@ASSERT (buf_init (&la,0 )); } -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); tv.tv_sec = timeout_sec; tv.tv_usec =0 ; - status =openvpn_select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!proxy_recv_char (&c,"recv_line" , sd, &tv, signal_received)) { - goto error; - } - -/* timeout? */ -if (status ==0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read timeout expired" ); - } - goto error; - } - -/* error */ -if (status <0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on select()" ); - } - goto error; - } - -/* read single char */ - size =recv (sd, (void *)&c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on recv()" ); - } - goto error; +return false; }#if 0
@@ -179,9 +182,6 @@ }return true; - -error: -return false; } static bool
src/openvpn/proxy.h +3 -0
@@ -80,6 +80,9 @@void http_proxy_close (struct http_proxy_info *hp); +bool proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received); + bool establish_http_proxy_passthru(struct http_proxy_info *p, socket_descriptor_t sd, /* already open to proxy */ const char *host, /* openvpn server remote */
src/openvpn/socks.c +16 -48
144 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70620aca638847168f06b0fb23cc04bd279d7df9
Gerrit-Change-Number: 1278
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email )
Change subject: proxy: factor out recv_char code common with socks proxy
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70620aca638847168f06b0fb23cc04bd279d7df9
Gerrit-Change-Number: 1278
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 16 Oct 2025 10:31:25 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v2 1/1 proxy: factor out recv_char code common with socks proxy
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1278
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1278
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/proxy.c +46 -46
@@ -57,6 +57,50 @@/* cached proxy username/password */ static struct user_pass static_proxy_user_pass; +bool +proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +const int status =openvpn_select (sd +1 , &reads,NULL ,NULL , timeout); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, (void *)c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool recv_line (socket_descriptor_t sd,char *buf,int len,const int timeout_sec,const bool verbose,struct buffer *lookahead,volatile int *signal_received)
@@ -72,9 +116,6 @@while (true) { -int status; -ssize_t size; -fd_set reads;struct timeval tv;uint8_t c;
@@ -83,50 +124,12 @@ASSERT (buf_init (&la,0 )); } -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); tv.tv_sec = timeout_sec; tv.tv_usec =0 ; - status =openvpn_select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!proxy_recv_char (&c,"recv_line" , sd, &tv, signal_received)) { - goto error; - } - -/* timeout? */ -if (status ==0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read timeout expired" ); - } - goto error; - } - -/* error */ -if (status <0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on select()" ); - } - goto error; - } - -/* read single char */ - size =recv (sd, (void *)&c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on recv()" ); - } - goto error; +return false; }#if 0
@@ -179,9 +182,6 @@ }return true; - -error: -return false; } static bool
src/openvpn/proxy.h +3 -0
@@ -80,6 +80,9 @@void http_proxy_close (struct http_proxy_info *hp); +bool proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received); + bool establish_http_proxy_passthru(struct http_proxy_info *p, socket_descriptor_t sd, /* already open to proxy */ const char *host, /* openvpn server remote */
src/openvpn/socks.c +16 -48
144 lines not on this page · raw message
[Openvpn-devel] [PATCH applied] Re: proxy: factor out recv_char code common with socks proxy
Stared-at-code, and at "git show --color-moved", ran client/server tests on the linux testbed (which excercises all the proxy variants except NTLM).
Test compiled on MinGW, BBs all green as well.
Your patch has been applied to the master branch.
commit 9443371628755b01161a4efa55f23fb67859874a
Author: Frank Lichtenheld Date: Thu Oct 16 12:31:35 2025 +0200
proxy: factor out recv_char code common with socks proxy
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1278
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59247456/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: proxy: factor out recv_char code common with socks proxy
......................................................................
proxy: factor out recv_char code common with socks proxy
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1278
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59247456/
---
M src/openvpn/proxy.c
M src/openvpn/proxy.h
M src/openvpn/socks.c
3 files changed, 65 insertions(+), 94 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/1278/3
src/openvpn/proxy.c +46 -46
@@ -57,6 +57,50 @@/* cached proxy username/password */ static struct user_pass static_proxy_user_pass; +bool +proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +const int status =openvpn_select (sd +1 , &reads,NULL ,NULL , timeout); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, (void *)c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool recv_line (socket_descriptor_t sd,char *buf,int len,const int timeout_sec,const bool verbose,struct buffer *lookahead,volatile int *signal_received)
@@ -72,9 +116,6 @@while (true) { -int status; -ssize_t size; -fd_set reads;struct timeval tv;uint8_t c;
@@ -83,50 +124,12 @@ASSERT (buf_init (&la,0 )); } -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); tv.tv_sec = timeout_sec; tv.tv_usec =0 ; - status =openvpn_select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!proxy_recv_char (&c,"recv_line" , sd, &tv, signal_received)) { - goto error; - } - -/* timeout? */ -if (status ==0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read timeout expired" ); - } - goto error; - } - -/* error */ -if (status <0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on select()" ); - } - goto error; - } - -/* read single char */ - size =recv (sd, (void *)&c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on recv()" ); - } - goto error; +return false; }#if 0
@@ -179,9 +182,6 @@ }return true; - -error: -return false; } static bool
src/openvpn/proxy.h +3 -0
@@ -80,6 +80,9 @@void http_proxy_close (struct http_proxy_info *hp); +bool proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received); + bool establish_http_proxy_passthru(struct http_proxy_info *p, socket_descriptor_t sd, /* already open to proxy */ const char *host, /* openvpn server remote */
src/openvpn/socks.c +16 -48
144 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70620aca638847168f06b0fb23cc04bd279d7df9
Gerrit-Change-Number: 1278
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email )
Change subject: proxy: factor out recv_char code common with socks proxy
......................................................................
proxy: factor out recv_char code common with socks proxy
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1278
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59247456/
---
M src/openvpn/proxy.c
M src/openvpn/proxy.h
M src/openvpn/socks.c
3 files changed, 65 insertions(+), 94 deletions(-)
src/openvpn/proxy.c +46 -46
@@ -57,6 +57,50 @@/* cached proxy username/password */ static struct user_pass static_proxy_user_pass; +bool +proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +const int status =openvpn_select (sd +1 , &reads,NULL ,NULL , timeout); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, (void *)c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool recv_line (socket_descriptor_t sd,char *buf,int len,const int timeout_sec,const bool verbose,struct buffer *lookahead,volatile int *signal_received)
@@ -72,9 +116,6 @@while (true) { -int status; -ssize_t size; -fd_set reads;struct timeval tv;uint8_t c;
@@ -83,50 +124,12 @@ASSERT (buf_init (&la,0 )); } -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); tv.tv_sec = timeout_sec; tv.tv_usec =0 ; - status =openvpn_select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!proxy_recv_char (&c,"recv_line" , sd, &tv, signal_received)) { - goto error; - } - -/* timeout? */ -if (status ==0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read timeout expired" ); - } - goto error; - } - -/* error */ -if (status <0 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on select()" ); - } - goto error; - } - -/* read single char */ - size =recv (sd, (void *)&c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -if (verbose) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_line: TCP port read failed on recv()" ); - } - goto error; +return false; }#if 0
@@ -179,9 +182,6 @@ }return true; - -error: -return false; } static bool
src/openvpn/proxy.h +3 -0
@@ -80,6 +80,9 @@void http_proxy_close (struct http_proxy_info *hp); +bool proxy_recv_char (uint8_t *c,const char *name,socket_descriptor_t sd, +struct timeval *timeout,volatile int *signal_received); + bool establish_http_proxy_passthru(struct http_proxy_info *p, socket_descriptor_t sd, /* already open to proxy */ const char *host, /* openvpn server remote */
src/openvpn/socks.c +16 -48
144 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1278?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70620aca638847168f06b0fb23cc04bd279d7df9
Gerrit-Change-Number: 1278
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>