diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-07-30 23:25:59 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-07-30 23:25:59 +0000 |
commit | 81469bbb1745a835676c3664e75a4a951223da9d (patch) | |
tree | 70a53b118c406d5958a8fb8c72e391fb6439f729 /plugins/ip.lua | |
parent | we can now add new commands from lua plugins (diff) | |
download | milla-81469bbb1745a835676c3664e75a4a951223da9d.tar.gz milla-81469bbb1745a835676c3664e75a4a951223da9d.zip |
* fixed a crash when unloading a lua script
* added event types, foreground and background color for watchlists
* added a url_encode function to lua to encode urls. Underneath, it just
calls the standard library function from golang
* updated the README
* the urban plugin now can take in the number of entries to return
* reverted a bug where setting the http proxy for the lua http module
was not working
* fixed the url for the ip script so it is actually working. the current
provider does not support ipv6 though
Diffstat (limited to 'plugins/ip.lua')
-rw-r--r-- | plugins/ip.lua | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/ip.lua b/plugins/ip.lua index 2e9afad..79ac6e2 100644 --- a/plugins/ip.lua +++ b/plugins/ip.lua @@ -2,18 +2,19 @@ local milla = require("milla") local os = require("os") local json = require("json") --- setting the proxy value before loading the http module --- this way, only this script will be using this proxy -os.setenv("ALL_PROXY", "socks5://172.17.0.1:9057") - -local http = require("http") - -- this function should be global -- one string arg that holds all args -- should only return one string value function milla_get_ip(arg) - local ip = arg - local response, err = http.request("GET", "http://ip-api.com/json?" .. ip) + -- setting the proxy value before loading the http module + -- this way, only this script will be using this proxy + os.setenv("http_proxy", "http://172.17.0.1:8120") + + local http = require("http") + + local url = "http://ip-api.com/json/" .. arg + + local response, err = http.request("GET", url) if err ~= nil then print(err) end local json_response, err = json.decode(response.body) |