update
This commit is contained in:
parent
62c5fa2f1f
commit
233dc494da
10
MQTT.py
10
MQTT.py
|
@ -5,7 +5,7 @@ import paho.mqtt.client as mqtt
|
|||
|
||||
from tool import *
|
||||
|
||||
from config import broker, port, subscribe_topic, publish_topic, username, password
|
||||
from config import broker, port, subscribe_topic, publish_topic, username, password, publish_pwd
|
||||
|
||||
|
||||
def valid(msg, client):
|
||||
|
@ -13,6 +13,14 @@ def valid(msg, client):
|
|||
if 'msg' not in origin_data:
|
||||
client.publish('error', payload='msg must be supplied', qos=0)
|
||||
return False
|
||||
# TODO 增加安全性
|
||||
if 'pwd' not in origin_data:
|
||||
client.publish('error', payload='pwd must be supplied', qos=0)
|
||||
return False
|
||||
# 判断密码是否正确
|
||||
if publish_pwd != origin_data['pwd']:
|
||||
client.publish('error', payload='pwd is not corrected', qos=0)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -5,3 +5,5 @@ port=1883
|
|||
[record]
|
||||
post_record_list_url=https://shop.lihaink.cn/api/index/file_list
|
||||
post_record_url=https://shop.lihaink.cn/api/index/upload
|
||||
[publish_pwd]
|
||||
value=123456
|
|
@ -18,6 +18,9 @@ port = config.getint("broker", "port")
|
|||
# 录像地址
|
||||
post_record_list_url = config.get("record", "post_record_list_url")
|
||||
post_record_url = config.get("record", "post_record_url")
|
||||
# 发布消息的认证pwd
|
||||
publish_pwd = config.get("publish_pwd", "value")
|
||||
|
||||
|
||||
# 读取设备配置
|
||||
config.read('conf/device/device.conf')
|
||||
|
@ -33,5 +36,6 @@ password = config.get(device_name, "password")
|
|||
# 特殊配置
|
||||
config.read('conf/zhanguan/topic.conf')
|
||||
zhanguan_device_name = config.get("device", "name")
|
||||
|
||||
# tool配置
|
||||
mp4_path = '/home/pi/mp4'
|
Loading…
Reference in New Issue