过滤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);
|
auto bs = Get(name);
|
||||||
if(bs.Length() < 6) return false;
|
if(bs.Length() < 6) return false;
|
||||||
|
if (bs[0] == 6)return false; // 单片机这边不支持ipv6
|
||||||
value = bs;
|
Buffer bs2(bs.GetBuffer() + 1, 6);
|
||||||
|
value = bs2;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +143,11 @@ bool BinaryPair::Set(const String& name, UInt64 value)
|
||||||
|
|
||||||
bool BinaryPair::Set(const String& name, const IPEndPoint& 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());
|
MemoryStream urims(uri.GetBuffer(), uri.Length());
|
||||||
BinaryPair uribp(urims);
|
BinaryPair uribp(urims);
|
||||||
|
|
||||||
uint prcl = 0x00; // 服务店 ProtocolType 17 为UDP
|
uribp.Get("Type", Protocol); // 服务店 ProtocolType 17 为UDP
|
||||||
uribp.Get("ProtocolType", prcl);
|
if (Protocol == 0x00)Protocol = 0x11; // 避免 unknown 出现
|
||||||
prcl >>= 24; // 大小端问题
|
|
||||||
Protocol = prcl;
|
|
||||||
uribp.Get("Host", Server);
|
uribp.Get("Host", Server);
|
||||||
uint uintPort; // 服务端 Port 为 int 类型
|
uint uintPort; // 服务端 Port 为 int 类型
|
||||||
uribp.Get("Port", uintPort);
|
uribp.Get("Port", uintPort);
|
||||||
Port = uintPort >> 16;
|
Port = uintPort ;
|
||||||
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);*/
|
|
||||||
}
|
}
|
||||||
bp.Get("VisitToken", VisitToken);
|
bp.Get("VisitToken", VisitToken);
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ TokenConfig* TokenConfig::Create(const char* vendor, ProtocolType protocol, usho
|
||||||
tc.Init();
|
tc.Init();
|
||||||
tc.Protocol = protocol;
|
tc.Protocol = protocol;
|
||||||
tc.Load();
|
tc.Load();
|
||||||
|
if(tc.Protocol == 0x00)tc.Protocol = ProtocolType::Udp; // 默认 UDP 不允许 unknown
|
||||||
|
|
||||||
bool rs = tc.New;
|
bool rs = tc.New;
|
||||||
if(!tc.Vendor)
|
if(!tc.Vendor)
|
||||||
|
|
Loading…
Reference in New Issue