forked from syslog-ng/syslog-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules/afmongodb, configure.ac: ENABLE_LEGACY_MONGODB_OPTIONS
This re-adds additional support for previous syntax used by libmongo-client before we started using mongo-c-driver and its URI syntax exclusively. I.e., so additionally to uri() and collection(), now the following keywords should work again: servers() safe_mode() path() password() username() database() Note that these are plainly translated to a connection URI without much sanity checking or preserving their former semantic meaning. So various aspects of the MongoDB connection like health checks, retries, error reporting and synchronicity will still follow the slightly altered semantics of mongo-c-driver. In the future, theoretically it is enough to revert this single commit to remove support. (This is one reason I did not opt for OOP & inheritance to implement this) Fixes syslog-ng#893 Signed-off-by: bkil-syslogng <tamas.nagy@balabit.com>
- Loading branch information
1 parent
20828a9
commit e7962e4
Showing
12 changed files
with
684 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
* Copyright (c) 2010-2016 Balabit | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#include "afmongodb-legacy-grammar.h" | ||
#include "afmongodb-legacy-private.h" | ||
|
||
gboolean | ||
afmongodb_dd_check_address(LogDriver *d, gboolean local) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
if (local) | ||
{ | ||
if ((self->port != 0 || self->port != MONGO_CONN_LOCAL) && self->address != NULL) | ||
return FALSE; | ||
if (self->servers) | ||
return FALSE; | ||
} | ||
else | ||
{ | ||
if (self->port == MONGO_CONN_LOCAL && self->address != NULL) | ||
return FALSE; | ||
} | ||
return TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_user(LogDriver *d, const gchar *user) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using username() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
g_free(self->user); | ||
self->user = g_strdup(user); | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_password(LogDriver *d, const gchar *password) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using password() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
g_free(self->password); | ||
self->password = g_strdup(password); | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_host(LogDriver *d, const gchar *host) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using host() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
g_free(self->address); | ||
self->address = g_strdup(host); | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_port(LogDriver *d, gint port) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using port() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
self->port = port; | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_servers(LogDriver *d, GList *servers) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using servers() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
string_list_free(self->servers); | ||
self->servers = servers; | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_path(LogDriver *d, const gchar *path) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using path() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
g_free(self->address); | ||
self->address = g_strdup(path); | ||
self->port = MONGO_CONN_LOCAL; | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_database(LogDriver *d, const gchar *database) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using database() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
g_free(self->db); | ||
self->db = g_strdup(database); | ||
self->is_legacy = TRUE; | ||
} | ||
|
||
void | ||
afmongodb_dd_set_safe_mode(LogDriver *d, gboolean state) | ||
{ | ||
MongoDBDestDriver *self = (MongoDBDestDriver *)d; | ||
|
||
msg_warning_once( | ||
"WARNING: Using safe_mode() option is deprecated in mongodb driver, please use uri() instead", NULL); | ||
|
||
self->safe_mode = state; | ||
self->is_legacy = TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2010-2016 Balabit | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#ifndef AFMONGODB_LEGACY_GRAMMAR_H_ | ||
#define AFMONGODB_LEGACY_GRAMMAR_H_ | ||
|
||
#include "driver.h" | ||
|
||
gboolean afmongodb_dd_check_address(LogDriver *d, gboolean local); | ||
void afmongodb_dd_set_servers(LogDriver *d, GList *servers); | ||
void afmongodb_dd_set_host(LogDriver *d, const gchar *host); | ||
void afmongodb_dd_set_port(LogDriver *d, gint port); | ||
void afmongodb_dd_set_database(LogDriver *d, const gchar *database); | ||
void afmongodb_dd_set_user(LogDriver *d, const gchar *user); | ||
void afmongodb_dd_set_password(LogDriver *d, const gchar *password); | ||
void afmongodb_dd_set_safe_mode(LogDriver *d, gboolean state); | ||
void afmongodb_dd_set_path(LogDriver *d, const gchar *path); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2010-2016 Balabit | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#ifndef AFMONGODB_LEGACY_PRIVATE_H_ | ||
#define AFMONGODB_LEGACY_PRIVATE_H_ | ||
|
||
#include "afmongodb-private.h" | ||
|
||
#define MONGO_CONN_LOCAL -1 | ||
|
||
typedef struct _MongoDBHostPort | ||
{ | ||
char *host; | ||
gint port; | ||
} MongoDBHostPort; | ||
|
||
#endif |
Oops, something went wrong.