Skip to content

Commit

Permalink
Always check status of automatic service
Browse files Browse the repository at this point in the history
- Remove service-only mode (start/stop service) which has not been in
  use since we moved to running the GUI as limited user.
  Also its not very useful as it does not allow any control of
  service-started daemons

- Keep CheckServiceStatus and always check the status of
automatic service.

The status of the service will be used to toggle supporting
control of persistent connections started by the service.

Signed-off-by: Selva Nair <[email protected]>
  • Loading branch information
selvanair committed Aug 8, 2022
1 parent 428ee29 commit 8f0dbbc
Show file tree
Hide file tree
Showing 29 changed files with 24 additions and 367 deletions.
5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,6 @@ silent_connection
not be shown while connecting. Warnings such as interactive service
not started or multiple config files with same name are also suppressed.

service_only
If set to "1", OpenVPN GUI's normal "Connect" and "Disconnect"
actions are changed so they start/stop the OpenVPN service instead
of launching openvpn.exe directly.

show_balloon
0: Never show any connected balloon

Expand Down
34 changes: 9 additions & 25 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
if (use_iservice && strtod(o.ovpn_version, NULL) > 2.3 && !o.silent_connection)
CheckIServiceStatus(TRUE);

CheckServiceStatus(); /* Check if automatic service is running or not */
BuildFileList();

if (!VerifyAutoConnections()) {
Expand Down Expand Up @@ -538,8 +539,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM

CreatePopupMenus(); /* Create popup menus */
ShowTrayIcon();
if (o.service_only)
CheckServiceStatus(); // Check if service is running or not

/* if '--import' was specified, do it now */
if (o.action == WM_OVPN_IMPORT && o.action_arg)
Expand Down Expand Up @@ -581,15 +580,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
else if (LOWORD(wParam) == IDM_CLOSE) {
CloseApplication(hwnd);
}
else if (LOWORD(wParam) == IDM_SERVICE_START) {
MyStartService();
}
else if (LOWORD(wParam) == IDM_SERVICE_STOP) {
MyStopService();
}
else if (LOWORD(wParam) == IDM_SERVICE_RESTART) {
MyReStartService();
}
/* rest of the handlers require a connection id */
else {
minfo.fMask = MIM_MENUDATA;
Expand Down Expand Up @@ -713,16 +703,14 @@ ShowSettingsDialog()
++page_number;

/* Proxy tab */
if (o.service_only == 0) {
psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
psp[page_number].dwFlags = PSP_DLGINDIRECT;
psp[page_number].hInstance = o.hInstance;
psp[page_number].pResource = LocalizedDialogResource(ID_DLG_PROXY);
psp[page_number].pfnDlgProc = ProxySettingsDialogFunc;
psp[page_number].lParam = 0;
psp[page_number].pfnCallback = NULL;
++page_number;
}
psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
psp[page_number].dwFlags = PSP_DLGINDIRECT;
psp[page_number].hInstance = o.hInstance;
psp[page_number].pResource = LocalizedDialogResource(ID_DLG_PROXY);
psp[page_number].pfnDlgProc = ProxySettingsDialogFunc;
psp[page_number].lParam = 0;
psp[page_number].pfnCallback = NULL;
++page_number;

/* Advanced tab */
psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
Expand Down Expand Up @@ -765,10 +753,6 @@ CloseApplication(HWND hwnd)
{
int i;

if (o.service_state == service_connected
&& ShowLocalizedMsgEx(MB_YESNO, NULL, _T("Exit OpenVPN"), IDS_NFO_SERVICE_ACTIVE_EXIT) == IDNO)
return;

/* Show a message if any non-persistent connections are active */
for (i = 0; i < o.num_configs; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion options.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ add_option(options_t *options, int i, TCHAR **p)
else if (streq(p[0], _T("service_only")) && p[1])
{
++i;
options->service_only = _ttoi(p[1]) ? 1 : 0;
PrintDebug (L"Deprecated option: '%ls' ignored.", p[0]);
}
else if (streq(p[0], _T("show_script_window")) && p[1])
{
Expand Down
1 change: 0 additions & 1 deletion options.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ typedef struct {
TCHAR log_viewer[MAX_PATH];
TCHAR editor[MAX_PATH];
DWORD silent_connection;
DWORD service_only;
DWORD iservice_admin;
DWORD show_balloon;
DWORD show_script_window;
Expand Down
1 change: 0 additions & 1 deletion registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ struct regkey_int {
{L"connectscript_timeout", &o.connectscript_timeout, 30},
{L"disconnectscript_timeout", &o.disconnectscript_timeout, 10},
{L"show_script_window", &o.show_script_window, 0},
{L"service_only", &o.service_only, 0},
{L"config_menu_view", &o.config_menu_view, CONFIG_VIEW_AUTO},
{L"popup_mute_interval", &o.popup_mute_interval, 24},
{L"disable_popup_messages", &o.disable_popup_messages, 0},
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-cs.rc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ Volby k použití explicitního nastavení namísto výchozího z registru:\n\
--allow_password\t\t: 1=Zobrazit položku Změnit heslo v menu.\n\
--allow_proxy\t\t: 1=Zobrazit nastavení proxy v menu.\n\
--show_balloon\t\t: Ukazovat upozornění: 0=Nikdy, 1=Při připojení, 2=Při připojení/obnovení spojení.\n\
--service_only\t\t: 1=Ovládat pouze službu systému.\n\
--silent_connection\t\t: 1=Nezobrazovat stav při připojování ani nekritická varování při spuštění.\n\
--show_script_window\t: 0=Nezobrazovat okno skriptu, 1=Zobrazit okno skriptu.\n\
--passphrase_attempts\t: Počet možných pokusů o zadání hesla.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-de.rc
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ Option zum Überschreiben der Registry Einstellungen:\n\
--allow_password\t\t: 1=Zeige Passwort-ändern-Menü.\n\
--allow_proxy\t\t: 1=Zeige Proxy-Einstellungsmenü.\n\
--show_balloon\t\t: 0=Nie, 1=Beim ersten Verbinden, 2=Bei jedem Wiederverbinden.\n\
--service_only\t\t: 1=Aktiviere Service-Only-Modus.\n\
--silent_connection\t\t: 1=Unterdrücke die Anzeige des Statusdialogs beim Verbinden.\n\
--show_script_window\t: 0=Unterdrücke die Anzeige des Skriptfensters, 1=Zeige es.\n\
--passphrase_attempts\t: Anzahl der erlaubten Passphrase-Versuche.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-dk.rc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ Parametre som vil tilsidesætte indstillinger i registreringsdatabasen:\n\
--allow_password\t\t: 1=Vise Ændre Password i menu.\n\
--allow_proxy\t\t: 1=Vise Proxy Innstillinger i menu.\n\
--show_balloon\t\t: 0=Aldrig, 1=under tilslutning, 2=Ved hver ""gen-tilslutning"".\n\
--service_only\t\t: 1=Aktivere ""Kun Service"" tilstand.\n\
--silent_connection\t\t: 1=ikke vise status-vindue ved tilslutning.\n\
--show_script_window\t: 0=Skjul script-vindue, 1=Vise script-vindue.\n\
--passphrase_attempts\t: Antal forbindelses-forsøg.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-en.rc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ Options to override registry settings:\n\
--allow_password\t\t: 1=Show Change Password menu item.\n\
--allow_proxy\t\t: 1=Show Proxy Settings menu.\n\
--show_balloon\t\t: 0=Never, 1=At initial connect, 2=At every reconnect.\n\
--service_only\t\t: 1=Enable Service Only mode.\n\
--silent_connection\t: 1=Do not show the status dialog while connecting or non-critical warnings at startup.\n\
--show_script_window\t: 0=Hide Script execution window, 1=Show it.\n\
--passphrase_attempts\t: Number of passphrase attempts to allow.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-es.rc
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ Opciones para sobreescribir opciones del registro:\n\
--allow_password\t\t: 1=Mostrar el menú de Cambiar Clave.\n\
--allow_proxy\t\t: 1=Mostrar el menú de Configuración del Proxy.\n\
--show_balloon\t\t: 0=Nunca, 1=En la conexión inicial, 2=En cada reconexión.\n\
--service_only\t\t: 1=Activar el modo de Solo Servicio.\n\
--silent_connection\t\t: 1=No mostrar la ventana de estado al conectar.\n\
--show_script_window\t: 0=Oculta la ventana de ejecución de Script, 1=Mostrarla.\n\
--passphrase_attempts\t: Número de intentos permitidos para la passphrase.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-fa.rc
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ Options to override registry settings:\n\
--allow_password\t\t: 1=Show Change Password menu item.\n\
--allow_proxy\t\t: 1=Show Proxy Settings menu.\n\
--show_balloon\t\t: 0=Never, 1=At initial connect, 2=At every reconnect.\n\
--service_only\t\t: 1=Enable Service Only mode.\n\
--silent_connection\t\t: 1=Do not show the status dialog while connecting or non-critical warnings at startup.\n\
--show_script_window\t: 0=Hide Script execution window, 1=Show it.\n\
--passphrase_attempts\t: Number of passphrase attempts to allow.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-fi.rc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ Rekisterin asetukset kumoavat valinnat:\n\
--allow_password\t\t: 1=Näytä salasanan vaihto valikossa.\n\
--allow_proxy\t\t: 1=Näytä välipalvelimen asetukset valikossa.\n\
--show_balloon\t\t: 0=Ei koskaan, 1=Ensimmäisen kerran yhdistettäessä, 2=Joka yhdistyksellä.\n\
--service_only\t\t: 1=Käynnistä palveluna.\n\
--silent_connection\t\t: 1=Älä näytä sovelluksen tilaa yhdistettäessä.\n\
--show_script_window\t: 0=Piilota komentojonoikkuna, 1=Älä piilota sitä.\n\
--passphrase_attempts\t: Salasanan syöttökertojen maksimimäärä\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-fr.rc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ Options pour corriger la configuration de registre:\n\
--allow_password\t\t: 1=Afficher le menu de Changement de Mot de passe.\n\
--allow_proxy\t\t: 1=Afficher le menu de la configuration du Proxy.\n\
--show_balloon\t\t: 0=Jamais, 1=A la connexion initiale, 2=A toutes les reconnexions.\n\
--service_only\t\t: 1=Activer le mode Service seul Enable.\n\
--silent_connection\t\t: 1=Ne pas ouvrir le dialogue de Statut à la connexion.\n\
--show_script_window\t: 0=Cacher la fenêtre d'exécution du script, 1=Afficher la fenêtre.\n\
--passphrase_attempts\t: Nombre de tentatives de Mot de passe permises.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-it.rc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ Opzioni per ignorare il registro di sistema:\n\
--allow_password\t\t: 1=Mostra menu modifica password.\n\
--allow_proxy\t\t: 1=Mostra menu impostazioni proxy.\n\
--show_balloon\t\t: 0=Mai, 1=Alla connessione iniziale, 2=A ogni riconnessione.\n\
--service_only\t\t: 1=Abilita la modalità solo servizio.\n\
--silent_connection\t\t: 1=Non mostrare la finestra di stato durante la connessione e avvertimenti non urgenti all'avvio.\n\
--show_script_window\t: 0=Nascondi la finestra di esecuzione dello script, 1=Mostra.\n\
--passphrase_attempts\t: Numero di tentativi permessi per la frase di sicurezza.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-jp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ OpenVPN GUIをこのまま終了しますか?"
--allow_password\t\t: 1=[パスワードの変更]メニューを表示する。\n\
--allow_proxy\t\t: 1=[プロキシ設定]メニューを表示する。\n\
--show_balloon\t\t: 0=表示しない, 1=接続時, 2=接続/再接続時\n\
--service_only\t\t: 1=サービスのみのモードを有効にする。\n\
--silent_connection\t\t: 1=接続時にステータス表示ダイアログを表示しない。\n\
--show_script_window\t: 0=スクリプト実行ウィンドウを非表示にする。1=表示する。\n\
--passphrase_attempts\t: パスフレーズの入力可能回数。\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-kr.rc
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ OpenVPN GUI를 이대로 종료 하겠습니까?"
--allow_password\t\t: 1=암호 변경 메뉴 표시\n\
--allow_proxy\t\t: 1=프락시 설정 메뉴 표시\n\
--show_balloon\t\t: 0=표시 안함, 1=접속 시, 2=모든 접속/재접속 시.\n\
--service_only\t\t: 1=서비스 전용 모드를 사용\n\
--silent_connection\t\t: 1=연결시 상태 표시 대화 상자를 표시하지 않습니다.\n\
--show_script_window\t: 0=스크립트 실행창 숨김, 1=보기.\n\
--passphrase_attempts\t: 암호 입력 시도 회수\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-nl.rc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ Instellingen die de registerinstellingen overschrijven:\n\
--allow_password\t\t: 1=""Wachtwoord wijzigen"" menu-item weergeven.\n\
--allow_proxy\t\t: 1=Menu ""Proxyinstellingen"" weergeven.\n\
--show_balloon\t\t: 0=Nooit, 1=Tijdens eerste verbinding, 2=Bij elke herverbinding.\n\
--service_only\t\t: 1=Service Only modus activeren.\n\
--silent_connection\t\t: 1=Het status-venster tijdens het verbinden verbergen.\n\
--show_script_window\t: 0=Het script uitvoer-venster verbergen, 1=Weergeven.\n\
--passphrase_attempts\t: Aantal wachtwoordpogingen.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-no.rc
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ Parametere som vil overstyre innstillinger gjort i registeret:\n\
--allow_password\t\t: 1=Vis 'Endre passord' i menyen.\n\
--allow_proxy\t\t: 1=Vis 'Proxy-innstillinger' i menyen.\n\
--show_balloon\t\t: 0=Aldri, 1=under tilkobling, 2=Ved hver til- og gjenoppkobling.\n\
--service_only\t\t: 1=Kjør kun som bakgrunnstjeneste.\n\
--silent_connection\t\t: 1=Skjul statusvindu ved tilkobling.\n\
--show_script_window\t: 0=Skjul skriptvindu, 1=Vis skriptvindu.\n\
--passphrase_attempts\t: Antall tilkoblingsforsøk.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-pl.rc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ Opcje oddalające ustawienia rejestru:\n\
--allow_password\t\t: 1=Wyświetl w menu pole Zmień Hasło.\n\
--allow_proxy\t\t: 1=Wyświetl w menu pole Pokaż Ustawienia Proxy.\n\
--show_balloon\t\t: 0=Nigdy, 1=Przy pierwszym połączeniu, 2=Przy każdym połączeniu.\n\
--service_only\t\t: 1=Aktywuj tryb Tylko Usługa (Service Only).\n\
--silent_connection\t\t: 1=Nie pokazuj okna statusu podczas łączenia.\n\
--show_script_window\t: 0=Ukryj okno wykonywania skryptu, 1=Wyświetl je.\n\
--passphrase_attempts\t: Dopuszczalna ilość prób podania hasła.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-pt.rc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ Opções para sobrescrever opções do registro:\n\
--allow_password\t\t: 1=Mostrar menu de troca de senha.\n\
--allow_proxy\t\t: 1=Mostrar menu de configurações de Proxy.\n\
--show_balloon\t\t: 0=Nunca, 1=Ao iniciar conexão, 2=Sempre que reconectar.\n\
--service_only\t\t: 1=Habilitar modo Service Only .\n\
--silent_connection\t\t: 1=Não mostrar dialogo de status quando estiver conectando.\n\
--show_script_window\t: 0=Esconder janela de execução de script, 1=Mostrar.\n\
--passphrase_attempts\t: Número de tentativas de digitação de senha.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-ru.rc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ Supported commands:\n\
--allow_password\t\t: 1=Отображать пункт меню «Сменить пароль».\n\
--allow_proxy\t\t: 1=Отображать пункт меню «Настройки прокси-сервера».\n\
--show_balloon\t\t: Показывать информационное всплывающее окно. 0=Никогда, 1=При первом подключении, 2=При каждом переподключении.\n\
--service_only\t\t: 1=Включить режим управления службой.\n\
--silent_connection\t\t: 1=Не показывать диалог состояния при подключении.\n\
--show_script_window\t: 0=Скрыть окно выполнения скрипта, 1=Показать его.\n\
--passphrase_attempts\t: Количество разрешённых попыток ввода пароля.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-se.rc
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ Parametrar som ersätter inställningar gjorda i registret:\n\
--allow_password\t\t: 1=Visa Ändra Lösenord på menyn.\n\
--allow_proxy\t\t: 1=Visa Proxy Inställningar på menyn.\n\
--show_balloon\t\t: 0=Aldrig, 1=Vid anslutning, 2=Vid varje återanslutning.\n\
--service_only\t\t: 1=Aktivera ""Service Only"" läge.\n\
--silent_connection\t\t: 1=Visa inte status fönstret under anslutning.\n\
--show_script_window\t: 0=Göm skript fönster, 1=Visa skript fönster.\n\
--passphrase_attempts\t: Antal lösenordsförsök.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-tr.rc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ Registry ayarları için:\n\
--allow_password\t\t: 1=Şifre değiştirme menü öğesini göster.\n\
--allow_proxy\t\t: 1=Proxy Ayarları menüsünü gözter.\n\
--show_balloon\t\t: 0=Hiç bir zaman, 1=Bağlantı yapılırken, 2=Bağlantı her yeniden yapıldığında.\n\
--service_only\t\t: 1=Sadece servis çalışsın, arayüz gösterilmesin.\n\
--silent_connection\t\t: 1=Bağlantı sırasında durum diyaloğu görünmesin.\n\
--show_script_window\t: 0=Betik çalıştırma penceresi görünmesin, 1=Betik çalıştırma penceresi görünsün.\n\
--passphrase_attempts\t: Kaç defa şifre giriş denemesi yapılabilir.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-ua.rc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ BEGIN
--allow_password\t\t: 1=Відобразити пункт меню Змінити пароль.\n\
--allow_proxy\t\t: 1=Відобразити меню Налаштування проксі-сервера.\n\
--show_balloon\t\t: 0=Николи, 1=У перше підключення, 2=При кожному перепідключенні.\n\
--service_only\t\t: 1=Включити режим тільки сервіси.\n\
--silent_connection\t\t: 1=Сховати вікно статусу під час підключення.\n\
--show_script_window\t: 0=Сховати вікно виконання скрипту, 1=Відобразити це вікно.\n\
--passphrase_attempts\t: Кількість спроб вводу паролю.\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-zh-hans.rc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ BEGIN
--allow_password\t\t: 1=显示「变更密码」选项。\n\
--allow_proxy\t\t: 1=显示「代理设置」选项。\n\
--show_balloon\t\t: 0=永不、1=首次连接时、2=每次重新连接时显示通知。\n\
--service_only\t\t: 1=启动「仅系统服务」模式。\n\
--silent_connection\t\t: 1=连接时,不显示状态窗口。\n\
--show_script_window\t: 0=隐藏脚本执行窗口、1=显示。\n\
--passphrase_attempts\t: 允许尝试输入密码次数。\n\
Expand Down
1 change: 0 additions & 1 deletion res/openvpn-gui-res-zh-hant.rc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ Supported commands:\n\
--allow_password\t\t: 1=顯示「變更密碼」選單。\n\
--allow_proxy\t\t: 1=顯示「Proxy 設定」選單。\n\
--show_balloon\t\t: 0=永不、1=首次連線時、2=每次重新連線時顯示通知氣球。\n\
--service_only\t\t: 1=啟動「僅有系統服務」模式。\n\
--silent_connection\t\t: 1=連線時,不顯示狀態視窗。\n\
--show_script_window\t: 0=隱藏指令碼執行視窗、1=顯示。\n\
--passphrase_attempts\t: 允許嘗試輸入密碼次數。\n\
Expand Down
Loading

0 comments on commit 8f0dbbc

Please sign in to comment.