| 1 | /**************************************************************************
|
|---|
| 2 | * Copyright (C) 2004-2007 by Michael Medin <michael@medin.name> *
|
|---|
| 3 | * *
|
|---|
| 4 | * This code is part of NSClient++ - http://trac.nakednuns.org/nscp *
|
|---|
| 5 | * *
|
|---|
| 6 | * This program is free software; you can redistribute it and/or modify *
|
|---|
| 7 | * it under the terms of the GNU General Public License as published by *
|
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or *
|
|---|
| 9 | * (at your option) any later version. *
|
|---|
| 10 | * *
|
|---|
| 11 | * This program is distributed in the hope that it will be useful, *
|
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|---|
| 14 | * GNU General Public License for more details. *
|
|---|
| 15 | * *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License *
|
|---|
| 17 | * along with this program; if not, write to the *
|
|---|
| 18 | * Free Software Foundation, Inc., *
|
|---|
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|---|
| 20 | ***************************************************************************/
|
|---|
| 21 | #include <socket_helpers.hpp>
|
|---|
| 22 | #include <check_nt/server/protocol.hpp>
|
|---|
| 23 |
|
|---|
| 24 | class NSClientServer : public nscapi::impl::simple_plugin, public check_nt::server::handler {
|
|---|
| 25 | public:
|
|---|
| 26 | NSClientServer();
|
|---|
| 27 | virtual ~NSClientServer();
|
|---|
| 28 | // Module calls
|
|---|
| 29 | bool loadModuleEx(std::string alias, NSCAPI::moduleLoadMode mode);
|
|---|
| 30 | bool unloadModule();
|
|---|
| 31 |
|
|---|
| 32 | check_nt::packet handle(check_nt::packet packet);
|
|---|
| 33 |
|
|---|
| 34 | check_nt::packet create_error(std::wstring msg) {
|
|---|
| 35 | return check_nt::packet("ERROR: Failed to parse");
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | void log_debug(std::string module, std::string file, int line, std::string msg) const {
|
|---|
| 39 | if (GET_CORE()->should_log(NSCAPI::log_level::debug)) {
|
|---|
| 40 | GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg);
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 | void log_error(std::string module, std::string file, int line, std::string msg) const {
|
|---|
| 44 | if (GET_CORE()->should_log(NSCAPI::log_level::error)) {
|
|---|
| 45 | GET_CORE()->log(NSCAPI::log_level::error, file, line, msg);
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | std::string get_password() const {
|
|---|
| 50 | return password_;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | private:
|
|---|
| 54 | void set_password(std::string password) {
|
|---|
| 55 | password_ = password;
|
|---|
| 56 | }
|
|---|
| 57 | virtual void set_allow_arguments(bool v) {
|
|---|
| 58 | allowArgs_ = v;
|
|---|
| 59 | }
|
|---|
| 60 | virtual void set_allow_nasty_arguments(bool v) {
|
|---|
| 61 | allowNasty_ = v;
|
|---|
| 62 | }
|
|---|
| 63 | virtual void set_perf_data(bool v) {
|
|---|
| 64 | noPerfData_ = !v;
|
|---|
| 65 | }
|
|---|
| 66 | bool isPasswordOk(std::string remotePassword);
|
|---|
| 67 |
|
|---|
| 68 | private:
|
|---|
| 69 | bool noPerfData_;
|
|---|
| 70 | bool allowNasty_;
|
|---|
| 71 | bool allowArgs_;
|
|---|
| 72 |
|
|---|
| 73 | socket_helpers::connection_info info_;
|
|---|
| 74 | boost::shared_ptr<check_nt::server::server> server_;
|
|---|
| 75 | std::string password_;
|
|---|
| 76 |
|
|---|
| 77 | }; |
|---|