Subscribe to bytecount message from management interface

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/214/head
Selva Nair 2018-01-28 11:40:12 -05:00 committed by Samuli Seppänen
parent dd8c4dfdab
commit 105e022f7b
5 changed files with 20 additions and 0 deletions

1
main.c
View File

@ -168,6 +168,7 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
{ needok, OnNeedOk },
{ needstr, OnNeedStr },
{ echo, OnEcho },
{ bytecount,OnByteCount },
{ 0, NULL }
};
InitManagement(handler);

View File

@ -327,6 +327,11 @@ OnManagement(SOCKET sk, LPARAM lParam)
if (rtmsg_handler[echo])
rtmsg_handler[echo](c, pos + 5);
}
else if (strncmp(pos, "BYTECOUNT:", 10) == 0)
{
if (rtmsg_handler[bytecount])
rtmsg_handler[bytecount](c, pos + 10);
}
}
else if (c->manage.cmd_queue)
{

View File

@ -123,6 +123,7 @@ OnReady(connection_t *c, UNUSED char *msg)
ManagementCommand(c, "state on", NULL, regular);
ManagementCommand(c, "log all on", OnLogLine, combined);
ManagementCommand(c, "echo all on", OnEcho, combined);
ManagementCommand(c, "bytecount 5", NULL, regular);
}
@ -1157,6 +1158,16 @@ OnStop(connection_t *c, UNUSED char *msg)
}
}
/*
* Handle bytecount report from OpenVPN
* Expect bytes-in,bytes-out
*/
void OnByteCount(connection_t *c, char *msg)
{
if (!msg || sscanf(msg, "%I64u,%I64u", &c->bytes_in, &c->bytes_out) != 2)
return;
}
/*
* Break a long line into shorter segments
*/

View File

@ -39,6 +39,7 @@ void OnStop(connection_t *, char *);
void OnNeedOk(connection_t *, char *);
void OnNeedStr(connection_t *, char *);
void OnEcho(connection_t *, char *);
void OnByteCount(connection_t *, char *);
void ResetSavePasswords(connection_t *);

View File

@ -126,6 +126,8 @@ struct connection {
HWND hwndStatus;
int flags;
char *dynamic_cr; /* Pointer to buffer for dynamic challenge string received */
unsigned long long int bytes_in;
unsigned long long int bytes_out;
};
/* All options used within OpenVPN GUI */