mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-15 20:37:36 +02:00
Fix dissector logic (#1626)
* Fix typo in Wireshark dissector * Fix wireshark dissector prefs_changed logic The previous logic had several issues: - Changing only the port number (without toggling all_ports) would not re-register the dissector on the new port. - Turning all_ports off would remove all registrations but only re-add the specific port inside a branch that also required all_ports to have changed, and never updated default_settings.port. Simplify to: remove all registrations, then register based on current prefs, then update the cached state.
This commit is contained in:
22
dist/wireshark/nebula.lua
vendored
22
dist/wireshark/nebula.lua
vendored
@@ -84,30 +84,24 @@ end
|
|||||||
|
|
||||||
function nebula.prefs_changed()
|
function nebula.prefs_changed()
|
||||||
if default_settings.all_ports == nebula.prefs.all_ports and default_settings.port == nebula.prefs.port then
|
if default_settings.all_ports == nebula.prefs.all_ports and default_settings.port == nebula.prefs.port then
|
||||||
-- Nothing changed, bail
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove our old dissector
|
-- Remove all existing registrations
|
||||||
DissectorTable.get("udp.port"):remove_all(nebula)
|
DissectorTable.get("udp.port"):remove_all(nebula)
|
||||||
|
|
||||||
if nebula.prefs.all_ports and default_settings.all_ports ~= nebula.prefs.all_ports then
|
if nebula.prefs.all_ports then
|
||||||
default_settings.all_port = nebula.prefs.all_ports
|
-- Register on every port for hole punch capture
|
||||||
|
|
||||||
for i=0, 65535 do
|
for i=0, 65535 do
|
||||||
DissectorTable.get("udp.port"):add(i, nebula)
|
DissectorTable.get("udp.port"):add(i, nebula)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
-- no need to establish again on specific ports
|
-- Register on the configured port only
|
||||||
return
|
DissectorTable.get("udp.port"):add(nebula.prefs.port, nebula)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
default_settings.all_ports = nebula.prefs.all_ports
|
||||||
if default_settings.all_ports ~= nebula.prefs.all_ports then
|
default_settings.port = nebula.prefs.port
|
||||||
-- Add our new port dissector
|
|
||||||
default_settings.port = nebula.prefs.port
|
|
||||||
DissectorTable.get("udp.port"):add(default_settings.port, nebula)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
DissectorTable.get("udp.port"):add(default_settings.port, nebula)
|
DissectorTable.get("udp.port"):add(default_settings.port, nebula)
|
||||||
|
|||||||
Reference in New Issue
Block a user