Skip to content

Commit dc58f0e

Browse files
author
Scott Powell
committed
* BUG FIX: repeater remote admin, flood login should invalidate the client->out_path
1 parent f274015 commit dc58f0e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/simple_repeater/MyMesh.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void MyMesh::putNeighbour(const mesh::Identity &id, uint32_t timestamp, float sn
8282
#endif
8383
}
8484

85-
uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data) {
85+
uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood) {
8686
ClientInfo* client = NULL;
8787
if (data[0] == 0) { // blank password, just check if sender is in ACL
8888
client = acl.getClient(sender.pub_key, PUB_KEY_SIZE);
@@ -123,6 +123,10 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr
123123
}
124124
}
125125

126+
if (is_flood) {
127+
client->out_path_len = -1; // need to rediscover out_path
128+
}
129+
126130
uint32_t now = getRTCClock()->getCurrentTimeUnique();
127131
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
128132
reply_data[4] = RESP_SERVER_LOGIN_OK;
@@ -438,7 +442,7 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
438442
data[len] = 0; // ensure null terminator
439443
uint8_t reply_len;
440444
if (data[4] == 0 || data[4] >= ' ') { // is password, ie. a login request
441-
reply_len = handleLoginReq(sender, secret, timestamp, &data[4]);
445+
reply_len = handleLoginReq(sender, secret, timestamp, &data[4], packet->isRouteFlood());
442446
//} else if (data[4] == ANON_REQ_TYPE_*) { // future type codes
443447
// TODO
444448
} else {

examples/simple_repeater/MyMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
113113
#endif
114114

115115
void putNeighbour(const mesh::Identity& id, uint32_t timestamp, float snr);
116-
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data);
116+
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood);
117117
int handleRequest(ClientInfo* sender, uint32_t sender_timestamp, uint8_t* payload, size_t payload_len);
118118
mesh::Packet* createSelfAdvert();
119119

0 commit comments

Comments
 (0)