过滤IP 不允许type为unknown Redirect 字符串修改 大小端修改
This commit is contained in:
parent
eef6243af9
commit
a276d27848
|
@ -113,8 +113,9 @@ bool BinaryPair::Get(const String& name, IPEndPoint& value) const
|
|||
{
|
||||
auto bs = Get(name);
|
||||
if(bs.Length() < 6) return false;
|
||||
|
||||
value = bs;
|
||||
if (bs[0] == 6)return false; // 单片机这边不支持ipv6
|
||||
Buffer bs2(bs.GetBuffer() + 1, 6);
|
||||
value = bs2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -142,6 +143,11 @@ bool BinaryPair::Set(const String& name, UInt64 value)
|
|||
|
||||
bool BinaryPair::Set(const String& name, const IPEndPoint& value)
|
||||
{
|
||||
return Set(name, value.ToArray());
|
||||
MemoryStream ms(7);
|
||||
ms.Write(4);
|
||||
ms.Write(value.ToArray());
|
||||
ByteArray bs(ms.GetBuffer(), ms.Position());
|
||||
return Set(name, bs);
|
||||
//return Set(name, value.ToArray());
|
||||
}
|
||||
|
||||
|
|
|
@ -53,23 +53,12 @@ bool HelloMessage::Read(Stream& ms)
|
|||
MemoryStream urims(uri.GetBuffer(), uri.Length());
|
||||
BinaryPair uribp(urims);
|
||||
|
||||
uint prcl = 0x00; // 服务店 ProtocolType 17 为UDP
|
||||
uribp.Get("ProtocolType", prcl);
|
||||
prcl >>= 24; // 大小端问题
|
||||
Protocol = prcl;
|
||||
uribp.Get("Type", Protocol); // 服务店 ProtocolType 17 为UDP
|
||||
if (Protocol == 0x00)Protocol = 0x11; // 避免 unknown 出现
|
||||
uribp.Get("Host", Server);
|
||||
uint uintPort; // 服务端 Port 为 int 类型
|
||||
uribp.Get("Port", uintPort);
|
||||
Port = uintPort >> 16;
|
||||
Port = _REV16(Port); // 大小端问题
|
||||
|
||||
/*uint prcl = 0x00; // 服务店 ProtocolType 17 为UDP
|
||||
bp.Get("ProtocolType", prcl);
|
||||
Protocol = prcl == 0x11 ? 0x02 : 0x01; // Protocol; // 协议,TCP=1/UDP=2
|
||||
bp.Get("Host", Server);
|
||||
uint uintPort; // 服务端 Port 为 int 类型
|
||||
bp.Get("Port", uintPort);
|
||||
Port = (*(int*)&uintPort);*/
|
||||
Port = uintPort ;
|
||||
}
|
||||
bp.Get("VisitToken", VisitToken);
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ TokenConfig* TokenConfig::Create(const char* vendor, ProtocolType protocol, usho
|
|||
tc.Init();
|
||||
tc.Protocol = protocol;
|
||||
tc.Load();
|
||||
if(tc.Protocol == 0x00)tc.Protocol = ProtocolType::Udp; // 默认 UDP 不允许 unknown
|
||||
|
||||
bool rs = tc.New;
|
||||
if(!tc.Vendor)
|
||||
|
|
Loading…
Reference in New Issue