fix
This commit is contained in:
parent
d009bba5b6
commit
2ec2380a54
@ -33,7 +33,7 @@ init([]) ->
|
|||||||
Name = dns_server:get_name(Id),
|
Name = dns_server:get_name(Id),
|
||||||
#{
|
#{
|
||||||
id => Name,
|
id => Name,
|
||||||
start => {sdlan_stun, start_link, [Name, Port]},
|
start => {dns_server, start_link, [Name, Port]},
|
||||||
restart => permanent,
|
restart => permanent,
|
||||||
shutdown => 2000,
|
shutdown => 2000,
|
||||||
type => worker,
|
type => worker,
|
||||||
|
|||||||
@ -19,7 +19,8 @@ init() ->
|
|||||||
|
|
||||||
-spec lookup(FullHostname :: binary()) -> error | {ok, Ip :: inet:ip4_address()}.
|
-spec lookup(FullHostname :: binary()) -> error | {ok, Ip :: inet:ip4_address()}.
|
||||||
lookup(FullHostname) when is_binary(FullHostname) ->
|
lookup(FullHostname) when is_binary(FullHostname) ->
|
||||||
case ets:lookup(?TABLE, FullHostname) of
|
LowerFullHostname = string:lowercase(FullHostname),
|
||||||
|
case ets:lookup(?TABLE, LowerFullHostname) of
|
||||||
[{_, Ip}] ->
|
[{_, Ip}] ->
|
||||||
{ok, Ip};
|
{ok, Ip};
|
||||||
[] ->
|
[] ->
|
||||||
@ -29,7 +30,8 @@ lookup(FullHostname) when is_binary(FullHostname) ->
|
|||||||
-spec insert(any(), Domain :: binary(), Ip :: integer()) -> no_return().
|
-spec insert(any(), Domain :: binary(), Ip :: integer()) -> no_return().
|
||||||
insert(HostName, Domain, Ip) when is_binary(HostName), is_binary(Domain), is_integer(Ip), HostName /= <<>> ->
|
insert(HostName, Domain, Ip) when is_binary(HostName), is_binary(Domain), is_integer(Ip), HostName /= <<>> ->
|
||||||
FullHostname = <<HostName/binary, ".", Domain/binary>>,
|
FullHostname = <<HostName/binary, ".", Domain/binary>>,
|
||||||
|
LowerFullHostname = string:lowercase(FullHostname),
|
||||||
<<Ip0, Ip1, Ip2, Ip3>> = <<Ip:32>>,
|
<<Ip0, Ip1, Ip2, Ip3>> = <<Ip:32>>,
|
||||||
true = ets:insert(?TABLE, {FullHostname, {Ip0, Ip1, Ip2, Ip3}});
|
true = ets:insert(?TABLE, {LowerFullHostname, {Ip0, Ip1, Ip2, Ip3}});
|
||||||
insert(_, _, _) ->
|
insert(_, _, _) ->
|
||||||
ok.
|
ok.
|
||||||
Loading…
x
Reference in New Issue
Block a user