MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Data Structures | Functions | Variables
Controller Namespace Reference

Holds everything unique to the controller. More...

Data Structures

class  cpudata
 A class storing information about the cpu the server is running on. More...
 
struct  liveCheck
 
class  sessIndex
 This is a comparison and storage class that keeps sessions apart from each other. More...
 
struct  statLog
 
class  statSession
 A session class that keeps track of both current and archived connections. More...
 
class  statStorage
 

Functions

void AddStreams (JSON::Value &in, JSON::Value &out)
 
bool authorize (JSON::Value &Request, JSON::Value &Response, Socket::Connection &conn)
 Checks an authorization request for a given user. More...
 
static void buildPipedArguments (JSON::Value &p, char *argarr[], const JSON::Value &capabilities)
 
static void builPipedPart (JSON::Value &p, char *argarr[], int &argnum, const JSON::Value &argset)
 
bool CheckAllStreams (JSON::Value &data)
 Checks all streams, restoring if needed. More...
 
void checkAvailProtocols ()
 Aquire list of available protocols, storing in global 'capabilities' JSON::Value. More...
 
void checkCapable (JSON::Value &capa)
 Checks the capabilities of the system. More...
 
void checkConfig (JSON::Value &in, JSON::Value &out)
 Check the submitted configuration and handle things accordingly. More...
 
bool CheckProtocols (JSON::Value &p, const JSON::Value &capabilities)
 Checks current protocol configuration, updates state of enabled connectors if neccessary. More...
 
void checkServerLimits ()
 
void checkStream (std::string name, JSON::Value &data)
 Checks the validity of a stream, updates internal stream status. More...
 
void checkStreamLimits (std::string streamName, long long currentKbps, long long connectedUsers)
 
void CheckStreams (JSON::Value &in, JSON::Value &out)
 Parse a given stream configuration. More...
 
JSON::Value CheckUpdateInfo ()
 
void CheckUpdates ()
 Calls CheckUpdateInfo(), uses the resulting JSON::Value to download any needed updates. More...
 
void deleteStream (const std::string &name, JSON::Value &out)
 
void fillActive (JSON::Value &req, JSON::Value &rep, bool onlyNow=false)
 This takes a "active_streams" request, and fills in the response data. More...
 
void fillClients (JSON::Value &req, JSON::Value &rep)
 This takes a "clients" request, and fills in the response data. More...
 
void fillTotals (JSON::Value &req, JSON::Value &rep)
 This takes a "totals" request, and fills in the response data. More...
 
std::string getCountry (std::string ip)
 
int handleAPIConnection (Socket::Connection &conn)
 Handles a single incoming API connection. More...
 
void handleMsg (void *err)
 Handles output of a Mist application, detecting and catching debug messages. More...
 
bool hasViewers (std::string streamName)
 Returns true if this stream has at least one connected client. More...
 
std::string hostLookup (std::string ip)
 
bool isBlacklisted (std::string host, std::string streamName, int timeConnected)
 
void killStatistics (char *data, size_t len, unsigned int id)
 Forces a disconnect to all users. More...
 
void Log (std::string kind, std::string message)
 Store and print a log message. More...
 
bool onList (std::string ip, std::string list)
 
void parseStatistics (char *data, size_t len, unsigned int id)
 This function is called by the shared memory page that holds statistics. More...
 
std::string readFile (std::string filename)
 
void SharedMemStats (void *config)
 This function runs as a thread and roughly once per second retrieves statistics from all connected clients, as well as wipes old statistics that have disconnected over 10 minutes ago. More...
 
bool streamsEqual (JSON::Value &one, JSON::Value &two)
 Checks whether two streams are equal. More...
 
void updateComponent (const std::string &component, const std::string &md5sum, Socket::Connection &updrConn)
 Attempts to download an update for the listed component. More...
 
void UpdateProtocol (std::string protocol)
 Checks if the binary mentioned in the protocol argument is currently active, if so, restarts it. More...
 
void uplinkConnection (void *np)
 
void writeConfig ()
 Writes the current config to shared memory to be used in other processes. More...
 
bool WriteFile (std::string Filename, std::string contents)
 Write contents to Filename. More...
 
bool writeFile (std::string filename, std::string &contents)
 

Variables

JSON::Value capabilities
 Global storage of capabilities. More...
 
Util::Config conf
 Global storage of configuration. More...
 
tthread::mutex configMutex
 Mutex for server config access. More...
 
std::map< unsigned long, sessIndexconnToSession
 Map of socket IDs to session info. More...
 
static std::map< std::string, pid_t > currentConnectors
 The currently running connectors. More...
 
std::map< std::string, pid_t > inputProcesses
 
bool killOnExit = KILL_ON_EXIT
 
tthread::mutex logMutex
 Mutex for log thread. More...
 
bool restarting = false
 Signals if the controller is shutting down (false) or restarting (true). More...
 
std::map< sessIndex, statSessionsessions
 list of sessions that have statistics data available More...
 
tthread::mutex statsMutex
 
JSON::Value Storage
 Global storage of data. More...
 
std::string uniqId
 
JSON::Value updates
 

Detailed Description

Holds everything unique to the controller.

Function Documentation

void Controller::AddStreams ( JSON::Value in,
JSON::Value out 
)
Trigger:
The "STREAM_ADD" trigger is stream-specific, and is ran whenever a new stream is added to the server configuration.

If cancelled, the stream is not added. Its payload is:

streamname
configuration in JSON format

The "STREAM_CONFIG" trigger is stream-specific, and is ran whenever a stream's configuration is changed. If cancelled, the configuration is not changed. Its payload is:

streamname
configuration in JSON format
bool Controller::authorize ( JSON::Value Request,
JSON::Value Response,
Socket::Connection conn 
)

Checks an authorization request for a given user.

Parameters
RequestThe request to be parsed.
ResponseThe location to store the generated response.
connThe user to be checked for authorization.
Returns
True on successfull authorization, false otherwise.
API call:
To login, an "authorize" request must be sent. Since HTTP does not use persistent connections, you are required to re-sent authentication with every API request made. To prevent plaintext sending of the password, a random challenge string is sent first, and then the password is hashed together with this challenge string to create a one-time-use string to login with. If the user is not authorized, this request is the only request the server will respond to until properly authorized. "authorize" requests take the form of:
{
//username to login as
"username": "test",
//hash of password to login with. Send empty value when no challenge for the hash is known yet.
//When the challenge is known, the value to be used here can be calculated as follows:
// MD5( MD5("secret") + challenge)
//Where "secret" is the plaintext password.
"password": ""
}
and are responded to as:
{
//current login status. Either "OK", "CHALL", "NOACC" or "ACC_MADE".
"status": "CHALL",
//Random value to be used in hashing the password.
"challenge": "abcdef1234567890"
}
The challenge string is sent for all statuses, except "NOACC", where it is left out. A status of "OK" means you are currently logged in and have access to all other API requests. A status of "CHALL" means you are not logged in, and a challenge has been provided to login with. A status of "NOACC" means there are no valid accounts to login with. In this case - and ONLY in this case - it is possible to create a initial login through the API itself. To do so, send a request as follows:
{
//username to create, as plain text
"new_username": "test",
//password to set, as plain text
"new_password": "secret"
}
Please note that this is NOT secure. At all. Never use this mechanism over a public network! A status of "ACC_MADE" indicates the account was created successfully and can now be used to login as normal.
static void Controller::buildPipedArguments ( JSON::Value p,
char *  argarr[],
const JSON::Value capabilities 
)
inlinestatic
static void Controller::builPipedPart ( JSON::Value p,
char *  argarr[],
int &  argnum,
const JSON::Value argset 
)
inlinestatic
bool Controller::CheckAllStreams ( JSON::Value data)

Checks all streams, restoring if needed.

Parameters
dataThe stream configuration for the server.
Returns
True if the server status changed
void Controller::checkAvailProtocols ( )

Aquire list of available protocols, storing in global 'capabilities' JSON::Value.

void Controller::checkCapable ( JSON::Value capa)

Checks the capabilities of the system.

Parameters
capaThe location to store the capabilities.
API call:
"capabilities" requests are always empty:
{}
and are responded to as:
{
"connectors": { // a list of installed connectors
"FLV": { //name of the connector. This is based on the executable filename, with the "MistIn" / "MistConn" prefix stripped.
"codecs": [ //supported combinations of codecs.
[["H264","H263","VP6"],["AAC","MP3"]] //one such combination, listing simultaneously available channels and the codec options for those channels
],
"deps": "HTTP", //dependencies on other connectors, if any.
"desc": "Enables HTTP protocol progressive streaming.", //human-friendly description of this connector
"methods": [ //list of supported request methods
{
"handler": "http", //what handler to use for this request method. The "http://" part of a URL, without the "://".
"priority": 5, // priority of this request method, higher is better.
"type": "flash/7" //type of request method - usually name of plugin followed by the minimal plugin version, or 'HTML5' for pluginless.
}
],
"name": "HTTP_Progressive_FLV", //Full name of this connector.
"optional": { //optional parameters
"username": { //name of the parameter
"help": "Username to drop privileges to - default if unprovided means do not drop privileges", //human-readable help text
"name": "Username", //human-readable name of parameter
"option": "--username", //command-line option to use
"type": "str" //type of option - "str" or "num"
}
//above structure repeated for all (optional) parameters
},
//above structure repeated, as "required" for required parameters, if any.
"socket": "http_progressive_flv", //unix socket this connector listens on, if any
"url_match": "/$.flv", //URL pattern to match, if any. The $ substitutes the stream name and may not be the first or last character.
"url_prefix": "/progressive/$/", //URL prefix to match, if any. The $ substitutes the stream name and may not be the first or last character.
"url_rel": "/$.flv" //relative URL where to access a stream through this connector.
}
//... above structure repeated for all installed connectors.
},
"cpu": [ //a list of installed CPUs
{
"cores": 4, //amount of cores for this CPU
"mhz": 1645, //speed in MHz for this CPU
"model": "Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz", //model identifier, for humans
"threads": 8 //amount of simultaneously executing threads that are supported on this CPU
}
//above structure repeated for all installed CPUs
],
"load": {
"fifteen": 72,
"five": 81,
"memory": 42,
"one": 124
},
"mem": {
"cached": 1989, //current memory usage of system caches, in MiB
"free": 2539, //free memory, in MiB
"swapfree": 0, //free swap space, in MiB
"swaptotal": 0, //total swap space, in MiB
"total": 7898, //total memory, in MiB
"used": 3370 //used memory, in MiB (excluding system caches, listed separately)
},
"speed": 6580, //total speed in MHz of all CPUs cores summed together
"threads": 8 //total count of all threads of all CPUs summed together
}
void Controller::checkConfig ( JSON::Value in,
JSON::Value out 
)

Check the submitted configuration and handle things accordingly.

Parameters
inThe new configuration.
outThe location to store the resulting configuration.
API call:
"config" requests take the form of:
{
"controller": { //controller settings
"interface": null, //interface to listen on. Defaults to all interfaces.
"port": 4242, //port to listen on. Defaults to 4242.
"username": null //username to drop privileges to. Defaults to root.
},
"protocols": [ //enabled connectors / protocols
{
"connector": "HTTP" //Name of the connector to enable
//any required and/or optional settings may be given here as "name": "value" pairs inside this object.
},
//above structure repeated for all enabled connectors / protocols
],
"serverid": "", //human-readable server identifier, optional.
}
and are responded to as:
{
"controller": { //controller settings
"interface": null, //interface to listen on. Defaults to all interfaces.
"port": 4242, //port to listen on. Defaults to 4242.
"username": null //username to drop privileges to. Defaults to root.
},
"protocols": [ //enabled connectors / protocols
{
"connector": "HTTP" //Name of the connector to enable
//any required and/or optional settings may be given here as "name": "value" pairs inside this object.
"online": 1 //boolean value indicating if the executable is running or not
},
//above structure repeated for all enabled connectors / protocols
],
"serverid": "", //human-readable server identifier, as configured.
"time": 1398982430, //current unix time
"version": "2.0.2/8.0.1-23-gfeb9322/Generic_64" //currently running server version string
}
bool Controller::CheckProtocols ( JSON::Value p,
const JSON::Value capabilities 
)

Checks current protocol configuration, updates state of enabled connectors if neccessary.

Checks current protocol configuration, updates state of enabled connectors if neccesary.

Parameters
pAn object containing all protocols.
capabilitiesAn object containing the detected capabilities.
Returns
True if any action was taken
Trigger:
The "OUTPUT_START" trigger is global, and is ran whenever a new protocol listener is started. It cannot be cancelled. Its payload is:
output listener commandline
The "OUTPUT_STOP" trigger is global, and is ran whenever a protocol listener is terminated. It cannot be cancelled. Its payload is:
output listener commandline
Todo:
Check dependencies?
void Controller::checkServerLimits ( )
void Controller::checkStream ( std::string  name,
JSON::Value data 
)

Checks the validity of a stream, updates internal stream status.

Parameters
nameThe name of the stream
dataThe corresponding configuration values.
void Controller::checkStreamLimits ( std::string  streamName,
long long  currentKbps,
long long  connectedUsers 
)
void Controller::CheckStreams ( JSON::Value in,
JSON::Value out 
)

Parse a given stream configuration.

Parameters
inThe requested configuration.
outThe new configuration after parsing.
API call:
"streams" requests take the form of:
{
"streamname_here": { //name of the stream
"source": "/mnt/media/a.dtsc" //full path to a VoD file, or "push://" followed by the IP or hostname of the machine allowed to push live data. Empty means everyone is allowed to push live data.
"DVR": 30000 //optional. For live streams, indicates the requested minimum size of the available DVR buffer in milliseconds.
},
//the above structure repeated for all configured streams
}
and are responded to as:
{
"streamname_here": { //name of the configured stream
"error": "Available", //error state, if any. "Available" is a special value for VoD streams, indicating it has no current viewers (is not active), but is available for activation.
"h_meta": 1398113185, //unix time the stream header (if any) was last processed for metadata
"l_meta": 1398115447, //unix time the stream itself was last processed for metadata
"meta": { //available metadata for this stream, if any
"format": "dtsc", //detected media source format
"tracks": { //list of tracks in this stream
"audio_AAC_2ch_48000hz_2": {//human-readable track name
"bps": 16043,
"channels": 2,
"codec": "AAC",
"firstms": 0,
"init": "\u0011Vå\u0000",
"lastms": 596480,
"rate": 48000,
"size": 16,
"trackid": 2,
"type": "audio"
},
//the above structure repeated for all tracks
},
"vod": 1 //indicates VoD stream, or "live" to indicated live stream.
},
"name": "a", //the stream name, guaranteed to be equal to the object name.
"online": 2, //online state. 0 = error, 1 = active, 2 = inactive.
"source": "/home/thulinma/a.dtsc" //source for this stream, as configured.
},
//the above structure repeated for all configured streams
}
Through this request, ALL streams must always be configured. To remove a stream, simply leave it out of the request. To add a stream, simply add it to the request. To edit a stream, simply edit it in the request. The LTS edition has additional requests that allow per-stream changing of the configuration.
JSON::Value Controller::CheckUpdateInfo ( )
API call:
"update" and "checkupdate" requests (LTS-only) are responded to as: ~~~~~~~~~~~~~~~{.js} { "error": "Something went wrong", // 'Optional' "release": "LTS64_99", "version": "1.2 / 6.0.0", "date": "January 5th, 2014", "uptodate": 0, "needs_update": ["MistBuffer", "MistController"], //Controller is guaranteed to be last "MistController": "abcdef1234567890", //md5 sum of latest version //...

all other MD5 sums follow } ~~~~~~~~~~~~~~~ Note that "update" will only list known information, while "checkupdate" triggers an information refresh from the update server.

void Controller::CheckUpdates ( )

Calls CheckUpdateInfo(), uses the resulting JSON::Value to download any needed updates.

Will shut down the server if the JSON::Value contained a "shutdown" member.

void Controller::deleteStream ( const std::string &  name,
JSON::Value out 
)
Trigger:
The "STREAM_REMOVE" trigger is stream-specific, and is ran whenever a stream is removed from the server configuration.

If cancelled, the stream is not removed. Its payload is:

streamname
void Controller::fillActive ( JSON::Value req,
JSON::Value rep,
bool  onlyNow = false 
)

This takes a "active_streams" request, and fills in the response data.

API call:
"active_streams" and "stats_streams" requests may either be empty, in which case the response looks like this:
[
//Array of stream names
"streamA",
"streamB",
"streamC"
]
"stats_streams" will list all streams that any statistics data is available for, and only those. "active_streams" only lists streams that are currently active, and only those. If the request is an array, which may contain any of the following elements:
[
//Array of requested data types
"clients", //Current viewer count
"lastms" //Current position in the live buffer, if live
]
In which case the response is changed into this format:
{
//Object of stream names, containing arrays in the same order as the request, with the same data
"streamA":[
0,
60000
]
"streamB":[
//....
]
//...
}
All streams that any statistics data is available for are listed, and only those streams.
void Controller::fillClients ( JSON::Value req,
JSON::Value rep 
)

This takes a "clients" request, and fills in the response data.

API call:
"clients" requests take the form of:
{
//array of streamnames to accumulate. Empty means all.
"streams": ["streama", "streamb", "streamc"],
//array of protocols to accumulate. Empty means all.
"protocols": ["HLS", "HSS"],
//list of requested data fields. Empty means all.
"fields": ["host", "stream", "protocol", "conntime", "position", "down", "up", "downbps", "upbps"],
//unix timestamp of measuring moment. Negative means X seconds ago. Empty means now.
"time": 1234567
}
OR
[
{},//request object as above
{}//repeat the structure as many times as wanted
]
and are responded to as:
{
//unix timestamp of data. Always present, always absolute.
"time": 1234567,
//array of actually represented data fields.
"fields": [...]
//for all clients, the data in the order they appear in the "fields" field.
"data": [[x, y, z], [x, y, z], [x, y, z]]
}
In case of the second method, the response is an array in the same order as the requests.
void Controller::fillTotals ( JSON::Value req,
JSON::Value rep 
)

This takes a "totals" request, and fills in the response data.

API call:
"totals" requests take the form of:
{
//array of streamnames to accumulate. Empty means all.
"streams": ["streama", "streamb", "streamc"],
//array of protocols to accumulate. Empty means all.
"protocols": ["HLS", "HSS"],
//list of requested data fields. Empty means all.
"fields": ["clients", "downbps", "upbps"],
//unix timestamp of data start. Negative means X seconds ago. Empty means earliest available.
"start": 1234567
//unix timestamp of data end. Negative means X seconds ago. Empty means latest available (usually 'now').
"end": 1234567
}
OR
[
{},//request object as above
{}//repeat the structure as many times as wanted
]
and are responded to as:
{
//unix timestamp of start of data. Always present, always absolute.
"start": 1234567,
//unix timestamp of end of data. Always present, always absolute.
"end": 1234567,
//array of actually represented data fields.
"fields": [...]
// Time between datapoints. Here: 10 points with each 5 seconds afterwards, followed by 10 points with each 1 second afterwards.
"interval": [[10, 5], [10, 1]],
//the data for the times as mentioned in the "interval" field, in the order they appear in the "fields" field.
"data": [[x, y, z], [x, y, z], [x, y, z]]
}
In case of the second method, the response is an array in the same order as the requests.
Todo:
Make the interval configurable instead of 1 second
std::string Controller::getCountry ( std::string  ip)
int Controller::handleAPIConnection ( Socket::Connection conn)

Handles a single incoming API connection.

Assumes the connection is unauthorized and will allow for 4 requests without authorization before disconnecting.

API call:
"addstream" requests (LTS-only) take the form of:
{
"streamname": {
//Stream configuration - see the "streams" call for details on this format.
}
}
These requests will add new streams or update existing streams with the same names, without touching other streams. In other words, this call can be used for incremental updates to the stream list instead of complete updates, like the "streams" call. Sending "addstream" or "deletestream" as part of your request will alter the "streams" response. As opposed to a full list of streams, this will now include a property "incomplete list" set to 1 and only include successfully added streams. As deletions cannot fail, these are never mentioned.
API call:
"deletestream" requests (LTS-only) take the form of:
{
"streamname": {} //any contents in this object are ignored
}
OR
[
"streamname",
]
OR
"streamname"
These requests will remove the named stream(s), without touching other streams. In other words, this call can be used for incremental updates to the stream list instead of complete updates, like the "streams" call. Sending "addstream" or "deletestream" as part of your request will alter the "streams" response. As opposed to a full list of streams, this will now include a property "incomplete list" set to 1 and only include successfully added streams. As deletions cannot fail, these are never mentioned.
API call:
"addprotocol" requests (LTS-only) take the form of:
{
"connector": "HTTP" //Name of the connector to enable
//any required and/or optional settings may be given here as "name": "value" pairs inside this object.
}
OR
[
{
"connector": "HTTP" //Name of the connector to enable
//any required and/or optional settings may be given here as "name": "value" pairs inside this object.
}
]
These requests will add the given protocol configurations, without touching existing configurations. In other words, this call can be used for incremental updates to the protocols list instead of complete updates, like the "config" call. There is no response to this call.
API call:
"deleteprotocol" requests (LTS-only) take the form of:
{
"connector": "HTTP" //Name of the connector to enable
//any required and/or optional settings may be given here as "name": "value" pairs inside this object.
}
OR
[
{
"connector": "HTTP" //Name of the connector to enable
//any required and/or optional settings may be given here as "name": "value" pairs inside this object.
}
]
These requests will remove the given protocol configurations (exact matches only), without touching other configurations. In other words, this call can be used for incremental updates to the protocols list instead of complete updates, like the "config" call. There is no response to this call.
Todo:
Re-enable conversion API at some point.

This takes a "browse" request, and fills in the response data.

API call:
"browse" requests take the form of:
//A string, containing the path for which to discover contents. Empty means current working directory.
"/tmp/example"
and are responded to as:
[
//The folder path
"path":"/tmp/example"
//An array of strings showing all files
"files":
["file1.dtsc",
"file2.mp3",
"file3.exe"
]
//An array of strings showing all subdirectories
"subdirectories":[
"folder1"
]
]
API call:
"save" requests are always empty:
{}
Sending this request will cause the controller to write out its currently active configuration to the configuration file it was loaded from (the default being ./config.json).
API call:
"ui_settings" requests can take two forms. The first is the "set" form:
{
//Any data here
}
The second is the "request" form, and takes any non-object as argument. When using the set form, this will write the given object verbatim into the controller storage. No matter which form is used, the current contents of the ui_settings object are always returned in the response. This API call is intended to store User Interface settings across sessions, and its contents are completely ignored by the controller itself. Besides the requirement of being an object, the contents are entirely free-form and may technically be used for any purpose.
API call:
LTS builds will always include an "LTS" response, set to 1.
API call:
"autoupdate" requests (LTS-only) will cause MistServer to apply a rolling update to itself, and are not responded to.
API call:
"log" responses are always sent, and cannot be requested:
[
[
1398978357, //unix timestamp of this log message
"CONF", //shortcode indicating the type of log message
"Starting connector: {\"connector\":\"HTTP\"}" //string containing the log message itself
],
//the above structure repeated for all logs
]
It's possible to clear the stored logs by sending an empty "clearstatlogs" request.
void Controller::handleMsg ( void *  err)

Handles output of a Mist application, detecting and catching debug messages.

Debug messages are automatically converted into Log messages. Closes the file descriptor on read error.

Parameters
errFile descriptor of the stderr output of the process to monitor.
bool Controller::hasViewers ( std::string  streamName)

Returns true if this stream has at least one connected client.

std::string Controller::hostLookup ( std::string  ip)
bool Controller::isBlacklisted ( std::string  host,
std::string  streamName,
int  timeConnected 
)
void Controller::killStatistics ( char *  data,
size_t  len,
unsigned int  id 
)

Forces a disconnect to all users.

void Controller::Log ( std::string  kind,
std::string  message 
)

Store and print a log message.

Parameters
kindThe type of message.
messageThe message to be logged.
bool Controller::onList ( std::string  ip,
std::string  list 
)
void Controller::parseStatistics ( char *  data,
size_t  len,
unsigned int  id 
)

This function is called by the shared memory page that holds statistics.

It updates the internally saved statistics data, moving across sessions or archiving when neccessary.

std::string Controller::readFile ( std::string  filename)
void Controller::SharedMemStats ( void *  config)

This function runs as a thread and roughly once per second retrieves statistics from all connected clients, as well as wipes old statistics that have disconnected over 10 minutes ago.

bool Controller::streamsEqual ( JSON::Value one,
JSON::Value two 
)

Checks whether two streams are equal.

Parameters
oneThe first stream for the comparison.
twoThe second stream for the comparison.
Returns
True if the streams are equal, false otherwise.
Todo:
Change this to use capabilities["inputs"] and only compare required/optional parameters.
Todo:
Maybe change this to check for correct source and/or required parameters.
void Controller::updateComponent ( const std::string &  component,
const std::string &  md5sum,
Socket::Connection updrConn 
)

Attempts to download an update for the listed component.

Parameters
componentFilename of the component being checked.
md5sumThe MD5 sum of the latest version of this file.
updrConnAn connection to releases.mistserver.org to (re)use. Will be (re)opened if closed.
void Controller::UpdateProtocol ( std::string  protocol)

Checks if the binary mentioned in the protocol argument is currently active, if so, restarts it.

Parameters
protocolThe protocol to check.
void Controller::uplinkConnection ( void *  np)
void Controller::writeConfig ( )

Writes the current config to shared memory to be used in other processes.

Trigger:
The "SYSTEM_START" trigger is global, and is ran as soon as the server configuration is first stable.

It has no payload. If cancelled, the system immediately shuts down again.
The "SYSTEM_CONFIG" trigger is global, and is ran every time the server configuration is updated. Its payload is the new configuration in JSON format. This trigger cannot be cancelled.

bool Controller::WriteFile ( std::string  Filename,
std::string  contents 
)

Write contents to Filename.

Parameters
FilenameThe full path of the file to write to.
contentsThe data to be written to the file.
bool Controller::writeFile ( std::string  filename,
std::string &  contents 
)

Variable Documentation

JSON::Value Controller::capabilities

Global storage of capabilities.

Util::Config Controller::conf

Global storage of configuration.

tthread::mutex Controller::configMutex

Mutex for server config access.

std::map< unsigned long, Controller::sessIndex > Controller::connToSession

Map of socket IDs to session info.

std::map<std::string, pid_t> Controller::currentConnectors
static

The currently running connectors.

std::map<std::string, pid_t> Controller::inputProcesses
bool Controller::killOnExit = KILL_ON_EXIT
tthread::mutex Controller::logMutex

Mutex for log thread.

bool Controller::restarting = false

Signals if the controller is shutting down (false) or restarting (true).

std::map< Controller::sessIndex, Controller::statSession > Controller::sessions

list of sessions that have statistics data available

tthread::mutex Controller::statsMutex
JSON::Value Controller::Storage

Global storage of data.

std::string Controller::uniqId
JSON::Value Controller::updates