mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-26 18:53:41 +00:00
Fix stat_update_cb for UDP packets
This commit is contained in:
+4
-6
@@ -832,11 +832,12 @@ server_send_cb(EV_P_ ev_io *w, int revents)
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
static void
|
||||
void
|
||||
stat_update_cb()
|
||||
{
|
||||
LOGI("stat: %" PRId64 ", %" PRId64 "", tx, rx);
|
||||
ev_tstamp now = ev_time();
|
||||
if (now - last > 1.0) {
|
||||
if (now - last > 0.5) {
|
||||
send_traffic_stat(tx, rx);
|
||||
last = now;
|
||||
}
|
||||
@@ -870,10 +871,6 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
|
||||
ev_timer_again(EV_A_ & remote->recv_ctx->watcher);
|
||||
|
||||
#ifdef ANDROID
|
||||
stat_update_cb();
|
||||
#endif
|
||||
|
||||
ssize_t r = recv(remote->fd, server->buf->data, BUF_SIZE, 0);
|
||||
|
||||
if (r == 0) {
|
||||
@@ -899,6 +896,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
if (!remote->direct) {
|
||||
#ifdef ANDROID
|
||||
rx += server->buf->len;
|
||||
stat_update_cb();
|
||||
#endif
|
||||
int err = crypto->decrypt(server->buf, server->d_ctx, BUF_SIZE);
|
||||
if (err == CRYPTO_ERROR) {
|
||||
|
||||
@@ -89,6 +89,7 @@ static remote_ctx_t *new_remote(int fd, server_ctx_t *server_ctx);
|
||||
extern uint64_t tx;
|
||||
extern uint64_t rx;
|
||||
extern int vpn;
|
||||
extern void stat_update_cb();
|
||||
#endif
|
||||
|
||||
extern int verbose;
|
||||
@@ -737,6 +738,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
|
||||
#else
|
||||
#ifdef ANDROID
|
||||
rx += buf->len;
|
||||
stat_update_cb();
|
||||
#endif
|
||||
// Construct packet
|
||||
brealloc(buf, buf->len + 3, buf_size);
|
||||
|
||||
Reference in New Issue
Block a user