mirror of
https://git.numenor-labs.us/dsfx.git
synced 2025-04-29 00:00:35 +00:00
fix(internal/peer): read admins file correctly
Previously, the 'keyRaw' slice was being allocated with a length of 0. However, the 'Read()' function will only read up to the slice's length. Together, this means that we always read 0 bytes from the admins file. Now, we can use the 'io.ReadAll()' function to read all of the admins file before parsing.
This commit is contained in:
parent
433b4e03a4
commit
d6cf91916f
@ -189,12 +189,12 @@ func (p *Peer) Run(ctx context.Context) error {
|
||||
|
||||
// loadAdmins ...
|
||||
func (p *Peer) loadAdmins() ([]string, error) {
|
||||
hasKeyFile, err := p.hasAdminsFile()
|
||||
hasAdminsFile, err := p.hasAdminsFile()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to check for admins file: %w", err)
|
||||
}
|
||||
|
||||
if !hasKeyFile {
|
||||
if !hasAdminsFile {
|
||||
if err := p.createAdminsFile(); err != nil {
|
||||
return nil, fmt.Errorf("failed to create admins file: %w", err)
|
||||
}
|
||||
@ -236,8 +236,7 @@ func (p *Peer) readAdminsFile() ([]string, error) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
keyRaw := make([]byte, 0)
|
||||
_, err = f.Read(keyRaw)
|
||||
keyRaw, err := io.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user