aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/ip.lua
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-06-26 23:49:06 +0000
committerterminaldweller <devi@terminaldweller.com>2024-06-26 23:49:06 +0000
commit2d45235aaa8456c1cbd8303bba41e4d3a95f627a (patch)
tree7b46beafbdb3d0313ef2804270a3e4264b9c0cd2 /plugins/ip.lua
parentadded watchlists (diff)
downloadmilla-2d45235aaa8456c1cbd8303bba41e4d3a95f627a.tar.gz
milla-2d45235aaa8456c1cbd8303bba41e4d3a95f627a.zip
WIP
Diffstat (limited to 'plugins/ip.lua')
-rw-r--r--plugins/ip.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/plugins/ip.lua b/plugins/ip.lua
new file mode 100644
index 0000000..57cb0f5
--- /dev/null
+++ b/plugins/ip.lua
@@ -0,0 +1,23 @@
+local milla = require("milla")
+local os = require("os")
+local json = require("json")
+
+os.setenv("ALL_PROXY", "socks5://172.17.0.1:9057")
+
+local http = require("http")
+
+local function get_ip(arg)
+ local ip = arg
+ local response, err = http.request("GET",
+ "https://getip-api.com/json?" .. ip)
+ local json_response, err = json.decode(response.body)
+
+ local result = ""
+ for key, value in ipairs(json_response) do
+ result = result .. key .. ": " .. value .. "\n"
+ end
+
+ return result
+end
+
+milla.register_cmd("ip", "get_ip")