updated codes batch new CM.
This commit is contained in:
parent
f6e287a780
commit
228173af08
52
inc/hgl/network/UserAgentString.h
Normal file
52
inc/hgl/network/UserAgentString.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef HGL_WEBAPI_BROWSER_AGENT_STRING_INCLUDE
|
||||
#define HGL_WEBAPI_BROWSER_AGENT_STRING_INCLUDE
|
||||
|
||||
#include<hgl/type/String.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace webapi
|
||||
{
|
||||
enum OS
|
||||
{
|
||||
OS_WindowsX86=0,
|
||||
OS_WindowsAMD64,
|
||||
OS_WindowsWOW64,
|
||||
|
||||
OS_macOS,
|
||||
|
||||
OS_Linuxi686,
|
||||
OS_LinuxX86_64,
|
||||
|
||||
OS_iPod,
|
||||
OS_iPhone,
|
||||
OS_iPad,
|
||||
|
||||
OS_AndroidPhone,
|
||||
OS_AndroidTablet,
|
||||
OS_AndroidTV,
|
||||
|
||||
OS_END
|
||||
};
|
||||
|
||||
struct FirefoxUserAgentConfig
|
||||
{
|
||||
hgl::webapi::OS os;
|
||||
|
||||
uint64 gecko_version;
|
||||
|
||||
struct
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
}
|
||||
ff_ver, //firefox版本号
|
||||
os_ver; //操作系统版本号
|
||||
};
|
||||
|
||||
/**
|
||||
* 生成一个firefox用户代理字符串
|
||||
*/
|
||||
UTF8String FirefoxUserAgent(FirefoxUserAgentConfig &cfg);
|
||||
}//namespace webapi
|
||||
}//namespace hgl
|
||||
#endif//HGL_WEBAPI_BROWSER_AGENT_STRING_INCLUDE
|
@ -39,8 +39,9 @@ SET(NETWORK_SCTP_SOURCE
|
||||
SET(NETWORK_HTTP_SOURCE
|
||||
HTTPInputStream.cpp
|
||||
# HTTPOutputStream.cpp
|
||||
HTTPTools.cpp
|
||||
WebApi_Currency.cpp)
|
||||
# HTTPTools.cpp
|
||||
# WebApi_Currency.cpp
|
||||
)
|
||||
|
||||
SET(NETWORK_WEBSOCKET_SOURCE
|
||||
WebSocket.cpp
|
||||
@ -99,9 +100,7 @@ SET(CM_NETWORK_ALL_SOURCE
|
||||
${NETWORK_OS_SOURCE}
|
||||
WebapiUserAgent.cpp)
|
||||
|
||||
add_cm_library(CMNetwork "CM" ${CM_NETWORK_ALL_SOURCE} ${NETWORK_HTTP_SOURCE})
|
||||
|
||||
IF(WIN32)
|
||||
add_cm_library(CMNetwork "CM" ${CM_NETWORK_ALL_SOURCE})
|
||||
ELSE()
|
||||
add_cm_library(CMNetwork "CM" ${CM_NETWORK_ALL_SOURCE} ${NETWORK_HTTP_SOURCE})
|
||||
ENDIF()
|
||||
#find_package(unofficial-gumbo CONFIG REQUIRED)
|
||||
#target_link_libraries(CMNetwork PRIVATE unofficial::gumbo::gumbo)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include<hgl/Str.h>
|
||||
#include<hgl/type/BaseString.h>
|
||||
#include<hgl/type/StrChar.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/io/MemoryOutputStream.h>
|
||||
#include<hgl/algorithm/Hash.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
#include<hgl/algorithm/Crypt.h>
|
||||
|
||||
namespace hgl
|
||||
@ -41,7 +41,7 @@ namespace hgl
|
||||
end=key;
|
||||
while(*end!='\r')++end;
|
||||
|
||||
sec_websocket_key.Set(key,end-key);
|
||||
sec_websocket_key=UTF8String(key,end-key);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include<hgl/webapi/UserAgentString.h>
|
||||
#include<hgl/network/UserAgentString.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
@ -14,14 +14,14 @@ namespace hgl
|
||||
if(cfg.os>=OS_WindowsX86
|
||||
&&cfg.os<=OS_WindowsWOW64)
|
||||
{
|
||||
agent+="(Windows NT "+UTF8String(cfg.os_ver.major)+"."+UTF8String(cfg.os_ver.minor)+"; ";
|
||||
agent+="(Windows NT "+UTF8String::numberOf(cfg.os_ver.major)+"."+UTF8String::numberOf(cfg.os_ver.minor)+"; ";
|
||||
|
||||
if(cfg.os==OS_WindowsAMD64)agent+="Win64; x64; ";else
|
||||
if(cfg.os==OS_WindowsWOW64)agent+="WOW64; ";
|
||||
}
|
||||
else
|
||||
if(cfg.os==OS_macOS)
|
||||
agent+="(Macintosh; Intel Mac OS X "+UTF8String(cfg.os_ver.major)+"."+UTF8String(cfg.os_ver.minor)+"; ";
|
||||
agent+="(Macintosh; Intel Mac OS X "+UTF8String::numberOf(cfg.os_ver.major)+"."+UTF8String::numberOf(cfg.os_ver.minor)+"; ";
|
||||
else
|
||||
if(cfg.os==OS_Linuxi686)
|
||||
agent+="(X11; Linux i686; ";
|
||||
@ -29,8 +29,8 @@ namespace hgl
|
||||
if(cfg.os==OS_LinuxX86_64)
|
||||
agent+="(X11; Linux x86_64; ";
|
||||
|
||||
agent+="rv:"+UTF8String(cfg.ff_ver.major)+"."+UTF8String(cfg.ff_ver.minor)+") Gecko/"+UTF8String(cfg.gecko_version)+" Firefox/"
|
||||
+UTF8String(cfg.ff_ver.major)+"."+UTF8String(cfg.ff_ver.minor);
|
||||
agent+="rv:"+UTF8String::numberOf(cfg.ff_ver.major)+"."+UTF8String::numberOf(cfg.ff_ver.minor)+") Gecko/"+UTF8String::numberOf(cfg.gecko_version)+" Firefox/"
|
||||
+UTF8String::numberOf(cfg.ff_ver.major)+"."+UTF8String::numberOf(cfg.ff_ver.minor);
|
||||
}
|
||||
else
|
||||
if(cfg.os>=OS_iPod
|
||||
@ -40,26 +40,26 @@ namespace hgl
|
||||
if(cfg.os==OS_iPad) agent+="(iPad; ";else
|
||||
agent+="(iPhone; ";
|
||||
|
||||
agent+= "CPU iPhone OS "+UTF8String(cfg.os_ver.major)+"_"+UTF8String(cfg.os_ver.minor)+" like Mac OS X) "+
|
||||
agent+= "CPU iPhone OS "+UTF8String::numberOf(cfg.os_ver.major)+"_"+UTF8String::numberOf(cfg.os_ver.minor)+" like Mac OS X) "+
|
||||
"AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12F69 Safari/600.1.4";
|
||||
}
|
||||
else
|
||||
if(cfg.os>=OS_AndroidPhone
|
||||
&&cfg.os<=OS_AndroidTV)
|
||||
{
|
||||
agent+="(Android "+UTF8String(cfg.os_ver.major)+"."+UTF8String(cfg.os_ver.minor)+"; ";
|
||||
agent+="(Android "+UTF8String::numberOf(cfg.os_ver.major)+"."+UTF8String::numberOf(cfg.os_ver.minor)+"; ";
|
||||
|
||||
if(cfg.os==OS_AndroidPhone )agent+="Mobile; ";
|
||||
if(cfg.os==OS_AndroidTablet )agent+="Tablet; ";
|
||||
if(cfg.os==OS_AndroidTV )agent+="TV; ";
|
||||
|
||||
agent+="rv:"+UTF8String(cfg.ff_ver.major)+"."+UTF8String(cfg.ff_ver.minor)+") Gecko/"
|
||||
+UTF8String(cfg.ff_ver.major)+"."+UTF8String(cfg.ff_ver.minor)+" Firefox/"
|
||||
+UTF8String(cfg.ff_ver.major)+"."+UTF8String(cfg.ff_ver.minor);
|
||||
agent+="rv:"+UTF8String::numberOf(cfg.ff_ver.major)+"."+UTF8String::numberOf(cfg.ff_ver.minor)+") Gecko/"
|
||||
+UTF8String::numberOf(cfg.ff_ver.major)+"."+UTF8String::numberOf(cfg.ff_ver.minor)+" Firefox/"
|
||||
+UTF8String::numberOf(cfg.ff_ver.major)+"."+UTF8String::numberOf(cfg.ff_ver.minor);
|
||||
}
|
||||
else
|
||||
{
|
||||
agent+="Firefox/"+UTF8String(cfg.ff_ver.major)+"."+UTF8String(cfg.ff_ver.minor);
|
||||
agent+="Firefox/"+UTF8String::numberOf(cfg.ff_ver.major)+"."+UTF8String::numberOf(cfg.ff_ver.minor);
|
||||
}
|
||||
|
||||
return agent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user