mirror of https://github.com/OpenVPN/openvpn-gui
Merge pull request #137 from selvanair/echo
Parse ECHO directives from openvpn Acked-by: Gert Doering <gert@greenie.muc.de>pull/160/head
commit
d7b0fcbe5b
1
main.c
1
main.c
|
@ -121,6 +121,7 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
|
||||||
{ stop, OnStop },
|
{ stop, OnStop },
|
||||||
{ needok, OnNeedOk },
|
{ needok, OnNeedOk },
|
||||||
{ needstr, OnNeedStr },
|
{ needstr, OnNeedStr },
|
||||||
|
{ echo, OnEcho },
|
||||||
{ 0, NULL }
|
{ 0, NULL }
|
||||||
};
|
};
|
||||||
InitManagement(handler);
|
InitManagement(handler);
|
||||||
|
|
5
manage.c
5
manage.c
|
@ -322,6 +322,11 @@ OnManagement(SOCKET sk, LPARAM lParam)
|
||||||
if (rtmsg_handler[needstr])
|
if (rtmsg_handler[needstr])
|
||||||
rtmsg_handler[needstr](c, pos + 9);
|
rtmsg_handler[needstr](c, pos + 9);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(pos, "ECHO:", 5) == 0)
|
||||||
|
{
|
||||||
|
if (rtmsg_handler[echo])
|
||||||
|
rtmsg_handler[echo](c, pos + 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (c->manage.cmd_queue)
|
else if (c->manage.cmd_queue)
|
||||||
{
|
{
|
||||||
|
|
33
openvpn.c
33
openvpn.c
|
@ -108,6 +108,7 @@ OnReady(connection_t *c, UNUSED char *msg)
|
||||||
{
|
{
|
||||||
ManagementCommand(c, "state on", NULL, regular);
|
ManagementCommand(c, "state on", NULL, regular);
|
||||||
ManagementCommand(c, "log all on", OnLogLine, combined);
|
ManagementCommand(c, "log all on", OnLogLine, combined);
|
||||||
|
ManagementCommand(c, "echo all on", OnEcho, combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -693,6 +694,38 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle >ECHO: request from OpenVPN management interface
|
||||||
|
* Expect msg = timestamp,message
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
OnEcho(connection_t *c, char *msg)
|
||||||
|
{
|
||||||
|
WCHAR errmsg[256];
|
||||||
|
|
||||||
|
PrintDebug(L"OnEcho with msg = %S", msg);
|
||||||
|
if (!(msg = strchr(msg, ',')))
|
||||||
|
{
|
||||||
|
PrintDebug(L"OnEcho: msg format not recognized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg++;
|
||||||
|
|
||||||
|
if (strcmp(msg, "forget-passwords") == 0)
|
||||||
|
{
|
||||||
|
DeleteSavedPasswords(c->config_name);
|
||||||
|
}
|
||||||
|
else if (strcmp(msg, "save-passwords") == 0)
|
||||||
|
{
|
||||||
|
c->flags |= (FLAG_SAVE_KEY_PASS | FLAG_SAVE_AUTH_PASS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sntprintf_0(errmsg, L"WARNING: Unknown ECHO directive '%S' ignored.", msg);
|
||||||
|
WriteStatusLog(c, L"GUI> ", errmsg, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle >PASSWORD: request from OpenVPN management interface
|
* Handle >PASSWORD: request from OpenVPN management interface
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -37,6 +37,7 @@ void OnPassword(connection_t *, char *);
|
||||||
void OnStop(connection_t *, char *);
|
void OnStop(connection_t *, char *);
|
||||||
void OnNeedOk(connection_t *, char *);
|
void OnNeedOk(connection_t *, char *);
|
||||||
void OnNeedStr(connection_t *, char *);
|
void OnNeedStr(connection_t *, char *);
|
||||||
|
void OnEcho(connection_t *, char *);
|
||||||
|
|
||||||
void ResetSavePasswords(connection_t *);
|
void ResetSavePasswords(connection_t *);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue