From a1bd01f725074ae2eda88fa91c85a11a0f3f4d69 Mon Sep 17 00:00:00 2001 From: John Viega Date: Thu, 19 Oct 2023 00:56:46 -0400 Subject: [PATCH] Incorporate new nimutils function for getting ones local external ip address, as external_ip() --- con4m.nimble | 2 +- files/con4m/builtins.nim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/con4m.nimble b/con4m.nimble index 06850a67..7aba6293 100644 --- a/con4m.nimble +++ b/con4m.nimble @@ -9,7 +9,7 @@ installExt = @["nim", "c4m", "c42spec", "sh"] # Dependencies requires "nim >= 2.0.0" -requires "https://github.com/crashappsec/nimutils#e0cbc02b13a850285a143482c34616dbfab1a0c4" +requires "https://github.com/crashappsec/nimutils#9d5bfe075ee192fd5dda0c97db4b911e777db3e2" #before build: diff --git a/files/con4m/builtins.nim b/files/con4m/builtins.nim index 9ded09da..3279e48a 100644 --- a/files/con4m/builtins.nim +++ b/files/con4m/builtins.nim @@ -1294,6 +1294,9 @@ proc c4mUrlPost*(args: seq[Box], unused = ConfigState(nil)): Option[Box] = result = some(pack(res)) +proc c4mExternalIp*(args: seq[Box], unused = ConfigState(nil)): Option[Box] = + result = some(pack(getMyIpV4Addr())) + proc c4mUrlPostPinned*(args: seq[Box], unused = ConfigState(nil)): Option[Box] = let url = unpack[string](args[0]) @@ -2684,6 +2687,11 @@ The parameters here are: will NOT assume one for you. Requests that take more than 5 seconds will be canceled. +""", + @["network"]), + ("external_ip() -> string", BuiltInFn(c4mExternalIp), + """ +Returns the external IP address for the current machine. """, @["network"]), ("url_post_pinned(string, string, dict[string, string], string) -> string",