mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-29 19:03:52 +00:00
fix channel !authorized check
This commit is contained in:
parent
1fcec8ce3b
commit
49b16fdf0c
@ -85,11 +85,17 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
|
|||||||
auto ch = channels.getByIndex(mp.channel);
|
auto ch = channels.getByIndex(mp.channel);
|
||||||
assert(ch.has_settings);
|
assert(ch.has_settings);
|
||||||
|
|
||||||
|
/// We only call plugins that are interested in the packet (and the message is destined to us or we are promiscious)
|
||||||
|
bool wantsPacket = (pi.isPromiscuous || toUs) && pi.wantPacket(&mp);
|
||||||
|
|
||||||
|
if (wantsPacket) {
|
||||||
|
// DEBUG_MSG("Plugin %s wantsPacket=%d\n", pi.name, wantsPacket);
|
||||||
|
pluginFound = true;
|
||||||
|
|
||||||
/// Is the channel this packet arrived on acceptable? (security check)
|
/// Is the channel this packet arrived on acceptable? (security check)
|
||||||
bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || (strcmp(ch.settings.name, pi.boundChannel) == 0);
|
bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || (strcmp(ch.settings.name, pi.boundChannel) == 0);
|
||||||
|
|
||||||
/// We only call plugins that are interested in the packet (and the message is destined to us or we are promiscious)
|
if (!rxChannelOk) {
|
||||||
if (!rxChannelOk && toUs) {
|
|
||||||
// no one should have already replied!
|
// no one should have already replied!
|
||||||
assert(!currentReply);
|
assert(!currentReply);
|
||||||
|
|
||||||
@ -98,19 +104,18 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
|
|||||||
currentReply = pi.allocErrorResponse(Routing_Error_NOT_AUTHORIZED, &mp);
|
currentReply = pi.allocErrorResponse(Routing_Error_NOT_AUTHORIZED, &mp);
|
||||||
} else
|
} else
|
||||||
DEBUG_MSG("packet on wrong channel, but client didn't want response\n");
|
DEBUG_MSG("packet on wrong channel, but client didn't want response\n");
|
||||||
} else if ((pi.isPromiscuous || toUs) && pi.wantPacket(&mp)) {
|
} else {
|
||||||
// DEBUG_MSG("Plugin %s wantsPacket=%d\n", pi.name, wantsPacket);
|
|
||||||
pluginFound = true;
|
|
||||||
|
|
||||||
bool handled = pi.handleReceived(mp);
|
bool handled = pi.handleReceived(mp);
|
||||||
|
|
||||||
// Possibly send replies (but only if the message was directed to us specifically, i.e. not for promiscious sniffing)
|
// Possibly send replies (but only if the message was directed to us specifically, i.e. not for promiscious
|
||||||
// also: we only let the one plugin send a reply, once that happens, remaining plugins are not considered
|
// sniffing) also: we only let the one plugin send a reply, once that happens, remaining plugins are not
|
||||||
|
// considered
|
||||||
|
|
||||||
// NOTE: we send a reply *even if the (non broadcast) request was from us* which is unfortunate but necessary because
|
// NOTE: we send a reply *even if the (non broadcast) request was from us* which is unfortunate but necessary
|
||||||
// currently when the phone sends things, it sends things using the local node ID as the from address. A better
|
// because currently when the phone sends things, it sends things using the local node ID as the from address. A
|
||||||
// solution (FIXME) would be to let phones have their own distinct addresses and we 'route' to them like any other
|
// better solution (FIXME) would be to let phones have their own distinct addresses and we 'route' to them like
|
||||||
// node.
|
// any other node.
|
||||||
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
|
||||||
pi.sendResponse(mp);
|
pi.sendResponse(mp);
|
||||||
DEBUG_MSG("Plugin %s sent a response\n", pi.name);
|
DEBUG_MSG("Plugin %s sent a response\n", pi.name);
|
||||||
@ -122,6 +127,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pi.currentRequest = NULL;
|
pi.currentRequest = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user