- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

admin_enabled.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // admin_enabled.cpp
19 //
20
21 #include "gdef.h"
22 #include "gsmtp.h"
23 #include "admin.h"
24 #include "legal.h"
25 #include "gssl.h"
26
27 bool Main::Admin::enabled()
28 {
29 return true ;
30 }
31
32 std::auto_ptr<GSmtp::AdminServer> Main::Admin::newServer( const Configuration & cfg ,
33 GSmtp::MessageStore & store , const GSmtp::Client::Config & client_config ,
34 const GAuth::Secrets & client_secrets , const std::string & version_number )
35 {
36 GNet::Address local_address =
37 cfg.clientInterface().length() ?
38 GNet::Address(cfg.clientInterface(),0U) :
39 GNet::Address(0U) ;
40
41 G::StringMap extra_commands_map ;
42 extra_commands_map.insert( std::make_pair(std::string("version"),version_number) ) ;
43 extra_commands_map.insert( std::make_pair(std::string("warranty"),
44 Legal::warranty(std::string(),std::string(1U,'\n'))) ) ;
45 extra_commands_map.insert( std::make_pair(std::string("credit"),
46 GSsl::Library::credit(std::string(),std::string(1U,'\n'),std::string())) ) ;
47 extra_commands_map.insert( std::make_pair(std::string("copyright"),Legal::copyright()) ) ;
48
49 std::auto_ptr<GSmtp::AdminServer> server ;
50 server <<= new GSmtp::AdminServer(
51 store ,
52 client_config ,
53 client_secrets ,
54 GNet::MultiServer::addressList( cfg.listeningInterfaces("admin") , cfg.adminPort() ) ,
55 cfg.allowRemoteClients() ,
56 local_address ,
57 cfg.serverAddress() ,
58 cfg.connectionTimeout() ,
59 extra_commands_map ,
60 cfg.withTerminate() ) ;
61
62 return server ;
63 }
64
65 void Main::Admin::notify( GSmtp::AdminServer & s , const std::string & p1 ,
66 const std::string & p2 , const std::string & p3 )
67 {
68 s.notify( p1 , p2 , p3 ) ;
69 }
70
71 void Main::Admin::report( const GSmtp::AdminServer & s )
72 {
73 s.report() ;
74 }
GNet::MultiServer::addressList
static AddressList addressList(const Address &)
A trivial convenience fuction that returns the given addresses as a single-element list...
Definition: gmultiserver.cpp:41
gssl.h
Main::Legal::copyright
static std::string copyright()
Returns the copyright text.
Definition: legal.cpp:26
GSmtp::AdminServer
A server class which implements the emailrelay administration interface.
Definition: gadminserver.h:112
Main::Configuration::serverAddress
std::string serverAddress() const
Returns the downstream server's address string.
Definition: configuration.cpp:145
GSmtp::AdminServer::notify
void notify(const std::string &s0, const std::string &s1, const std::string &s2)
Called when something happens which the admin user might be interested in.
Definition: gadminserver.cpp:350
Main::Legal::warranty
static std::string warranty(const std::string &prefix, const std::string &eol)
Returns the warranty text.
Definition: legal.cpp:31
GNet::Address
The Address class encapsulates an IP transport address.
Definition: gaddress.h:48
GSmtp::AdminServer::report
void report() const
Generates helpful diagnostics.
Definition: gadminserver.cpp:345
Main::Configuration::allowRemoteClients
bool allowRemoteClients() const
Returns true if allowing remote clients to connect.
Definition: configuration.cpp:239
Main::Configuration::listeningInterfaces
G::Strings listeningInterfaces(const std::string &protocol=std::string()) const
Returns the listening interface(s).
Definition: configuration.cpp:77
Main::Admin::enabled
static bool enabled()
Returns true if newServer() is fully implemented.
Definition: admin_enabled.cpp:27
GSmtp::MessageStore
A class which allows SMTP messages (envelope+content) to be stored and retrieved. ...
Definition: gmessagestore.h:45
GAuth::Secrets
A simple interface to a store of secrets as used in authentication.
Definition: gsecrets.h:44
admin.h
Main::Admin::newServer
static std::auto_ptr< GSmtp::AdminServer > newServer(const Configuration &, GSmtp::MessageStore &store, const GSmtp::Client::Config &, const GAuth::Secrets &client_secrets, const std::string &version_number)
A factory function for creating a new GSmtp::AdminServer instance on the heap.
Definition: admin_enabled.cpp:32
GSsl::Library::credit
static std::string credit(const std::string &prefix, const std::string &eol, const std::string &final)
Returns a credit string.
Definition: gssl_openssl.cpp:271
Main::Configuration::connectionTimeout
unsigned int connectionTimeout() const
Returns the client-side connection timeout value.
Definition: configuration.cpp:324
legal.h
GSmtp::Client::Config
A structure containing GSmtp::Client configuration parameters.
Definition: gsmtpclient.h:61
Main::Configuration::withTerminate
bool withTerminate() const
Returns true if the admin interface should support the terminate command.
Definition: configuration.cpp:349
Main::Configuration::clientInterface
std::string clientInterface() const
Returns the sending interface.
Definition: configuration.cpp:98
Main::Admin::report
static void report(const GSmtp::AdminServer &server)
Calls report() on the given server.
Definition: admin_enabled.cpp:71
G::StringMap
std::map< std::string, std::string > StringMap
A std::map of std::strings.
Definition: gstrings.h:49
gsmtp.h
Main::Configuration::adminPort
unsigned int adminPort() const
Returns the admin port number.
Definition: configuration.cpp:120
Main::Configuration
An interface for returning application configuration information.
Definition: configuration.h:45
Main::Admin::notify
static void notify(GSmtp::AdminServer &server, const std::string &, const std::string &, const std::string &)
Calls notify() on the given server.
Definition: admin_enabled.cpp:65