diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ip.lua | 23 | ||||
-rw-r--r-- | plugins/proxy_test.lua | 10 |
2 files changed, 33 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") diff --git a/plugins/proxy_test.lua b/plugins/proxy_test.lua new file mode 100644 index 0000000..841fefa --- /dev/null +++ b/plugins/proxy_test.lua @@ -0,0 +1,10 @@ +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 response, err = http.request("GET", "https://icanhazip.com") +print(response.body) |