matthewwall/weewx-interceptor

Patch attached to use pval if using pypcap

Closed this issue · 1 comments

If I put

promiscous = 1

in the [Interceptor] stanza of weewx.conf, it is parsed as a string and that causes weewx to crash with the following:

2018-12-31 13:51:57.985416500 127.0.0.1: user.info: Dec 31 13:51:57 weewx[93290]: engine: Loading station type Interceptor (user.interceptor)
2018-12-31 13:51:58.044125500 127.0.0.1: user.info: Dec 31 13:51:58 weewx[93290]: interceptor: MainThread: driver version is 0.43
2018-12-31 13:51:58.044420500 127.0.0.1: user.info: Dec 31 13:51:58 weewx[93290]: interceptor: MainThread: device type: observer
2018-12-31 13:51:58.044424500 127.0.0.1: user.info: Dec 31 13:51:58 weewx[93290]: interceptor: MainThread: sensor map: None
2018-12-31 13:51:58.044428500 127.0.0.1: user.info: Dec 31 13:51:58 weewx[93290]: interceptor: MainThread: mode is sniff
2018-12-31 13:51:58.044431500 127.0.0.1: user.info: Dec 31 13:51:58 weewx[93290]: interceptor: MainThread: sniff iface=axe0 promiscuous=1
2018-12-31 13:51:58.044488500 127.0.0.1: user.info: Dec 31 13:51:58 weewx[93290]: interceptor: MainThread: sniff filter 'src 10.0.26.59 and dst port 80'
2018-12-31 13:51:58.047348500 127.0.0.1: user.err: Dec 31 13:51:58 weewx[93290]: import of driver failed: an integer is required (<type 'exceptions.TypeError'>)
2018-12-31 13:51:58.047353500 127.0.0.1: user.crit: Dec 31 13:51:58 weewx[93290]: engine: Unable to load driver: an integer is required
2018-12-31 13:51:58.047393500 127.0.0.1: user.crit: Dec 31 13:51:58 weewx[93290]:     ****  Exiting...

Here is a patch against 0.43 for that:

--- interceptor_orig.py Mon Dec 31 14:10:55 2018
+++ interceptor.py      Mon Dec 31 12:26:58 2018
@@ -334,7 +334,7 @@
                 self.sniffer_type = 'pylibpcap'
             except AttributeError:
                 # try pypcap
-                self.sniffer = pcap.pcap(iface, snaplen, promiscuous)
+                self.sniffer = pcap.pcap(iface, snaplen, pval)
                 self.sniffer.setfilter(pcap_filter)
                 self.sniffer_type = 'pypcap'
                 self.sniffer_version = pcap.__version__.lower()

fixed at commit b7d7417