chore(psk): improve configuration file
This commit is contained in:
parent
7c61bc18cf
commit
2f18f5e8b5
|
@ -1,7 +1,19 @@
|
|||
##--------------------------------------------------------------------
|
||||
## EMQ X PSK
|
||||
##--------------------------------------------------------------------
|
||||
|
||||
psk {
|
||||
## Whether to enable the PSK feature.
|
||||
enable = true
|
||||
|
||||
# boot_file = {{ platform_data_dir }}/boot.psk
|
||||
## If boot file is specified, emqx will import PSKs from the file
|
||||
## into the built-in database at startup for use by the runtime.
|
||||
##
|
||||
## The file has to be structured line-by-line, each line must be in
|
||||
## the format: <PSKIdentity>:<SharedSecret>
|
||||
## boot_file = {{ platform_data_dir }}/boot.psk
|
||||
|
||||
# delimiter = ":"
|
||||
## Specifies the separator for PSKIdentity and SharedSecret in the boot file.
|
||||
## The default is colon (:)
|
||||
## separator = ":"
|
||||
}
|
||||
|
|
|
@ -148,15 +148,15 @@ is_enable() ->
|
|||
boot_file() ->
|
||||
emqx_config:get([psk, boot_file], undefined).
|
||||
|
||||
delimiter() ->
|
||||
emqx_config:get([psk, delimiter], ?DEFAULT_DELIMITER).
|
||||
separator() ->
|
||||
emqx_config:get([psk, separator], ?DEFAULT_DELIMITER).
|
||||
|
||||
import_psks(SrcFile) ->
|
||||
case file:open(SrcFile, [read, raw, binary, read_ahead]) of
|
||||
{error, Reason} ->
|
||||
{error, Reason};
|
||||
{ok, Io} ->
|
||||
case Result = import_psks(Io, delimiter()) of
|
||||
case Result = import_psks(Io, separator()) of
|
||||
ok -> ignore;
|
||||
{error, Reason} ->
|
||||
?LOG("Failed to import psk from ~s due to ~p", [SrcFile, Reason])
|
||||
|
|
|
@ -29,7 +29,7 @@ roots() -> [].
|
|||
fields("psk") ->
|
||||
[ {enable, fun enable/1}
|
||||
, {boot_file, fun boot_file/1}
|
||||
, {delimiter, fun delimiter/1}
|
||||
, {separator, fun separator/1}
|
||||
].
|
||||
|
||||
enable(type) -> boolean();
|
||||
|
@ -40,6 +40,6 @@ boot_file(type) -> binary();
|
|||
boot_file(nullable) -> true;
|
||||
boot_file(_) -> undefined.
|
||||
|
||||
delimiter(type) -> binary();
|
||||
delimiter(default) -> <<":">>;
|
||||
delimiter(_) -> undefined.
|
||||
separator(type) -> binary();
|
||||
separator(default) -> <<":">>;
|
||||
separator(_) -> undefined.
|
||||
|
|
Loading…
Reference in New Issue