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 },
|
{ needok, OnNeedOk },
|
||||||
{ needstr, OnNeedStr },
|
{ needstr, OnNeedStr },
|
||||||
{ echo, OnEcho },
|
{ echo, OnEcho },
|
||||||
|
{ bytecount,OnByteCount },
|
||||||
{ 0, NULL }
|
{ 0, NULL }
|
||||||
};
|
};
|
||||||
InitManagement(handler);
|
InitManagement(handler);
|
||||||
|
|
5
manage.c
5
manage.c
|
@ -327,6 +327,11 @@ OnManagement(SOCKET sk, LPARAM lParam)
|
||||||
if (rtmsg_handler[echo])
|
if (rtmsg_handler[echo])
|
||||||
rtmsg_handler[echo](c, pos + 5);
|
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)
|
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, "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);
|
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
|
* Break a long line into shorter segments
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,6 +39,7 @@ 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 OnEcho(connection_t *, char *);
|
||||||
|
void OnByteCount(connection_t *, char *);
|
||||||
|
|
||||||
void ResetSavePasswords(connection_t *);
|
void ResetSavePasswords(connection_t *);
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,8 @@ struct connection {
|
||||||
HWND hwndStatus;
|
HWND hwndStatus;
|
||||||
int flags;
|
int flags;
|
||||||
char *dynamic_cr; /* Pointer to buffer for dynamic challenge string received */
|
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 */
|
/* All options used within OpenVPN GUI */
|
||||||
|
|
Loading…
Reference in New Issue