提交 7571ad2a 编写于 作者: 报告_前方高能's avatar 报告_前方高能

1.4.6-20230331

上级 a9c7f931
2023-03-27 ahttp 集成asynframe-sdk_v1.4.5-20230327 https://github.com/netsecsp/asynframe 2023-03-31 ahttp 集成asynframe-sdk_v1.4.6-20230331 https://github.com/netsecsp/asynframe
> asynframe-sdk_v1.4.5-20230327.zip is from https://github.com/netsecsp/asynframe > asynframe-sdk_v1.4.6-20230331.zip is from https://github.com/netsecsp/asynframe
# ahttp.exe # ahttp.exe
> supports IPv4/IPv6 http/https client program under windows > supports IPv4/IPv6 http/https client program under windows
......
...@@ -73,7 +73,7 @@ static void ShowUsage(std::string name) ...@@ -73,7 +73,7 @@ static void ShowUsage(std::string name)
printf(" -s use TLS or SSL\n"); printf(" -s use TLS or SSL\n");
printf(" -check-certificate\n"); printf(" -check-certificate\n");
printf(" -u use proxy url, protocol://[user:password@]host[:port]/ver?params\n"); printf(" -u use proxy url, protocol://[user:password@]host[:port]/ver?params\n");
printf(" -c continue-at OFFSET Resumed transfer OFFSET\n"); printf(" -c continue-at OFFSET Resumed transfer OFFSET\n");
printf(" -o save FILE\n"); printf(" -o save FILE\n");
printf("example: %s -4 \"http://localhost/test.exe\"\n", name.c_str()); printf("example: %s -4 \"http://localhost/test.exe\"\n", name.c_str());
} }
......
...@@ -95,11 +95,11 @@ HRESULT CHttpDownloader::OnIomsgNotify( uint64_t lParam1, uint64_t lAction, IAsy ...@@ -95,11 +95,11 @@ HRESULT CHttpDownloader::OnIomsgNotify( uint64_t lParam1, uint64_t lAction, IAsy
CComPtr<IAsynNetIoOperation> spAsynIoOperation; CComPtr<IAsynNetIoOperation> spAsynIoOperation;
lpAsynIoOperation->QueryInterface(IID_IAsynNetIoOperation, (void **)&spAsynIoOperation); lpAsynIoOperation->QueryInterface(IID_IAsynNetIoOperation, (void **)&spAsynIoOperation);
spAsynIoOperation->GetPeerAddress(&host, 0, &port, &m_af); spAsynIoOperation->GetPeerAddress(&host, 0, &port, &m_af);
printf("connected %s:%d[%s]\n", host.m_val.c_str(), port, m_af == AF_INET ? "ipv4" : "ipv6"); printf("connected %s:%d[%s]\n", host.m_val.c_str(), port, m_af == AF_INET? "ipv4" : "ipv6");
} }
asynsdk::CKeyvalSetter params(1); asynsdk::CKeyvalSetter params(1);
params.Set(STRING_from_string("User-Agent"), 1, STRING_from_string("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)")); params.Set(STRING_from_string("User-Agent"), 1, STRING_from_string("curl/7.84.0"));
params.Set(STRING_from_string("Accept" ), 1, STRING_from_string("*/*")); params.Set(STRING_from_string("Accept" ), 1, STRING_from_string("*/*"));
if( m_referurl ) params.Set(STRING_from_string("Referer"), 1, STRING_from_string(m_referurl)); if( m_referurl ) params.Set(STRING_from_string("Referer"), 1, STRING_from_string(m_referurl));
......
...@@ -148,7 +148,7 @@ public: ...@@ -148,7 +148,7 @@ public:
hostport = tmpurl.substr(pos1); hostport = tmpurl.substr(pos1);
} }
else else
{// ver?params {// ver?method=v&ssl=v
hostport = tmpurl.substr(pos1, pos2 - pos1); hostport = tmpurl.substr(pos1, pos2 - pos1);
pos2 += 1; pos2 += 1;
...@@ -170,20 +170,27 @@ public: ...@@ -170,20 +170,27 @@ public:
m_setsfile.set_string("proxy", "version", tmpurl.substr(pos2, post - pos2)); m_setsfile.set_string("proxy", "version", tmpurl.substr(pos2, post - pos2));
} }
std::string::size_type poss = params.find("method="); std::map<std::string, std::string> t;
if( poss != std::string::npos ) const char *s = params.c_str(), *e = s + params.size(), *i;
{ do{
poss += 7; i = strchr(s, '=');
std::string::size_type pose = params.find('&'); if(!i ) break;
if( pose == std::string::npos )
{ std::string key(s, i - s);
m_setsfile.set_string("proxy", "method", params.substr(poss));
} s = i + 1; //skip '='
else
{ i = strchr(s, '&');
m_setsfile.set_string("proxy", "method", params.substr(poss, pose - poss));
} t[key] = std::string(s, i? (i - s) : (e - s));
}
if(!i ) break;
s = i + 1; //skip '&'
}while(1);
m_setsfile.set_string("proxy", "method", t["method"]);
m_setsfile.set_string("proxy", "ssl", t["ssl"]);
} }
} }
...@@ -228,16 +235,6 @@ public: ...@@ -228,16 +235,6 @@ public:
{ {
continue; continue;
} }
std::string schema = tmpurl.substr(0, pos1);
_strlwr_s((char*)schema.c_str(), schema.size() + 1);
if( schema != "http" &&
schema != "https" &&
schema != "ftp" &&
schema != "ftps" )
{
continue;
}
else else
{ {
httpurl = argv[i]; httpurl = argv[i];
...@@ -259,17 +256,9 @@ public: ...@@ -259,17 +256,9 @@ public:
} }
std::string schema = url.substr(0, pos1); std::string schema = url.substr(0, pos1);
_strlwr_s((char*)schema.c_str(), schema.size() + 1); _strlwr_s((char*)schema.c_str(), schema.size()+1);
if( schema != "http" &&
schema != "https" && {// skip ://
schema != "ftp" &&
schema != "ftps" )
{
printf("fail to parse %s\n", url.c_str());
return false;
}
else
{
pos1 += 3; pos1 += 3;
} }
...@@ -333,7 +322,14 @@ public: ...@@ -333,7 +322,14 @@ public:
CComPtr<IAsynRawSocket> spAsynPtlSocket; CComPtr<IAsynRawSocket> spAsynPtlSocket;
if( proxyname == "none" ) if( proxyname == "none" )
{// 没有配置代理的情况: none {// 没有配置代理的情况: none
m_spAsynNetwork->CreateAsynPtlSocket( STRING_from_string("http"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(schema == "http" || schema == "ftp"? "tcp" : m_setsfile.get_string("ssl", "algo", "tls/1.0")), &spAsynPtlSocket); if( schema != "http" &&
schema != "https" )
{
printf("fail to parse %s\n", url.c_str());
return false;
}
m_spAsynNetwork->CreateAsynPtlSocket( STRING_from_string("http"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(schema == "http"? "tcp" : m_setsfile.get_string("ssl", "algo", "tls/1.0")), &spAsynPtlSocket);
if( spAsynPtlSocket == NULL ) if( spAsynPtlSocket == NULL )
{ {
printf("can't load plugin: http\n"); printf("can't load plugin: http\n");
...@@ -344,53 +340,93 @@ public: ...@@ -344,53 +340,93 @@ public:
{// 已经配置代理的情况: http/socks proxy {// 已经配置代理的情况: http/socks proxy
if( proxyname == "http" ) if( proxyname == "http" )
{// http.proxy {// http.proxy
std::string version = m_setsfile.get_string("proxy", "version");
if(!version.empty())
version.insert(0, "/");
m_spAsynNetwork->CreateAsynPtlSocket( STRING_from_string("proxy"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(proxyname + version), &spAsynPtlSocket );
if( spAsynPtlSocket == NULL )
{ {
printf("can't load plugin: proxy.%s\n", proxyname.c_str()); std::string ver = m_setsfile.get_string("proxy", "version");
return false; if(!ver.empty())
} ver.insert(0, "/");
std::string ssl = m_setsfile.get_string("proxy", "ssl");
if(!ssl.empty())
ssl.insert(0, ":");
CComPtr<IAsynRawSocket> spAsynTmpSocket;
m_spAsynNetwork->CreateAsynPtlSocket( STRING_from_string("proxy"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(proxyname + ver + ssl), &spAsynTmpSocket );
if( spAsynTmpSocket == NULL )
{
printf("can't load plugin: proxy.%s\n", proxyname.c_str());
return false;
}
else
{
spAsynInnSocket = spAsynTmpSocket;
}
CComPtr<IAsynProxySocket> spProxy;
spAsynInnSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy);
m_filepath = url; asynsdk::CKeyvalSetter params(1);
params.Set(STRING_from_string(";account"), 1, STRING_from_string(m_setsfile.get_string("proxy", "user") + ":" + m_setsfile.get_string("proxy", "password")));
HRESULT hr = spProxy->SetProxyContext(STRING_from_string(m_setsfile.get_string("proxy", "host", "127.0.0.1")), (PORT)m_setsfile.get_long("proxy", "port", ssl.empty()? 8080 : 8443), STRING_from_string(m_setsfile.get_string("proxy", "method", "")), &params);
}
CComPtr<IAsynProxySocket> spProxy; if( schema != "http" &&
spAsynPtlSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy); schema != "https" )
{
m_filepath = url; //use url
}
asynsdk::CKeyvalSetter params(1); if( schema == "https" )
params.Set(STRING_from_string(";account"), 1, STRING_from_string(m_setsfile.get_string("proxy", "user") + ":" + m_setsfile.get_string("proxy", "password"))); {
HRESULT hr = spProxy->SetProxyContext(STRING_from_string(m_setsfile.get_string("proxy", "host", "127.0.0.1")), schema!="https"? (PORT)m_setsfile.get_long("proxy", "port", 8080) : (PORT)m_setsfile.get_long("proxy", "port", 8443), STRING_from_string(m_setsfile.get_string("proxy", "method", "")), &params); CComPtr<IHttpTxTunnel> spDataTxTunnel; spAsynInnSocket->QueryInterface(IID_IHttpTxTunnel, (void **)&spDataTxTunnel);
spDataTxTunnel->SetEnabled(1); //强制直接代理
m_spAsynNetwork->CreateAsynPtlSocket(STRING_from_string("http"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(m_setsfile.get_string("ssl", "algo", "tls/1.0")), &spAsynPtlSocket );
if( spAsynPtlSocket == NULL )
{
printf("can't load plugin: http\n");
return false;
}
}
else
{
spAsynPtlSocket = spAsynInnSocket;
}
} }
else else
{// socks.proxy {// socks.proxy
if( memcmp(schema.c_str(), "http", 4) != 0 ) if( schema != "http" &&
schema != "https" )
{ {
printf("invalid schema: %s\n", url.c_str()); printf("fail to parse %s\n", url.c_str());
return false; return false;
} }
std::string version = m_setsfile.get_string("proxy", "version");
if(!version.empty())
version.insert(0, "/");
CComPtr<IAsynRawSocket> spAsynTmpSocket;
m_spAsynNetwork->CreateAsynPtlSocket( STRING_from_string("proxy"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(proxyname + version), &spAsynTmpSocket );
if( spAsynTmpSocket == NULL )
{ {
printf("can't load plugin: proxy.%s\n", proxyname.c_str()); std::string ver = m_setsfile.get_string("proxy", "version");
return false; if(!ver.empty())
} ver.insert(0, "/");
CComPtr<IAsynRawSocket> spAsynTmpSocket;
m_spAsynNetwork->CreateAsynPtlSocket( STRING_from_string("proxy"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(proxyname + ver), &spAsynTmpSocket );
if( spAsynTmpSocket == NULL )
{
printf("can't load plugin: proxy.%s\n", proxyname.c_str());
return false;
}
else
{
spAsynInnSocket = spAsynTmpSocket;
}
CComPtr<IAsynProxySocket> spProxy; CComPtr<IAsynProxySocket> spProxy;
spAsynTmpSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy); spAsynTmpSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy);
asynsdk::CKeyvalSetter params(1); asynsdk::CKeyvalSetter params(1);
params.Set(STRING_from_string(";account"), 1, STRING_from_string(m_setsfile.get_string("proxy", "user") + ":" + m_setsfile.get_string("proxy", "password"))); params.Set(STRING_from_string(";account"), 1, STRING_from_string(m_setsfile.get_string("proxy", "user") + ":" + m_setsfile.get_string("proxy", "password")));
HRESULT hr = spProxy->SetProxyContext(STRING_from_string(m_setsfile.get_string("proxy", "host", "127.0.0.1")), (PORT)m_setsfile.get_long("proxy", "port", 1080), STRING_from_string(m_setsfile.get_string("proxy", "method", "")), &params); HRESULT hr = spProxy->SetProxyContext(STRING_from_string(m_setsfile.get_string("proxy", "host", "127.0.0.1")), (PORT)m_setsfile.get_long("proxy", "port", 1080), STRING_from_string(m_setsfile.get_string("proxy", "method", "")), &params);
}
m_spAsynNetwork->CreateAsynPtlSocket(STRING_from_string("http"), (IUnknown **)&spAsynTmpSocket.p, STRING_from_string(schema=="http"? "tcp" : m_setsfile.get_string("ssl", "algo", "tls/1.0")), &spAsynPtlSocket ); m_spAsynNetwork->CreateAsynPtlSocket(STRING_from_string("http"), (IUnknown **)&spAsynInnSocket.p, STRING_from_string(schema=="http"? "tcp" : m_setsfile.get_string("ssl", "algo", "tls/1.0")), &spAsynPtlSocket );
if( spAsynPtlSocket == NULL ) if( spAsynPtlSocket == NULL )
{ {
printf("can't load plugin: http\n"); printf("can't load plugin: http\n");
...@@ -419,8 +455,7 @@ public: ...@@ -419,8 +455,7 @@ public:
printf("start to connect %s:%d via %s-proxyserver[%s]\n", m_host.c_str(), m_port, proxyname.c_str(), m_setsfile.get_string("proxy", "host", "127.0.0.1").c_str()); printf("start to connect %s:%d via %s-proxyserver[%s]\n", m_host.c_str(), m_port, proxyname.c_str(), m_setsfile.get_string("proxy", "host", "127.0.0.1").c_str());
} }
CComPtr<IAsynNetIoOperation> spAsynIoOperation; CComPtr<IAsynNetIoOperation> spAsynIoOperation; m_spAsynNetwork->CreateAsynIoOperation(m_spAsynFrame, 0, 0, IID_IAsynNetIoOperation, (void **)&spAsynIoOperation);
m_spAsynNetwork->CreateAsynIoOperation(m_spAsynFrame, 0, 0, IID_IAsynNetIoOperation, (void **)&spAsynIoOperation);
m_spAsynTcpSocket->Connect(STRING_from_string(m_host), m_port, 0, spAsynIoOperation, m_setsfile.get_long("session", "connect_timeout", 2000/*2sec*/)); m_spAsynTcpSocket->Connect(STRING_from_string(m_host), m_port, 0, spAsynIoOperation, m_setsfile.get_long("session", "connect_timeout", 2000/*2sec*/));
return true; return true;
} }
......
...@@ -67,7 +67,10 @@ std::string setting::get_string(const std::string &section, const std::string &e ...@@ -67,7 +67,10 @@ std::string setting::get_string(const std::string &section, const std::string &e
void setting::set_string(const std::string &section, const std::string &entry, const std::string &value) void setting::set_string(const std::string &section, const std::string &entry, const std::string &value)
{ {
m_key2vals[section + entry] = value; if(!value.empty())
{
m_key2vals[section + entry] = value;
}
} }
long setting::get_long(const std::string &section, const std::string &entry, long default_int ) long setting::get_long(const std::string &section, const std::string &entry, long default_int )
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Copyright (c) netsecsp 2012-2032, All rights reserved. Copyright (c) netsecsp 2012-2032, All rights reserved.
Author: Shengqian Yang, netsecsp@hotmail.com, China, last updated 05/01/2022 Author: Shengqian Yang, netsecsp@hotmail.com, China, last updated 05/01/2022
http://aftpx.sf.net http://ahttp.sf.net
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are modification, are permitted provided that the following conditions are
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#endif #endif
#endif #endif
#define STRING_UPDATETIME "03/27/2023" #define STRING_UPDATETIME "03/31/2023"
#include <iostream> #include <iostream>
#include <tchar.h> #include <tchar.h>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册