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-2010 OpenVPN Technologies, 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
20 *  along with this program (see the file COPYING included with this
21 *  distribution); if not, write to the Free Software Foundation, Inc.,
22 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 */
24
25#ifndef PROXY_H
26#define PROXY_H
27
28#include "buffer.h"
29#include "misc.h"
30
31#ifdef ENABLE_HTTP_PROXY
32
33/* HTTP CONNECT authentication methods */
34#define HTTP_AUTH_NONE   0
35#define HTTP_AUTH_BASIC  1
36#define HTTP_AUTH_DIGEST 2
37#define HTTP_AUTH_NTLM   3
38#define HTTP_AUTH_NTLM2  4
39#define HTTP_AUTH_N      5 /* number of HTTP_AUTH methods */
40
41struct http_proxy_options {
42  const char *server;
43  int port;
44  bool retry;
45  int timeout;
46
47# define PAR_NO  0  /* don't support any auth retries */
48# define PAR_ALL 1  /* allow all proxy auth protocols */
49# define PAR_NCT 2  /* disable cleartext proxy auth protocols */
50  int auth_retry;
51
52  const char *auth_method_string;
53  const char *auth_file;
54  const char *http_version;
55  const char *user_agent;
56};
57
58struct http_proxy_options_simple {
59  const char *server;
60  int port;
61  int auth_retry;
62};
63
64struct http_proxy_info {
65  bool defined;
66  int auth_method;
67  struct http_proxy_options options;
68  struct user_pass up;
69  char *proxy_authenticate;
70  bool queried_creds;
71};
72
73struct http_proxy_options *init_http_proxy_options_once (struct http_proxy_options **hpo,
74                                                         struct gc_arena *gc);
75
76struct http_proxy_info *http_proxy_new (const struct http_proxy_options *o);
77
78void http_proxy_close (struct http_proxy_info *hp);
79
80bool establish_http_proxy_passthru (struct http_proxy_info *p,
81				    socket_descriptor_t sd, /* already open to proxy */
82				    const char *host,       /* openvpn server remote */
83				    const int port,         /* openvpn server port */
84				    struct buffer *lookahead,
85				    volatile int *signal_received);
86
87uint8_t *make_base64_string2 (const uint8_t *str, int str_len, struct gc_arena *gc);
88uint8_t *make_base64_string (const uint8_t *str, struct gc_arena *gc);
89
90#endif /* ENABLE_HTTP_PROXY */
91
92#endif /* PROXY_H */
93