2008-12-18 11:08:35 +00:00
|
|
|
/*
|
|
|
|
* OpenVPN-GUI -- A Windows GUI for OpenVPN.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Mathias Sundman <mathias@nilings.se>
|
2010-04-09 04:01:30 +00:00
|
|
|
* 2010 Heiko Hund <heikoh@users.sf.net>
|
2016-07-09 19:14:36 +00:00
|
|
|
* 2016 Selva Nair <selva.nair@gmail.com>
|
2008-12-18 11:08:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program (see the file COPYING included with this
|
|
|
|
* distribution); if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-04-09 04:01:30 +00:00
|
|
|
#ifndef OPTIONS_H
|
|
|
|
#define OPTIONS_H
|
|
|
|
|
2010-08-13 15:42:23 +00:00
|
|
|
typedef struct connection connection_t;
|
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
#include <windows.h>
|
2010-08-13 15:42:23 +00:00
|
|
|
#include <stdio.h>
|
2008-12-18 11:08:35 +00:00
|
|
|
#include <time.h>
|
2016-02-26 17:21:23 +00:00
|
|
|
#include <lmcons.h>
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2010-08-13 15:42:23 +00:00
|
|
|
#include "manage.h"
|
|
|
|
|
2016-02-26 17:21:23 +00:00
|
|
|
#define MAX_NAME (UNLEN + 1)
|
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
/*
|
|
|
|
* Maximum number of parameters associated with an option,
|
|
|
|
* including the option name itself.
|
|
|
|
*/
|
2010-04-09 04:01:30 +00:00
|
|
|
#define MAX_PARMS 5 /* May number of parameters per option */
|
|
|
|
#define MAX_CONFIG_SUBDIRS 50 /* Max number of subdirs to scan for configs */
|
|
|
|
|
|
|
|
|
2012-07-20 09:55:10 +00:00
|
|
|
typedef enum {
|
|
|
|
service_noaccess = -1,
|
|
|
|
service_disconnected = 0,
|
|
|
|
service_connecting = 1,
|
|
|
|
service_connected = 2
|
|
|
|
} service_state_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
config,
|
|
|
|
windows,
|
|
|
|
manual
|
|
|
|
} proxy_source_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
http,
|
|
|
|
socks
|
|
|
|
} proxy_t;
|
|
|
|
|
2010-04-09 04:01:30 +00:00
|
|
|
/* connection states */
|
|
|
|
typedef enum {
|
|
|
|
disconnected,
|
|
|
|
connecting,
|
|
|
|
reconnecting,
|
|
|
|
connected,
|
|
|
|
disconnecting,
|
|
|
|
suspending,
|
2013-04-25 15:53:16 +00:00
|
|
|
suspended,
|
2016-02-14 03:44:52 +00:00
|
|
|
resuming,
|
|
|
|
timedout
|
2010-04-09 04:01:30 +00:00
|
|
|
} conn_state_t;
|
2008-12-18 11:08:35 +00:00
|
|
|
|
2016-02-22 13:12:55 +00:00
|
|
|
/* Interactive Service IO parameters */
|
|
|
|
typedef struct {
|
|
|
|
OVERLAPPED o; /* This has to be the first element */
|
|
|
|
HANDLE pipe;
|
|
|
|
HANDLE hEvent;
|
|
|
|
WCHAR readbuf[512];
|
|
|
|
} service_io_t;
|
|
|
|
|
2016-02-29 03:10:14 +00:00
|
|
|
#define FLAG_ALLOW_CHANGE_PASSPHRASE (1<<1)
|
2016-10-02 18:52:13 +00:00
|
|
|
#define FLAG_SAVE_KEY_PASS (1<<4)
|
|
|
|
#define FLAG_SAVE_AUTH_PASS (1<<5)
|
2017-01-09 02:54:00 +00:00
|
|
|
#define FLAG_DISABLE_SAVE_PASS (1<<6)
|
2016-03-21 12:43:41 +00:00
|
|
|
|
2016-07-09 19:14:36 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned short major, minor, build, revision;
|
|
|
|
} version_t;
|
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
/* Connections parameters */
|
2010-08-13 15:42:23 +00:00
|
|
|
struct connection {
|
2010-04-09 04:01:30 +00:00
|
|
|
TCHAR config_file[MAX_PATH]; /* Name of the config file */
|
|
|
|
TCHAR config_name[MAX_PATH]; /* Name of the connection */
|
|
|
|
TCHAR config_dir[MAX_PATH]; /* Path to this configs dir */
|
|
|
|
TCHAR log_path[MAX_PATH]; /* Path to Logfile */
|
|
|
|
TCHAR ip[16]; /* Assigned IP address for this connection */
|
|
|
|
BOOL auto_connect; /* AutoConnect at startup id TRUE */
|
|
|
|
conn_state_t state; /* State the connection currently is in */
|
2010-08-13 15:42:23 +00:00
|
|
|
int failed_psw_attempts; /* # of failed attempts entering password(s) */
|
2010-04-09 04:01:30 +00:00
|
|
|
time_t connected_since; /* Time when the connection was established */
|
2012-07-20 09:55:10 +00:00
|
|
|
proxy_t proxy_type; /* Set during querying proxy credentials */
|
2010-04-09 04:01:30 +00:00
|
|
|
|
2010-08-13 15:42:23 +00:00
|
|
|
struct {
|
|
|
|
SOCKET sk;
|
2012-05-08 14:50:26 +00:00
|
|
|
SOCKADDR_IN skaddr;
|
|
|
|
time_t timeout;
|
2010-08-13 15:42:23 +00:00
|
|
|
char password[16];
|
2012-10-31 15:33:32 +00:00
|
|
|
char *saved_data;
|
|
|
|
size_t saved_size;
|
2010-08-13 15:42:23 +00:00
|
|
|
mgmt_cmd_t *cmd_queue;
|
2016-02-22 13:12:55 +00:00
|
|
|
BOOL connected; /* True, if management interface has connected */
|
2010-08-13 15:42:23 +00:00
|
|
|
} manage;
|
|
|
|
|
2016-02-22 13:12:55 +00:00
|
|
|
HANDLE hProcess; /* Handle of openvpn process if directly started */
|
|
|
|
service_io_t iserv;
|
|
|
|
|
2010-08-13 15:42:23 +00:00
|
|
|
HANDLE exit_event;
|
|
|
|
DWORD threadId;
|
2010-04-09 04:01:30 +00:00
|
|
|
HWND hwndStatus;
|
2016-03-21 12:43:41 +00:00
|
|
|
int flags;
|
2016-02-29 03:10:14 +00:00
|
|
|
char *dynamic_cr; /* Pointer to buffer for dynamic challenge string received */
|
2010-08-13 15:42:23 +00:00
|
|
|
};
|
2008-12-18 11:08:35 +00:00
|
|
|
|
|
|
|
/* All options used within OpenVPN GUI */
|
2010-04-09 04:01:30 +00:00
|
|
|
typedef struct {
|
|
|
|
/* Array of configs to autostart */
|
|
|
|
const TCHAR *auto_connect[MAX_CONFIGS];
|
|
|
|
|
|
|
|
/* Connection parameters */
|
|
|
|
connection_t conn[MAX_CONFIGS]; /* Connection structure */
|
|
|
|
int num_configs; /* Number of configs */
|
|
|
|
|
|
|
|
service_state_t service_state; /* State of the OpenVPN Service */
|
|
|
|
|
|
|
|
/* Proxy Settings */
|
|
|
|
proxy_source_t proxy_source; /* Where to get proxy information from */
|
|
|
|
proxy_t proxy_type; /* The type of proxy to use */
|
|
|
|
TCHAR proxy_http_address[100]; /* HTTP Proxy Address */
|
|
|
|
TCHAR proxy_http_port[6]; /* HTTP Proxy Port */
|
|
|
|
TCHAR proxy_socks_address[100]; /* SOCKS Proxy Address */
|
|
|
|
TCHAR proxy_socks_port[6]; /* SOCKS Proxy Address */
|
|
|
|
|
2016-07-06 17:38:27 +00:00
|
|
|
/* HKLM Registry values */
|
2010-04-09 04:01:30 +00:00
|
|
|
TCHAR exe_path[MAX_PATH];
|
2016-02-17 21:02:40 +00:00
|
|
|
TCHAR global_config_dir[MAX_PATH];
|
2016-07-06 17:38:27 +00:00
|
|
|
TCHAR priority_string[64];
|
|
|
|
TCHAR ovpn_admin_group[MAX_NAME];
|
2017-01-09 02:54:00 +00:00
|
|
|
DWORD disable_save_passwords;
|
2016-07-06 17:38:27 +00:00
|
|
|
/* HKCU registry values */
|
|
|
|
TCHAR config_dir[MAX_PATH];
|
2010-04-09 04:01:30 +00:00
|
|
|
TCHAR ext_string[16];
|
|
|
|
TCHAR log_dir[MAX_PATH];
|
2016-07-09 19:14:36 +00:00
|
|
|
DWORD log_append;
|
2010-04-09 04:01:30 +00:00
|
|
|
TCHAR log_viewer[MAX_PATH];
|
|
|
|
TCHAR editor[MAX_PATH];
|
2016-07-09 19:14:36 +00:00
|
|
|
DWORD silent_connection;
|
|
|
|
DWORD service_only;
|
|
|
|
DWORD show_balloon;
|
|
|
|
DWORD show_script_window;
|
|
|
|
DWORD connectscript_timeout; /* Connect Script execution timeout (sec) */
|
|
|
|
DWORD disconnectscript_timeout; /* Disconnect Script execution timeout (sec) */
|
|
|
|
DWORD preconnectscript_timeout; /* Preconnect Script execution timeout (sec) */
|
2010-04-09 04:01:30 +00:00
|
|
|
|
2008-12-18 11:08:35 +00:00
|
|
|
#ifdef DEBUG
|
2010-04-09 04:01:30 +00:00
|
|
|
FILE *debug_fp;
|
2008-12-18 11:08:35 +00:00
|
|
|
#endif
|
|
|
|
|
2010-04-09 04:01:30 +00:00
|
|
|
HWND hWnd;
|
|
|
|
HINSTANCE hInstance;
|
2013-04-25 15:53:16 +00:00
|
|
|
BOOL session_locked;
|
2016-02-26 17:21:23 +00:00
|
|
|
HANDLE netcmd_semaphore;
|
2016-07-09 19:14:36 +00:00
|
|
|
version_t version;
|
2016-11-02 02:53:26 +00:00
|
|
|
char ovpn_version[16]; /* OpenVPN version string: 2.3.12, 2.4_alpha2 etc.. */
|
2016-11-19 21:15:10 +00:00
|
|
|
unsigned int dpi_scale;
|
2010-04-09 04:01:30 +00:00
|
|
|
} options_t;
|
|
|
|
|
|
|
|
void InitOptions(options_t *);
|
|
|
|
void ProcessCommandLine(options_t *, TCHAR *);
|
|
|
|
int CountConnState(conn_state_t);
|
2010-08-13 15:42:23 +00:00
|
|
|
connection_t* GetConnByManagement(SOCKET);
|
2016-07-09 19:14:36 +00:00
|
|
|
INT_PTR CALLBACK ScriptSettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
INT_PTR CALLBACK ConnectionSettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
|
|
INT_PTR CALLBACK AdvancedSettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
2017-01-09 02:54:00 +00:00
|
|
|
void DisableSavePasswords(connection_t *);
|
2016-07-09 19:14:36 +00:00
|
|
|
|
|
|
|
void ExpandOptions(void);
|
|
|
|
int CompareStringExpanded(const WCHAR *str1, const WCHAR *str2);
|
2010-04-09 04:01:30 +00:00
|
|
|
#endif
|