From 2d45235aaa8456c1cbd8303bba41e4d3a95f627a Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 26 Jun 2024 19:49:06 -0400 Subject: WIP --- plugins/ip.lua | 23 +++++++++++++++++++++++ plugins/proxy_test.lua | 10 ++++++++++ 2 files changed, 33 insertions(+) create mode 100644 plugins/ip.lua create mode 100644 plugins/proxy_test.lua (limited to 'plugins') 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) -- cgit v1.2.3