Browse Source

fix shutdown from webconsole in windows

pull/997/head
R4SAS 7 years ago
parent
commit
dde4643e77
  1. 7
      Win32/Win32App.cpp
  2. 8
      daemon/HTTPServer.cpp

7
Win32/Win32App.cpp

@ -368,6 +368,9 @@ namespace win32
void StopWin32App () void StopWin32App ()
{ {
HWND hWnd = FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd"));
if (hWnd)
PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_EXIT, 0), 0);
UnregisterClass (I2PD_WIN32_CLASSNAME, GetModuleHandle(NULL)); UnregisterClass (I2PD_WIN32_CLASSNAME, GetModuleHandle(NULL));
} }
@ -375,7 +378,7 @@ namespace win32
{ {
HWND hWnd = FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd")); HWND hWnd = FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd"));
if (hWnd) if (hWnd)
PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_GRACEFUL_SHUTDOWN, 0), 0); PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_GRACEFUL_SHUTDOWN, 0), 0);
return hWnd; return hWnd;
} }
@ -383,7 +386,7 @@ namespace win32
{ {
HWND hWnd = FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd")); HWND hWnd = FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd"));
if (hWnd) if (hWnd)
PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_STOP_GRACEFUL_SHUTDOWN, 0), 0); PostMessage (hWnd, WM_COMMAND, MAKEWPARAM(ID_STOP_GRACEFUL_SHUTDOWN, 0), 0);
return hWnd; return hWnd;
} }

8
daemon/HTTPServer.cpp

@ -908,7 +908,11 @@ namespace http {
i2p::win32::StopGracefulShutdown (); i2p::win32::StopGracefulShutdown ();
#endif #endif
} else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW) { } else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW) {
#ifndef WIN32_APP
Daemon.running = false; Daemon.running = false;
#else
i2p::win32::StopWin32App ();
#endif
} else { } else {
res.code = 400; res.code = 400;
ShowError(s, "Unknown command: " + cmd); ShowError(s, "Unknown command: " + cmd);
@ -951,8 +955,8 @@ namespace http {
if (needAuth && pass == "") { if (needAuth && pass == "") {
uint8_t random[16]; uint8_t random[16];
char alnum[] = "0123456789" char alnum[] = "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"; "abcdefghijklmnopqrstuvwxyz";
pass.resize(sizeof(random)); pass.resize(sizeof(random));
RAND_bytes(random, sizeof(random)); RAND_bytes(random, sizeof(random));
for (size_t i = 0; i < sizeof(random); i++) { for (size_t i = 0; i < sizeof(random); i++) {

Loading…
Cancel
Save