fix non-ssl build
This commit is contained in:
+5
-1
@@ -263,7 +263,11 @@ int main(int argc, char* argv[], char* envp[]) {
|
|||||||
const string lang = MappedFileReader::normalizeLanguage(
|
const string lang = MappedFileReader::normalizeLanguage(
|
||||||
s_opt.preferLanguage == nullptr || !s_opt.preferLanguage[0] ? "" : s_opt.preferLanguage);
|
s_opt.preferLanguage == nullptr || !s_opt.preferLanguage[0] ? "" : s_opt.preferLanguage);
|
||||||
string configLocalPrefix, configUriPrefix;
|
string configLocalPrefix, configUriPrefix;
|
||||||
|
#ifdef HAVE_SSL
|
||||||
HttpClient::initialize(s_opt.caFile, s_opt.caPath);
|
HttpClient::initialize(s_opt.caFile, s_opt.caPath);
|
||||||
|
#else // HAVE_SSL
|
||||||
|
HttpClient::initialize(nullptr, nullptr);
|
||||||
|
#endif // HAVE_SSL
|
||||||
HttpClient* configHttpClient = nullptr;
|
HttpClient* configHttpClient = nullptr;
|
||||||
string configPath = s_opt.configPath;
|
string configPath = s_opt.configPath;
|
||||||
if (configPath.find("://") == string::npos) {
|
if (configPath.find("://") == string::npos) {
|
||||||
@@ -288,7 +292,7 @@ int main(int argc, char* argv[], char* envp[]) {
|
|||||||
logWrite(lf_main, ll_error, "invalid configPath URL (HTTPS not supported)"); // force logging on exit
|
logWrite(lf_main, ll_error, "invalid configPath URL (HTTPS not supported)"); // force logging on exit
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
logWrite(lf_main, ll_error, "invalid configPath URL"); // force logging on exit
|
logWrite(lf_main, ll_error, "invalid configPath URL"); // force logging on exit
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -63,9 +63,10 @@ typedef struct options {
|
|||||||
bool injectMessages; //!< inject remaining arguments as already seen messages
|
bool injectMessages; //!< inject remaining arguments as already seen messages
|
||||||
bool stopAfterInject; //!< only inject messages once, then stop
|
bool stopAfterInject; //!< only inject messages once, then stop
|
||||||
int injectCount; //!< number of message arguments to inject, or 0
|
int injectCount; //!< number of message arguments to inject, or 0
|
||||||
|
#ifdef HAVE_SSL
|
||||||
const char* caFile; //!< the CA file to use (uses defaults if neither caFile nor caPath are set), or "#" for insecure
|
const char* caFile; //!< the CA file to use (uses defaults if neither caFile nor caPath are set), or "#" for insecure
|
||||||
const char* caPath; //!< the path with CA files to use (uses defaults if neither caFile nor caPath are set)
|
const char* caPath; //!< the path with CA files to use (uses defaults if neither caFile nor caPath are set)
|
||||||
|
#endif // HAVE_SSL
|
||||||
symbol_t address; //!< own bus address [31]
|
symbol_t address; //!< own bus address [31]
|
||||||
bool answer; //!< answer to requests from other masters
|
bool answer; //!< answer to requests from other masters
|
||||||
unsigned int acquireTimeout; //!< bus acquisition timeout in ms [10]
|
unsigned int acquireTimeout; //!< bus acquisition timeout in ms [10]
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace ebusd {
|
|||||||
/** the default path of the configuration files. */
|
/** the default path of the configuration files. */
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
#define CONFIG_PATH "https" CONFIG_PATH_SUFFIX
|
#define CONFIG_PATH "https" CONFIG_PATH_SUFFIX
|
||||||
#else
|
#else // HAVE_SSL
|
||||||
#define CONFIG_PATH "http" CONFIG_PATH_SUFFIX
|
#define CONFIG_PATH "http" CONFIG_PATH_SUFFIX
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
|
|
||||||
/** the default program options. */
|
/** the default program options. */
|
||||||
static const options_t s_default_opt = {
|
static const options_t s_default_opt = {
|
||||||
@@ -57,9 +57,10 @@ static const options_t s_default_opt = {
|
|||||||
.injectMessages = false,
|
.injectMessages = false,
|
||||||
.stopAfterInject = false,
|
.stopAfterInject = false,
|
||||||
.injectCount = 0,
|
.injectCount = 0,
|
||||||
|
#ifdef HAVE_SSL
|
||||||
.caFile = nullptr,
|
.caFile = nullptr,
|
||||||
.caPath = nullptr,
|
.caPath = nullptr,
|
||||||
|
#endif // HAVE_SSL
|
||||||
.address = 0x31,
|
.address = 0x31,
|
||||||
.answer = false,
|
.answer = false,
|
||||||
.acquireTimeout = 10,
|
.acquireTimeout = 10,
|
||||||
@@ -345,13 +346,14 @@ static int parse_opt(int key, char *arg, const argParseOpt *parseOpt, struct opt
|
|||||||
opt->injectMessages = true;
|
opt->injectMessages = true;
|
||||||
opt->stopAfterInject = arg && strcmp("stop", arg) == 0;
|
opt->stopAfterInject = arg && strcmp("stop", arg) == 0;
|
||||||
break;
|
break;
|
||||||
|
#ifdef HAVE_SSL
|
||||||
case O_CAFILE: // --cafile=FILE
|
case O_CAFILE: // --cafile=FILE
|
||||||
opt->caFile = arg;
|
opt->caFile = arg;
|
||||||
break;
|
break;
|
||||||
case O_CAPATH: // --capath=PATH
|
case O_CAPATH: // --capath=PATH
|
||||||
opt->caPath = arg;
|
opt->caPath = arg;
|
||||||
break;
|
break;
|
||||||
|
#endif // HAVE_SSL
|
||||||
// eBUS options:
|
// eBUS options:
|
||||||
case 'a': // --address=31
|
case 'a': // --address=31
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -298,9 +298,9 @@ void MainLoop::run() {
|
|||||||
if (!m_httpClient.connect("upd.ebusd.eu",
|
if (!m_httpClient.connect("upd.ebusd.eu",
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
443, true,
|
443, true,
|
||||||
#else
|
#else // HAVE_SSL
|
||||||
80, false,
|
80, false,
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
PACKAGE_NAME "/" PACKAGE_VERSION)) {
|
PACKAGE_NAME "/" PACKAGE_VERSION)) {
|
||||||
logError(lf_main, "update check connect error");
|
logError(lf_main, "update check connect error");
|
||||||
nextCheckRun = now + CHECK_INITIAL_DELAY;
|
nextCheckRun = now + CHECK_INITIAL_DELAY;
|
||||||
|
|||||||
@@ -344,11 +344,11 @@ bool HttpClient::parseUrl(const string& url, string* proto, string* host, uint16
|
|||||||
if (!isSsl && *proto != "http") {
|
if (!isSsl && *proto != "http") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else // HAVE_SSL
|
||||||
if (*proto != "http") {
|
if (*proto != "http") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
size_t pos = url.find('/', hostPos);
|
size_t pos = url.find('/', hostPos);
|
||||||
if (pos == hostPos) {
|
if (pos == hostPos) {
|
||||||
return false;
|
return false;
|
||||||
@@ -387,12 +387,12 @@ bool HttpClient::connect(const string& host, const uint16_t port, bool https, co
|
|||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
m_socket = SSLSocket::connect(host, port, https, timeout, s_caFile, s_caPath);
|
m_socket = SSLSocket::connect(host, port, https, timeout, s_caFile, s_caPath);
|
||||||
m_https = https;
|
m_https = https;
|
||||||
#else
|
#else // HAVE_SSL
|
||||||
if (https) {
|
if (https) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_socket = TCPSocket::connect(host, port, timeout);
|
m_socket = TCPSocket::connect(host, port, timeout);
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
if (!m_socket) {
|
if (!m_socket) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -410,9 +410,9 @@ bool HttpClient::reconnect() {
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
m_socket = SSLSocket::connect(m_host, m_port, m_https, m_timeout, s_caFile, s_caPath);
|
m_socket = SSLSocket::connect(m_host, m_port, m_https, m_timeout, s_caFile, s_caPath);
|
||||||
#else
|
#else // HAVE_SSL
|
||||||
m_socket = TCPSocket::connect(m_host, m_port, m_timeout);
|
m_socket = TCPSocket::connect(m_host, m_port, m_timeout);
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
if (!m_socket) {
|
if (!m_socket) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
# include <openssl/ssl.h>
|
# include <openssl/ssl.h>
|
||||||
# include <openssl/bio.h>
|
# include <openssl/bio.h>
|
||||||
# include <openssl/err.h>
|
# include <openssl/err.h>
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
|
|
||||||
/** typedef for referencing @a sockaddr_in within namespace. */
|
/** typedef for referencing @a sockaddr_in within namespace. */
|
||||||
typedef struct sockaddr_in socketaddress;
|
typedef struct sockaddr_in socketaddress;
|
||||||
@@ -122,7 +122,7 @@ class HttpClient {
|
|||||||
HttpClient() :
|
HttpClient() :
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
m_https(false),
|
m_https(false),
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
m_socket(nullptr), m_port(0), m_timeout(0), m_bufferSize(0), m_buffer(nullptr) {
|
m_socket(nullptr), m_port(0), m_timeout(0), m_bufferSize(0), m_buffer(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ class HttpClient {
|
|||||||
|
|
||||||
/** the path with CA files to use. */
|
/** the path with CA files to use. */
|
||||||
static const char* s_caPath;
|
static const char* s_caPath;
|
||||||
#endif
|
#endif // HAVE_SSL
|
||||||
|
|
||||||
/** the currently connected socket. */
|
/** the currently connected socket. */
|
||||||
SocketClass* m_socket;
|
SocketClass* m_socket;
|
||||||
|
|||||||
Reference in New Issue
Block a user