Skip to content

Commit

Permalink
Incorporate new nimutils function for getting ones local external ip …
Browse files Browse the repository at this point in the history
…address, as external_ip()
  • Loading branch information
viega committed Oct 19, 2023
1 parent 90a3463 commit a1bd01f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion con4m.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions files/con4m/builtins.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit a1bd01f

Please sign in to comment.