[#65] adding IP to the Information struct
This commit is contained in:
parent
edea8086c4
commit
fe95cd4f2b
|
@ -12,6 +12,7 @@ defmodule POAAgent.Entity.Host.Information do
|
|||
net: Literal.Decimal.t(),
|
||||
protocol: pos_integer,
|
||||
api: Version.t(),
|
||||
ip: String.t(),
|
||||
port: Literal.Decimal.t(), ## :inet.port_number()
|
||||
os: String.t(),
|
||||
os_v: Version.t(),
|
||||
|
@ -27,6 +28,7 @@ defmodule POAAgent.Entity.Host.Information do
|
|||
:net,
|
||||
:protocol,
|
||||
:api,
|
||||
:ip,
|
||||
:port,
|
||||
:os,
|
||||
:os_v,
|
||||
|
@ -43,6 +45,7 @@ defmodule POAAgent.Entity.Host.Information do
|
|||
net: nil,
|
||||
protocol: nil,
|
||||
api: "", # this field belongs to JS version, doesn't make sense here
|
||||
ip: ip(),
|
||||
port: "", # TODO
|
||||
os: os(),
|
||||
os_v: os_version(),
|
||||
|
@ -51,6 +54,17 @@ defmodule POAAgent.Entity.Host.Information do
|
|||
}
|
||||
end
|
||||
|
||||
defp ip do
|
||||
case :inet.getif() do
|
||||
{:ok, [{ip, _, _} | _]} ->
|
||||
ip
|
||||
|> :inet_parse.ntoa
|
||||
|> List.to_string
|
||||
_ ->
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
defp os do
|
||||
{_, os} = :os.type()
|
||||
Atom.to_string(os)
|
||||
|
|
Loading…
Reference in New Issue