提交 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
> supports IPv4/IPv6 http/https client program under windows
......
......@@ -73,7 +73,7 @@ static void ShowUsage(std::string name)
printf(" -s use TLS or SSL\n");
printf(" -check-certificate\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("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
CComPtr<IAsynNetIoOperation> spAsynIoOperation;
lpAsynIoOperation->QueryInterface(IID_IAsynNetIoOperation, (void **)&spAsynIoOperation);
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);
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("*/*"));
if( m_referurl ) params.Set(STRING_from_string("Referer"), 1, STRING_from_string(m_referurl));
......
......@@ -148,7 +148,7 @@ public:
hostport = tmpurl.substr(pos1);
}
else
{// ver?params
{// ver?method=v&ssl=v
hostport = tmpurl.substr(pos1, pos2 - pos1);
pos2 += 1;
......@@ -170,20 +170,27 @@ public:
m_setsfile.set_string("proxy", "version", tmpurl.substr(pos2, post - pos2));
}
std::string::size_type poss = params.find("method=");
if( poss != std::string::npos )
{
poss += 7;
std::string::size_type pose = params.find('&');
if( pose == std::string::npos )
{
m_setsfile.set_string("proxy", "method", params.substr(poss));
}
else
{
m_setsfile.set_string("proxy", "method", params.substr(poss, pose - poss));
}
}
std::map<std::string, std::string> t;
const char *s = params.c_str(), *e = s + params.size(), *i;
do{
i = strchr(s, '=');
if(!i ) break;
std::string key(s, i - s);
s = i + 1; //skip '='
i = strchr(s, '&');
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:
{
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
{
httpurl = argv[i];
......@@ -259,17 +256,9 @@ public:
}
std::string schema = url.substr(0, pos1);
_strlwr_s((char*)schema.c_str(), schema.size() + 1);
if( schema != "http" &&
schema != "https" &&
schema != "ftp" &&
schema != "ftps" )
{
printf("fail to parse %s\n", url.c_str());
return false;
}
else
{
_strlwr_s((char*)schema.c_str(), schema.size()+1);
{// skip ://
pos1 += 3;
}
......@@ -333,7 +322,14 @@ public:
CComPtr<IAsynRawSocket> spAsynPtlSocket;
if( proxyname == "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 )
{
printf("can't load plugin: http\n");
......@@ -344,53 +340,93 @@ public:
{// 已经配置代理的情况: http/socks proxy
if( proxyname == "http" )
{// 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());
return false;
}
std::string ver = m_setsfile.get_string("proxy", "version");
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;
spAsynPtlSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy);
if( schema != "http" &&
schema != "https" )
{
m_filepath = url; //use 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")), 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);
if( schema == "https" )
{
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
{// 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;
}
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());
return false;
}
std::string ver = m_setsfile.get_string("proxy", "version");
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;
spAsynTmpSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy);
CComPtr<IAsynProxySocket> spProxy;
spAsynTmpSocket->QueryInterface(IID_IAsynProxySocket, (void **)&spProxy);
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", 1080), STRING_from_string(m_setsfile.get_string("proxy", "method", "")), &params);
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", 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 )
{
printf("can't load plugin: http\n");
......@@ -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());
}
CComPtr<IAsynNetIoOperation> spAsynIoOperation;
m_spAsynNetwork->CreateAsynIoOperation(m_spAsynFrame, 0, 0, IID_IAsynNetIoOperation, (void **)&spAsynIoOperation);
CComPtr<IAsynNetIoOperation> 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*/));
return true;
}
......
......@@ -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)
{
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 )
......
......@@ -5,7 +5,7 @@
Copyright (c) netsecsp 2012-2032, All rights reserved.
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
modification, are permitted provided that the following conditions are
......
......@@ -10,7 +10,7 @@
#endif
#endif
#define STRING_UPDATETIME "03/27/2023"
#define STRING_UPDATETIME "03/31/2023"
#include <iostream>
#include <tchar.h>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册