Skip to content

Commit

Permalink
better function name
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rad committed Oct 25, 2020
1 parent fbd279c commit 3e4a811
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions certs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -x
# call this script with an email address (valid or not).
# like:
# ./makecert.sh foo@foo.com
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Client) GetSecret(secretService *Service) error {
return errs.WithE(err, "Failed to write command")
}

if err := secretService.FromConnection(c.conn); err != nil {
if err := secretService.FromReaderUntilNewLine(c.conn); err != nil {
return errs.WithE(err, "Failed to get secret")
}
return nil
Expand Down
5 changes: 0 additions & 5 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"github.com/n0rad/go-erlog/errs"
"github.com/n0rad/go-erlog/logs"
_ "github.com/n0rad/go-erlog/register"
"github.com/n0rad/memguarded"
Expand Down Expand Up @@ -31,10 +30,6 @@ func execute() error {
ServerPem: "/etc/" + app + "/" + app + ".pem",
}

if err := config.Secret.AskSecret(true, "Secret"); err != nil {
return errs.WithE(err, "Failed ask secret")
}

logs.Info("Start")
return memguarded.StartServer(config)
}
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Server) Init(secretService *Service) error {

s.commands["set_secret"] = func(m net.Conn) error {
logs.Info("Set secret")
if err := secretService.FromConnection(m); err != nil {
if err := secretService.FromReaderUntilNewLine(m); err != nil {
return err
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *Service) FromBytes(secret *[]byte) error {
return nil
}

func (s *Service) FromConnection(conn net.Conn) error {
func (s *Service) FromReaderUntilNewLine(conn net.Conn) error {
buffer, err := memguard.NewBufferFromReaderUntil(conn, '\n')
if err != nil && err != io.EOF {
return errs.WithE(err, "Failed to read secret from connection")
Expand Down

0 comments on commit 3e4a811

Please sign in to comment.