I’m trying to run a function in one of my config files, in this case dev.exs
, which will return the IPv6 of one of my network interfaces. This is not working (highlighted yellow):
although I know the function does work.
I’ve also put the function into a module and placed the module in the config folder, and the lib folder, but they weren’t able to be found by dev.exs
either. So how and where do I define a function or module, so that it can be used in dev.exs?
Separately, is there an easier way to find the IPv6 of my “tun0” interface, than this module/function?
defmodule GetIp do
def get_ygg_ip do
:inet.getifaddrs()
|> elem(1)
|> Enum.filter(fn x -> elem(x, 0) == ~c"tun0" end)
|> Enum.at(0)
|> elem(1)
|> Enum.at(1)
|> elem(1)
end
end
if you want to test the function you will have to rename ~c"tun0"
to something the exists on your computer when using ifconfig
(leftmost column ahead of the colons are the interface names)