From 74d4d019fb093466597553dc24aab2b0028f2eba Mon Sep 17 00:00:00 2001 From: Heikki Hannikainen Date: Fri, 11 Sep 2015 08:48:12 +0300 Subject: [PATCH] Move client_t lat/lng over in live upgrade, so that m/ filter works for unvalidated clients right after live upgrade, too. --- src/accept.c | 11 +++++++++++ src/worker.c | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/accept.c b/src/accept.c index da29940..19f7279 100644 --- a/src/accept.c +++ b/src/accept.c @@ -1081,6 +1081,7 @@ static int accept_liveupgrade_single(cJSON *client, int *rxerr_map, int rxerr_ma cJSON *filter; cJSON *ibuf, *obuf; cJSON *client_heard; + cJSON *lat, *lng; unsigned addr_len; union sockaddr_u sa; char *argv[256]; @@ -1124,6 +1125,8 @@ static int accept_liveupgrade_single(cJSON *client, int *rxerr_map, int rxerr_ma ibuf = cJSON_GetObjectItem(client, "ibuf"); obuf = cJSON_GetObjectItem(client, "obuf"); client_heard = cJSON_GetObjectItem(client, "client_heard"); + lat = cJSON_GetObjectItem(client, "lat"); + lng = cJSON_GetObjectItem(client, "lng"); if (!( (fd) @@ -1283,6 +1286,14 @@ static int accept_liveupgrade_single(cJSON *client, int *rxerr_map, int rxerr_ma if (rx_errs && rx_errs->type == cJSON_Array && rxerr_map && rxerr_map_len > 0) accept_rx_err_load(c, rx_errs, rxerr_map, rxerr_map_len); + /* set client lat/lon, if they're given + */ + if (lat && lng && lat->type == cJSON_Number && lng->type == cJSON_Number) { + c->loc_known = 1; + c->lat = lat->valuedouble; + c->lng = lng->valuedouble; + } + hlog(LOG_DEBUG, "%s - Accepted live upgrade client on fd %d from %s", c->addr_loc, c->fd, c->addr_rem); /* set client socket options, return -1 on serious errors */ diff --git a/src/worker.c b/src/worker.c index e7b1a90..ced04f8 100644 --- a/src/worker.c +++ b/src/worker.c @@ -2141,6 +2141,11 @@ static struct cJSON *worker_client_json(struct client_t *c, int liveup_info) cJSON_AddNumberToObject(jc, "heard_count", c->client_heard_count); cJSON_AddNumberToObject(jc, "courtesy_count", c->client_courtesy_count); + if (c->loc_known) { + cJSON_AddNumberToObject(jc, "lat", c->lat); + cJSON_AddNumberToObject(jc, "lng", c->lng); + } + if (c->quirks_mode) cJSON_AddNumberToObject(jc, "quirks_mode", c->quirks_mode);