Changeset - 35c13f038f69
[Not reviewed]
0 4 0
Jan Kaluza - 13 years ago 2012-08-29 15:33:43
hanzz.k@gmail.com
Hidden password, allow seeting port
4 files changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/main.cpp
Show inline comments
 
@@ -136,13 +136,13 @@ int main(int argc, char **argv)
 
	}
 
	else if (command[0] == "list") {
 
		std::vector<std::string> list = show_list(&config);
 
	}
 
	else if (command[0] == "server") {
 
		Server server(&config);
 
		server.start(8080);
 
		server.start();
 
		while (1) { sleep(10); }
 
	}
 
	else {
 
		if (command.size() < 2) {
 
			std::cout << desc << "\n";
 
			return 11;
spectrum_manager/src/managerconfig.cpp
Show inline comments
 
@@ -28,12 +28,13 @@ bool ManagerConfig::load(const std::string &configfile, boost::program_options::
 
	if (!ifs.is_open())
 
		return false;
 

	
 
	opts.add_options()
 
		("service.admin_username", value<std::string>()->default_value(""), "Administrator username.")
 
		("service.admin_password", value<std::string>()->default_value(""), "Administrator password.")
 
		("service.port", value<int>()->default_value(8081), "Web interface port.")
 
		("service.config_directory", value<std::string>()->default_value("/etc/spectrum2/transports/"), "Directory with spectrum2 configuration files. One .cfg file per one instance")
 
		("servers.server", value<std::vector<std::string> >()->multitoken(), "Server.")
 
	;
 

	
 
	store(parse_config_file(ifs, opts), m_variables);
 
	notify(m_variables);
spectrum_manager/src/server.cpp
Show inline comments
 
@@ -155,15 +155,15 @@ Server::~Server() {
 

	
 
static void *_event_handler(enum mg_event event, struct mg_connection *conn) {
 
	const struct mg_request_info *request_info = mg_get_request_info(conn);
 
	return static_cast<Server *>(request_info->user_data)->event_handler(event, conn);
 
}
 

	
 
bool Server::start(int port) {
 
bool Server::start() {
 
	const char *options[] = {
 
		"listening_ports", boost::lexical_cast<std::string>(port).c_str(),
 
		"listening_ports", boost::lexical_cast<std::string>(CONFIG_INT(m_config, "service.port")).c_str(),
 
		"num_threads", "1",
 
		NULL
 
	};
 

	
 
	// Setup and start Mongoose
 
	if ((ctx = mg_start(&_event_handler, this, options)) == NULL) {
 
@@ -293,13 +293,13 @@ void Server::serve_login(struct mg_connection *conn, const struct mg_request_inf
 
  <body>\
 
    <center>\
 
      <h2>Spectrum 2 web interface login</h2>\
 
      <br/>\
 
      <form action=\"/authorize\">\
 
        Username: <input type=\"text\" name=\"user\"></input><br/>\
 
        Password: <input type=\"text\" name=\"password\"></input><br/>\
 
        Password: <input type=\"password\" name=\"password\"></input><br/>\
 
        <input type=\"submit\" value=\"Login\"></input>\
 
      </form>\
 
    </center>\
 
  </body>\
 
</html>";
 

	
spectrum_manager/src/server.h
Show inline comments
 
@@ -43,13 +43,13 @@ class Server {
 
		/// Constructor.
 
		Server(ManagerConfig *config);
 

	
 
		/// Destructor
 
		virtual ~Server();
 

	
 
		bool start(int port);
 
		bool start();
 

	
 
		void *event_handler(enum mg_event event, struct mg_connection *conn);
 

	
 
	private:
 
		void serve_login(struct mg_connection *conn, const struct mg_request_info *request_info);
 
		void serve_root(struct mg_connection *conn, const struct mg_request_info *request_info);
0 comments (0 inline, 0 general)