Added netmask based security and fixed MQTT close event handling

- Added netmask (package) dependency
- Netmask can be configured via 'netmask'  in config
- Write was '192.168.1.0/24'
- Only clients in that range can publish.
- MQTT socket closing is now captured via 'close' event instead of 'end'