OpenVPN
proxy.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2024 OpenVPN Inc <sales@openvpn.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef PROXY_H
25 #define PROXY_H
26 
27 #include "buffer.h"
28 #include "misc.h"
29 
30 /* HTTP CONNECT authentication methods */
31 #define HTTP_AUTH_NONE 0
32 #define HTTP_AUTH_BASIC 1
33 #define HTTP_AUTH_DIGEST 2
34 /* #define HTTP_AUTH_NTLM 3 removed in OpenVPN 2.7 */
35 #define HTTP_AUTH_NTLM2 4
36 #define HTTP_AUTH_N 5 /* number of HTTP_AUTH methods */
37 
39  const char *name;
40  const char *content;
41 };
42 
43 #define MAX_CUSTOM_HTTP_HEADER 10
45  const char *server;
46  const char *port;
47 
48 #define PAR_NO 0 /* don't support any auth retries */
49 #define PAR_ALL 1 /* allow all proxy auth protocols */
50 #define PAR_NCT 2 /* disable cleartext proxy auth protocols */
52 
53  const char *auth_method_string;
54  const char *auth_file;
55  const char *auth_file_up; /* specified with --http-proxy-user-pass */
56  const char *http_version;
57  const char *user_agent;
59  bool inline_creds; /* auth_file_up is inline credentials */
60  bool first_time; /* indicates if we need to wipe user creds at the first iteration of the main loop */
61  bool nocache;
62 };
63 
65  const char *server;
66  const char *port;
68 };
69 
71  bool defined;
74  struct user_pass up;
77 };
78 
80  struct gc_arena *gc);
81 
82 struct http_proxy_info *http_proxy_new(const struct http_proxy_options *o);
83 
84 void http_proxy_close(struct http_proxy_info *hp);
85 
87  socket_descriptor_t sd, /* already open to proxy */
88  const char *host, /* openvpn server remote */
89  const char *port, /* openvpn server port */
90  struct event_timeout *server_poll_timeout,
91  struct buffer *lookahead,
92  struct signal_info *sig_info);
93 
94 uint8_t *make_base64_string2(const uint8_t *str, int str_len, struct gc_arena *gc);
95 
96 uint8_t *make_base64_string(const uint8_t *str, struct gc_arena *gc);
97 
98 #endif /* PROXY_H */
http_proxy_options::auth_file
const char * auth_file
Definition: proxy.h:54
http_proxy_options::http_version
const char * http_version
Definition: proxy.h:56
http_proxy_info::defined
bool defined
Definition: proxy.h:71
http_custom_header::name
const char * name
Definition: proxy.h:39
http_proxy_options::auth_file_up
const char * auth_file_up
Definition: proxy.h:55
http_proxy_info
Definition: proxy.h:70
http_proxy_options::auth_method_string
const char * auth_method_string
Definition: proxy.h:53
http_proxy_info::auth_method
int auth_method
Definition: proxy.h:72
http_custom_header
Definition: proxy.h:38
http_proxy_options::inline_creds
bool inline_creds
Definition: proxy.h:59
http_proxy_options::nocache
bool nocache
Definition: proxy.h:61
MAX_CUSTOM_HTTP_HEADER
#define MAX_CUSTOM_HTTP_HEADER
Definition: proxy.h:43
http_proxy_options::user_agent
const char * user_agent
Definition: proxy.h:57
http_proxy_options::auth_retry
int auth_retry
Definition: proxy.h:51
misc.h
http_proxy_options::port
const char * port
Definition: proxy.h:46
options
Definition: options.h:236
http_proxy_options::first_time
bool first_time
Definition: proxy.h:60
buffer
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
http_proxy_options::server
const char * server
Definition: proxy.h:45
http_proxy_close
void http_proxy_close(struct http_proxy_info *hp)
Definition: proxy.c:565
http_proxy_options_simple::server
const char * server
Definition: proxy.h:65
buffer.h
http_proxy_info::proxy_authenticate
char * proxy_authenticate
Definition: proxy.h:75
http_proxy_info::queried_creds
bool queried_creds
Definition: proxy.h:76
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
init_http_proxy_options_once
struct http_proxy_options * init_http_proxy_options_once(struct http_proxy_options **hpo, struct gc_arena *gc)
Definition: proxy.c:46
socket_descriptor_t
SOCKET socket_descriptor_t
Definition: syshead.h:429
http_proxy_new
struct http_proxy_info * http_proxy_new(const struct http_proxy_options *o)
Definition: proxy.c:501
make_base64_string2
uint8_t * make_base64_string2(const uint8_t *str, int str_len, struct gc_arena *gc)
Definition: proxy.c:227
signal_info
Definition: sig.h:41
http_proxy_options
Definition: proxy.h:44
http_proxy_options_simple::port
const char * port
Definition: proxy.h:66
event_timeout
Definition: interval.h:136
http_proxy_info::up
struct user_pass up
Definition: proxy.h:74
user_pass
Definition: misc.h:56
http_custom_header::content
const char * content
Definition: proxy.h:40
establish_http_proxy_passthru
bool establish_http_proxy_passthru(struct http_proxy_info *p, socket_descriptor_t sd, const char *host, const char *port, struct event_timeout *server_poll_timeout, struct buffer *lookahead, struct signal_info *sig_info)
Definition: proxy.c:642
http_proxy_options_simple
Definition: proxy.h:64
http_proxy_options_simple::auth_retry
int auth_retry
Definition: proxy.h:67
make_base64_string
uint8_t * make_base64_string(const uint8_t *str, struct gc_arena *gc)
Definition: proxy.c:238
http_proxy_options::custom_headers
struct http_custom_header custom_headers[MAX_CUSTOM_HTTP_HEADER]
Definition: proxy.h:58