微耕门禁跨网段搜索代理

解决UDP无法跨网段时的控制器搜索问题

思路:

  1. 配置已知的搜索指令
  2. 配置已知的待搜索网段
  3. 定时使用HTTP发送指令至IP,收集并缓存收到的应答
  4. 监听收到UDP搜索指令,将未超时的缓存作为应答返回
  5. 与Http2UDP结合使用,可以实现广播包的返回

注:HTTP2UDP用法

  1. 设备在A网,Http2UDP在A网,可UDP,业务程序在B网(或互联网),连接http2udp发广播包,返回收到的所有广播包
  2. 设备在A网,Http2UDP在A网,可UDP,业务程序在B网(或互联网),连接http2udp发UDP包,返回收到的UDP包
  3. 设备在C网,Http2UDP在A网,不可UDP,先在A网运行ScanProxy进行数据包缓存,业务程序在B网(或互联网),连接http2udp发广播包,ScanProxy返回收到的所有广播包

 

配置

@@@code

{

"Logging": {

"LogLevel": {

"Default": "Warning"

}

},

"Scan": {

"Minute": 15,

"AliveMinute": 720,

"Command": [

{

"Name": 1994,

"Enable": 1,

"Data": "19 94 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",

"ProtocolHead": "1994",

"SNPosition": 4,

"Desc": "SDK"

   

},

{

"Name": 1794,

"Enable": 1,

"Data": "17 94 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",

"ProtocolHead": "1794",

"SNPosition": 4,

"Desc": "SDK"

   

},

{

"Name": "2010",

"Enable": 1,

"Data": "20 10 7d 2b 07 06 00 00 00 00 00 00 ff ff ff ff 00 00 02 00 ff ff ff ff",

"ProtocolHead": "2011",

"SNPosition": 8,

"Desc": "IPConfigTool"

},

{

"Name": 2410,

"Enable": 1,

"Data": "24 10 f4 33 02 06 00 00 00 00 00 00 ff ff ff ff 00 00 02 00",

"ProtocolHead": "2411",

"SNPosition": 8,

"Desc": "IPConfigTool"

   

},

{

"Name": 2440,

"Enable": 1,

"Data": "24 40 b3 e4 01 00 00 00 00 00 00 00 ff ff ff ff 00 81 02 00",

"ProtocolHead": "2441",

"SNPosition": 8,

"Desc": "N3000"

   

   

}

],

"Timeout": 3,

"NetMask": [

"172.16.2.*:60000",

"172.16.3.*:60000",

"172.16.4.*:60000",

"172.16.5.*:60000",

"192.168.153.*:60000",

"192.168.10.*:60000",

"192.168.156.*:60000"

]

},

"UDPServer": {

"ProtocolHead": [

{

"Name": 1994,

"Enable": 0,

"Heads": [

{

"Pos": 0,

"Hex": "1994"

}

]

},

{

"Name": 1794,

"Enable": 0,

"Heads": [

{

"Pos": 0,

"Hex": "1794"

}

]

},

{

"Name": 2440,

"Enable": 1,

"Sleep": 0,

"Heads": [

{

"Pos": 0,

"Hex": "2440"

},

{

"Pos": 18,

"Hex": "02"

}

]

},

{

"Name": 2410,

"Enable": 1,

"Sleep": 0,

"Heads": [

{

"Pos": 0,

"Hex": "2410"

},

{

"Pos": 18,

"Hex": "02"

}

]

},

{

"Name": 2010,

"Enable": 1,

"Sleep": 5,

"Heads": [

{

"Pos": 0,

"Hex": "2010"

},

{

"Pos": 18,

"Hex": "02"

}

]

}

],

"Timeout": 3,

"IPEndPoint": "192.168.10.211:60000"

},

"AllowedHosts": "*"

}

     

@@#

效果图

   

 

 

结合http2udp,可以实现下列用途

 

 

 

 

 

 

posted @ 2019-09-09 18:28  秦秋随  阅读(500)  评论(0编辑  收藏  举报