diff --git a/docs/scripting.xml b/docs/scripting.xml index 1f1f3395c..8cdde3b99 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -1292,9 +1292,9 @@ socket:close() the whois problem above is to have each thread block on a mutex using a common string, thus ensuring that only one thread is querying whois servers at once. That - thread can store the results in the NSE Registry before + thread can store the results in the NSE registry before releasing unlocking the mutex. The next script in the waiting - queue can then run. It will first check the Registry and only + queue can then run. It will first check the registry and only query whois servers if the previous results were insufficient. @@ -1436,29 +1436,33 @@ try(socket:send(result)) The Registry registry (NSE) - The registry is a normal Lua table. What is special about it - is that it is visible by all scripts and it retains its state - between script executions. The registry - is transient—it is not stored between Nmap executions. Every - script can read the registry and write to it. If a script is - running after another script, it can read some information in - the registry which was left by the first script. This feature - is particularly powerful in combination with the run level - concept. A script with a higher run level can rely on entries - left behind for it by scripts with lower run levels. - run level of scripts - Remember - however that the registry can be written by all scripts - equally, so choose the keys for your entries wisely. The - registry is stored in nmap.registry. The - behavior of the registry allows caching of already calculated - data. The cache can be seen by all scripts until the registry - is rebuilt with the next target group. + The registry is a Lua table with the special property that it + is visible by all scripts and retains its state between script + executions. The registry is transient—it is not stored + between Nmap executions. Every script can read and write to + the registry. Scripts commonly use it to save information for + other instances of the same script. For example, + the whois and asn-query + scripts may query one IP address, but receive information + which may apply to tens of thousands of IPs on that network. + Saving the information in the registry may prevent other + script threads from having to repeat the same query. The + registry may also be used to hand information to completely + different scripts. For example, + the snmp-brute script saves a discovered + community name in the registry where it may be used by other + SNMP scripts. Scripts which leave information behind for a + second script must have a lower runlevel + than that second script, or there is no guarantee that they + will run first.run level of + scripts + + + Keep in mind that the + registry can be written by all scripts equally, so choose + keys for your entries wisely. The registry is stored + in nmap.registry. -