aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
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
parentadded watchlists (diff)
downloadmilla-2d45235aaa8456c1cbd8303bba41e4d3a95f627a.tar.gz
milla-2d45235aaa8456c1cbd8303bba41e4d3a95f627a.zip
WIP
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ip.lua23
-rw-r--r--plugins/proxy_test.lua10
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)