Other functions¶
These are some functions that don’t really have a place in one of the other categories.
-
getregisteredname(name):
str¶ Returns the shortest domain name based on Mozilla’s Public Suffix List. In general it will tell you the ‘registered domain’ for a given name.
For example
getregisteredname('www.powerdns.com')returns “powerdns.com”- Parameters:¶
name (
str) – The name to check for.
-
getRecursorThreadId():
int¶ returns an unsigned integer identifying the thread handling the current request.
-
pdnsrandom([
upper_bound])¶ Get a random number.
- Parameters:¶
upper_bound (
int) – The upper bound. You will get a random number below this upper bound.
- spawnThread(script)¶
Added in version 5.2.0.
Spawn a new thread running the supplied Lua script in a newly created Lua context.
- Parameters:¶
script (
str) – The pathname of the Lua script to run.
Note
The putIntoRecordCache() and getRecordCacheRecords() functions are experimental, their functionality might change in upcoming releases.
-
putIntoRecordCache(dump):
int¶ Added in version 5.2.0.
Load a record cache dump into the record cache.
- Parameters:¶
dump (
str) – The data in the proprietary format produced bygetRecordCacheRecords()).- Returns:¶
The number of records inserted into the record cache.
Some record sets might be skipped, for example when they are already present in the record cache or contain specific information not supported yet by this function. If the Recursor determines the version of the data is not compatible, it will skip loading and log an error. In that case 0 is returned.
-
getRecordCacheRecords(perShard, maxSize):
str,int¶ Added in version 5.2.0.
Get a record cache dump in proprietary format.
- Parameters:¶
perShard (
int) – The maximum number of record sets to retrieve per shard. Zero is unlimited.maxSize (
int) – The maximum size of the dump. Zero is unlimited.
- Return:¶
A string representing the record sets and an integer specifying how many record sets were retrieved
This function will scan the most recently used record sets of each shard, picking at most
perShardrecord sets per shard and adding them to the result. If adding a record set’s data to the result would make the result size exceedmaxSize, the remainder of the current shard and further remaining shards are skipped. The format of the string produced is proprietary. The string contains meta information, so the Recursor callingputIntoRecordCache()can check if the data format is compatible.Note that setting both limits to zero can produce very large strings. It is wise to set at least one of the limits. Additionally, setting
maxSizeto zero can lead to less efficient memory management while producing the dump.
-
getConfigDirAndName():
str,str¶ Added in version 5.2.5.
Added in version 5.3.0.
Get the configuration directory and the instance name. These two values correspond to the recursor.config_dir and recursor.config_name settings.
Note
The putIntoNSSPeedTable and getNSSPeedTable functions are experimental, their functionality might change in upcoming releases.
-
putIntoNSSpeedTable(dump):
int¶ Added in version 5.3.0.
Load a nameserver speed table dump
- Parameters:¶
dump (
str) – The data in the proprietary format produced bygetNSSpeedTable()).- Returns:¶
The number of records inserted
Some entries might be skipped, for example when they are expired. If the Recursor determines the version of the data is not compatible, it will skip loading and log an error. In that case 0 is returned.
-
getNSSpeedTable(maxSize):
str,int¶ Added in version 5.3.0.
Get a nameserver speed table dump in proprietary format.
- Parameters:¶
maxSize (
int) – The maximum size of the dump. Zero is unlimited.- Return:¶
A string representing the nameserver speed table and an integer specifying how many record sets were retrieved
If adding an entry’s data to the result would make the result size exceed
maxSize, the remainder of the table is skipped. The format of the string produced is proprietary. The string contains meta information, so the Recursor callingputIntoNSSpeedTable()can check if the data format is compatible.Note that setting
maxSizeto zero (no limit) can produce very large strings. It is wise to set a limit. Additionally, setting no limit can lead to less efficient memory management while producing the dump.