mirror of https://github.com/OpenVPN/openvpn-gui
Subscribe to bytecount message from management interface
Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/214/head
parent
dd8c4dfdab
commit
105e022f7b
1
main.c
1
main.c
|
@ -168,6 +168,7 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
|
|||
{ needok, OnNeedOk },
|
||||
{ needstr, OnNeedStr },
|
||||
{ echo, OnEcho },
|
||||
{ bytecount,OnByteCount },
|
||||
{ 0, NULL }
|
||||
};
|
||||
InitManagement(handler);
|
||||
|
|
5
manage.c
5
manage.c
|
@ -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)
|
||||
{
|
||||
|
|
11
openvpn.c
11
openvpn.c
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
Loading…
Reference in New Issue