Player APIs (BrightScript & Ja...
JavaScript APIs

hostconfiguration

10min
the hostconfiguration object allows you to retrieve information about network interfaces and internet connectivity hostconfiguration idl interface networkhost { hostconfig defaultconfig(); promise\<hostconfig> getconfig(); promise\<void> applyconfig(hostconfigwritable config); }; interface hostconfig { \[optional] attribute string proxy; \[optional] attribute array\<string> proxybypasslist; \[optional] attribute array\<string> timeserverlist; \[optional] attribute string timeserverinterval; \[optional] attribute string hostname; &#x9;\[optional] attribute bool loginpassword; \[optional] attribute bool forwardingenabled; \[optional] attribute bool masqueradingenabled; &#x9;\[optional] attribute array\<natrule> natlist; }; interface hostconfigwritable hostconfig { \[optional] attribute string\[or bool] loginpassword; \[optional] attribute string\[or bool] obfuscatedloginpassword; }; interface natrule { attribute natrulematch match; attribute natrulereplacement replace; }; interface natrulematch { attribute string protocol; \[optional] attribute string sourceaddressrange; attribute string destinationaddressrange; attribute unsigned short destinationport; }; interface natrulereplacement { attribute string destinationaddress; attribute unsigned short destinationport; }; object creation to create a hostconfiguration object, first load the brightsign/hostconfiguration module using the require() method then create an instance of the hostconfiguration class var hostconfigurationclass = require("@brightsign/hostconfiguration"); var hc = new hostconfigurationclass(); networkhost use this interface to retrieve and modify host configuration getconfig() promise\<hostconfig> getconfig() returns a hostconfig interface containing current host configuration information applyconfig() promise\<void> applyconfig(hostconfigwritable config) applies host configuration settings to the player this method accepts a hostconfigwritable interface the config parameter should contain the complete desired configuration any previous configuration is overwritten if you wish to change one item while keeping the rest of the configuration the same, then call getconfig and modify the returned object (see the example in the examples section) hostconfig this interface contains host configuration parameters proxy string string the name or address of the proxy server used for http and ftp requests the proxy string should be formatted as "http //user\ password\@hostname\ port" the hostname can contain up to four " " characters; each " " character can be used to replace one octet from the current ip address for example, if the ip address is currently 192 168 1 2, and the proxy is set to "proxy ", then the player will attempt to use a proxy named "proxy 192 168" proxybypasslist array array \<string> \<string> a list of hostnames exempted from the proxy setting the player will attempt to reach the specified hosts directly rather than using the proxy specified in the proxy attribute for example, the hostname "example com" would exempt "example com", "example com 80", and "www example com" from the proxy setting timeserverlist array array \<string> \<string> an array containing zero or one time servers to be used by the player an empty array disables automatic setting of the player's clock a single entry indicates the time server and protocol that should be used as a url supported protocols are http, https and ntp for backward compatibility the use of just a host name is supported and indicates that ntp should be used note that when using https, host and peer verification are disabled since the player clock may not be correct the following are valid time server addresses http //time brightsignnetwork com/ https //time brightsignnetwork com/ ntp\ //time brightsignnetwork com/ time brightsignnetwork com timeserverinterval string string a value specifying how often (in seconds) the player should communicate with the time server to adjust its clock the default interval is 12 hours the minimum interval allowed is 120 seconds hostname string string the player host name if no host name has been explicitly set, then a host name is automatically generated based on the device serial number passing an empty string to this method resets the device host name to its automatically generated value loginpassword bool bool a value of true means that the password exists, false means that there is no password forwardingenabled bool bool enables or disables ip forwarding ip forwarding is disabled ( false ) by default masqueradingenabled bool bool enables or disables source address translation with ip forwarding if forwardingenabled is true, masqueradingenabled must be specified as true or false if masqueradingenabled is false, ip datagrams are forwarded between all interfaces and no address translation is done if masqueradingenabled is true, ip datagrams are forwarded between all interfaces, but snat https //ipwithease com/snat vs dnat/ is applied to any datagrams which are sent out of an "upstream" interface (any interface or interfaces on which a default route is set) datagrams destined for an interface that has no default route are forwarded without nat https //ipwithease com/snat vs dnat/ natlist array\<natrule> array\<natrule> a list of dnat https //ipwithease com/snat vs dnat/ rules which lets users change the destination address and port of a packet hostconfigwritable this interface contains password settings for ssh when writing settings using the applyconfig() method, some members of the hostconfig interface have special behavior loginpassword string string or bool bool if a string is supplied, sets a plain text login password for the ssh connection (note that ssh must also be enabled separately in the registry for this to be useful) if boolean true is supplied, the existing password (if any) is left unchanged if boolean false is supplied, any existing password is removed obfuscatedloginpassword string string or bool bool as above, except that the password should previously have been obfuscated using a shared secret contact support\@brightsign biz mailto\ support\@brightsign biz to learn more about generating a key for obfuscation and storing it on the player this behavior ensures that code such as getconfig() then((c) => { applyconfig(c); }) preserves any existing password, even though the password itself is not returned by getconfig() natrulematch the rules in this interface are compared to destinations in the tcp or udp packets that enter the player if the packet fields match the properties established in natrulematch , the destination ip and port will be overwritten with the desired values in the natrulesreplacement interface protocol string string filter for "udp" or "tcp" (the entry must be lower case) sourceaddressrange string string optional optional filter for this range of source ip addresses (in cidr https //en wikipedia org/wiki/classless inter domain routing# text=cidr%20introduced%20a%20new%20method,db8%3a%3a%2f32%20for%20ipv6 format) traffic from all source ip addresses will be included if this optional attribute is not specified destinationaddressrange string string the range of destination ip addresses (in cidr https //en wikipedia org/wiki/classless inter domain routing# text=cidr%20introduced%20a%20new%20method,db8%3a%3a%2f32%20for%20ipv6 format) to be overwritten destinationport unsigned short unsigned short the destination port to be overwritten natrulereplacement the address and port properties specified in natrulereplacement are written to the packet to replace selected ip address and port properties destinationaddress string string the ip address that will replace the previous ip address in the destination destinationport unsigned short unsigned short the port that will replace the previous port in the destination examples the following script uses the applyconfig() method to set the hostname, time server, and time server refresh interval var hostconfigurationclass = require("@brightsign/hostconfiguration"); var hc = new hostconfigurationclass(); var configdata = {}; configdata hostname = "myplayer"; configdata proxy = ""; configdata proxybypasslist = \[]; configdata timeserverinterval = 1200; configdata timeserverlist = \["time brightsignnetwork com"]; console log(" configuring host ") hc applyconfig(configdata) then( function() { console log("success"); }) catch( function(data) { console log(json stringify(data)); }); to change one item while keeping the rest of the configuration the same, call getconfig and modify the returned object var hostconfiguration = require('@brightsign/hostconfiguration'); var hostconfiguration = new hostconfiguration; hostconfiguration getconfig() then(function(config) { config hostname = "host brightsign"; hostconfiguration applyconfig(config); }) then(function() { console log("success"); }) catch(function(error) { console log(`${json stringify(error)}`); });