Skip to content

Commit 9f1aef5

Browse files
authored
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.
1 parent 1aa1a04 commit 9f1aef5

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

dist/wireshark/nebula.lua

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,24 @@ end
8484

8585
function nebula.prefs_changed()
8686
if default_settings.all_ports == nebula.prefs.all_ports and default_settings.port == nebula.prefs.port then
87-
-- Nothing changed, bail
8887
return
8988
end
9089

91-
-- Remove our old dissector
90+
-- Remove all existing registrations
9291
DissectorTable.get("udp.port"):remove_all(nebula)
9392

94-
if nebula.prefs.all_ports and default_settings.all_ports ~= nebula.prefs.all_ports then
95-
default_settings.all_port = nebula.prefs.all_ports
96-
93+
if nebula.prefs.all_ports then
94+
-- Register on every port for hole punch capture
9795
for i=0, 65535 do
9896
DissectorTable.get("udp.port"):add(i, nebula)
9997
end
100-
101-
-- no need to establish again on specific ports
102-
return
98+
else
99+
-- Register on the configured port only
100+
DissectorTable.get("udp.port"):add(nebula.prefs.port, nebula)
103101
end
104102

105-
106-
if default_settings.all_ports ~= nebula.prefs.all_ports then
107-
-- Add our new port dissector
108-
default_settings.port = nebula.prefs.port
109-
DissectorTable.get("udp.port"):add(default_settings.port, nebula)
110-
end
103+
default_settings.all_ports = nebula.prefs.all_ports
104+
default_settings.port = nebula.prefs.port
111105
end
112106

113107
DissectorTable.get("udp.port"):add(default_settings.port, nebula)

0 commit comments

Comments
 (0)