mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 20:44:39 +00:00
Merge remote-tracking branch 'purple/openssl' into meshnet
This commit is contained in:
commit
d030df925f
79
Config.cpp
79
Config.cpp
@ -26,83 +26,6 @@ namespace config {
|
||||
options_description m_OptionsDesc;
|
||||
variables_map m_Options;
|
||||
|
||||
/* list of renamed options */
|
||||
std::map<std::string, std::string> remapped_options = {
|
||||
{ "tunnelscfg", "tunconf" },
|
||||
{ "v6", "ipv6" },
|
||||
{ "httpaddress", "http.address" },
|
||||
{ "httpport", "http.port" },
|
||||
{ "httpproxyaddress", "httpproxy.address" },
|
||||
{ "httpproxyport", "httpproxy.port" },
|
||||
{ "socksproxyaddress", "socksproxy.address" },
|
||||
{ "socksproxyport", "socksproxy.port" },
|
||||
{ "samaddress", "sam.address" },
|
||||
{ "samport", "sam.port" },
|
||||
{ "bobaddress", "bob.address" },
|
||||
{ "bobport", "bob.port" },
|
||||
{ "i2pcontroladdress", "i2pcontrol.address" },
|
||||
{ "i2pcontroladdress", "i2pcontrol.port" },
|
||||
{ "proxykeys", "httpproxy.keys" },
|
||||
};
|
||||
/* list of options, that loose their argument and become simple switch */
|
||||
std::set<std::string> boolean_options = {
|
||||
"daemon", "floodfill", "notransit", "service", "ipv6"
|
||||
};
|
||||
|
||||
/* this function is a solid piece of shit, remove it after 2.6.0 */
|
||||
std::pair<std::string, std::string> old_syntax_parser(const std::string& s) {
|
||||
std::string name = "";
|
||||
std::string value = "";
|
||||
std::size_t pos = 0;
|
||||
/* shortcuts -- -h */
|
||||
if (s.length() == 2 && s.at(0) == '-' && s.at(1) != '-')
|
||||
return make_pair(s.substr(1), "");
|
||||
/* old-style -- -log, /log, etc */
|
||||
if (s.at(0) == '/' || (s.at(0) == '-' && s.at(1) != '-')) {
|
||||
if ((pos = s.find_first_of("= ")) != std::string::npos) {
|
||||
name = s.substr(1, pos - 1);
|
||||
value = s.substr(pos + 1);
|
||||
} else {
|
||||
name = s.substr(1, pos);
|
||||
value = "";
|
||||
}
|
||||
if (boolean_options.count(name) > 0 && value != "")
|
||||
std::cerr << "args: don't give an argument to switch option: " << s << std::endl;
|
||||
if (m_OptionsDesc.find_nothrow(name, false)) {
|
||||
std::cerr << "args: option " << s << " style is DEPRECATED, use --" << name << " instead" << std::endl;
|
||||
return std::make_pair(name, value);
|
||||
}
|
||||
if (remapped_options.count(name) > 0) {
|
||||
name = remapped_options[name];
|
||||
std::cerr << "args: option " << s << " is DEPRECATED, use --" << name << " instead" << std::endl;
|
||||
return std::make_pair(name, value);
|
||||
} /* else */
|
||||
}
|
||||
/* long options -- --help */
|
||||
if (s.substr(0, 2) == "--") {
|
||||
if ((pos = s.find_first_of("= ")) != std::string::npos) {
|
||||
name = s.substr(2, pos - 2);
|
||||
value = s.substr(pos + 1);
|
||||
} else {
|
||||
name = s.substr(2, pos);
|
||||
value = "";
|
||||
}
|
||||
if (boolean_options.count(name) > 0 && value != "") {
|
||||
std::cerr << "args: don't give an argument to switch option: " << s << std::endl;
|
||||
value = "";
|
||||
}
|
||||
if (m_OptionsDesc.find_nothrow(name, false))
|
||||
return std::make_pair(name, value);
|
||||
if (remapped_options.count(name) > 0) {
|
||||
name = remapped_options[name];
|
||||
std::cerr << "args: option " << s << " is DEPRECATED, use --" << name << " instead" << std::endl;
|
||||
return std::make_pair(name, value);
|
||||
} /* else */
|
||||
}
|
||||
std::cerr << "args: unknown option -- " << s << std::endl;
|
||||
return std::make_pair("", "");
|
||||
}
|
||||
|
||||
void Init() {
|
||||
options_description general("General options");
|
||||
general.add_options()
|
||||
@ -234,7 +157,7 @@ namespace config {
|
||||
auto style = boost::program_options::command_line_style::unix_style
|
||||
| boost::program_options::command_line_style::allow_long_disguise;
|
||||
style &= ~ boost::program_options::command_line_style::allow_guessing;
|
||||
store(parse_command_line(argc, argv, m_OptionsDesc, style, old_syntax_parser), m_Options);
|
||||
store(parse_command_line(argc, argv, m_OptionsDesc, style), m_Options);
|
||||
} catch (boost::program_options::error& e) {
|
||||
std::cerr << "args: " << e.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
|
2
HTTP.cpp
2
HTTP.cpp
@ -280,7 +280,7 @@ namespace http {
|
||||
return false;
|
||||
}
|
||||
|
||||
long int HTTPMsg::length() {
|
||||
long int HTTPMsg::content_length() {
|
||||
unsigned long int length = 0;
|
||||
auto it = headers.find("Content-Length");
|
||||
if (it == headers.end())
|
||||
|
2
HTTP.h
2
HTTP.h
@ -62,7 +62,7 @@ namespace http {
|
||||
void del_header(const char *name);
|
||||
|
||||
/** @brief Returns declared message length or -1 if unknown */
|
||||
long int length();
|
||||
long int content_length();
|
||||
};
|
||||
|
||||
struct HTTPReq : HTTPMsg {
|
||||
|
@ -205,7 +205,7 @@ namespace client
|
||||
}
|
||||
/* append to json chunk of data from 1st request */
|
||||
json.write(buf->begin() + len, bytes_transferred - len);
|
||||
remains = req.length() - len;
|
||||
remains = req.content_length() - len;
|
||||
/* if request has Content-Length header, fetch rest of data and store to json buffer */
|
||||
while (remains > 0) {
|
||||
len = ((long int) buf->size() < remains) ? buf->size() : remains;
|
||||
|
8
Tag.h
8
Tag.h
@ -1,3 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2016, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
* See full license text in LICENSE file at top of project tree
|
||||
*/
|
||||
|
||||
#ifndef TAG_H__
|
||||
#define TAG_H__
|
||||
|
||||
|
@ -29,7 +29,7 @@ int main() {
|
||||
assert(res->headers.find("Server")->second == "nginx/1.2.1");
|
||||
assert(res->headers.find("Content-Length")->second == "536");
|
||||
assert(res->is_chunked() == false);
|
||||
assert(res->length() == 536);
|
||||
assert(res->content_length() == 536);
|
||||
delete res;
|
||||
|
||||
/* test: building request */
|
||||
|
Loading…
x
Reference in New Issue
Block a user