The Extism IPINFO plugin facilitates retrieving detailed information about an IP address using the IP-API service. This README provides an overview of the plugin, its components, usage instructions, dependencies, and other relevant details.
-
ipInfo(ipAddress)
Function:- Constructs the API URL based on the provided IP address.
- Defines a request object containing necessary details such as method, URL, and headers.
- Executes an HTTP request to the constructed URL using
Http.request
. - Checks if the response status is not 200, indicating an error, and throws an exception if so.
- Parses the response body as JSON.
- Outputs the parsed JSON data.
-
run()
Function:- Retrieves an IP address as input.
- Calls the
ipInfo
function with the provided IP address.
-
Export:
- Exports the
run
function, allowing external modules to utilize this plugin.
- Exports the
To utilize this plugin, follow these steps:
- Ensure the plugin is correctly integrated into the hosting environment.
- Call the
run
function. - Provide the IP address as input when prompted.
- Receive detailed information about the IP address as output.
Example:
//risky
extism call plugin.wasm run --input "146.70.99.211" --wasi --allow-host '*'
// safe
extism call plugin.wasm run --input "146.70.99.211" --wasi --allow-host 'ip-api.com'