Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DTMFEncodeTable = map[rune]string{ ' ': `0`, '!': `1110`, '@': `1120`, '#': `1130`, '$': `1140`, '%': `1150`, '^': `1160`, '&': `1170`, '*': `1180`, '(': `1190`, '`': `1210`, '~': `1220`, ')': `1230`, '-': `1240`, '_': `1250`, '=': `1260`, '+': `1270`, '[': `1280`, '{': `1290`, ']': `1310`, '}': `1320`, '\\': `1330`, '|': `1340`, ';': `1350`, ':': `1360`, '\'': `1370`, '"': `1380`, ',': `1390`, '<': `1410`, '.': `1420`, '>': `1430`, '/': `1440`, '?': `1450`, toolbox.SubjectReportSerialisedFieldSeparator: `1460`, toolbox.SubjectReportSerialisedLineSeparator: `1470`, '0': `10`, '1': `110`, '2': `120`, '3': `130`, '4': `140`, '5': `150`, '6': `160`, '7': `170`, '8': `180`, '9': `190`, }
DTMFEncodeTable is the mapping between a symbol/number and corresponding DTMF character sequences. This is the partial inverse of DTMFDecodeTable, suffix character 0 from each character sequence is an indication of end of a sequence, sought by DTMFDecode.
Functions ¶
func EncodeToDTMF ¶
EncodeToDTMF encodes the input string into a form acceptable by the DNS daemon's query processor for running an application command. Specifically, the Latin letters remain in-place, numbers and symbols are substituted for DTMF sequences. Later on, when the DNS daemon picks up the encoded string from a query, it will decode the DTMF sequences to recover the original.
The return value must be further split apart into DNS labels of no more than 63 characters each.
func GetDNSQuery ¶
GetDNSQuery constructs a DNS name ready to be queried, the name consists of the input app command with DTMF encoded sequences, the domain name, and the mandatory command query prefix. If necessary, the app command will be truncated to fit into the maximum length of a name query.
func TestServer ¶
func TestServer(server *Daemon, t testingstub.T)
TestServer implements test cases for the phone-home daemon.
Types ¶
type Daemon ¶
type Daemon struct { // MessageProcessorServers is a map between message processor server URL and their configuration. MessageProcessorServers []*MessageProcessorServer `json:"MessageProcessorServers"` // ReportIntervalSec is the interval in seconds at which this daemon reports to the servers. ReportIntervalSec int `json:"ReportIntervalSec"` // LocalMessageProcessor answers to servers' app command requests LocalMessageProcessor *toolbox.MessageProcessor `json:"-"` // cmdProcessor runs app commands coming in from a store&forward message processor server. Processor *toolbox.CommandProcessor `json:"-"` // contains filtered or unexported fields }
Daemon phones home periodically by contacting one or more store&forward message processor servers over app command execution URLs.
func (*Daemon) Initialise ¶
Initialise validates the daemon configuration and initalises internal states.
func (*Daemon) StartAndBlock ¶
StartAndBlock starts the periodic reports and blocks caller until the daemon is stopped.
type MessageProcessorServer ¶
type MessageProcessorServer struct { /* HTTPEndpointURL is the complete URL of endpoint HandleAppCommand that will receive subject reports. If this is set, then DNSDomainName will be ignored. */ HTTPEndpointURL string `json:"HTTPEndpointURL"` /* DNSDomainName is the domain name where laitos DNS server runs to receive subject reports. If this is set, then HTTPEndpointURL will be ignored. */ DNSDomainName string `json:"DNSDomainName"` // Password is the password PIN that the server accepts for command execution. Passwords []string `json:"Passwords"` // HostName is the host name portion of server app command execution URL, it is calculated by Initialise function. HostName string `json:"-"` }
MessageProcessorServer contains server and password password configuration. If the server has an HTTP Endpoint URL, the report will be sent via an HTTP client. Otherwise if the server has a DNS domain name, the report will be sent via DNS TXT query.