Skip to content

Commit

Permalink
fix(pathfinder): fail on error connecting (#24)
Browse files Browse the repository at this point in the history
When virtual-sämubox starts and it can't connect to pathfinder or
our auth fails we throw a fatal error since it doesn't make sense to
continue running.
  • Loading branch information
hairmare authored Nov 5, 2020
1 parent c5b4796 commit f56f108
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions box/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ func waitAndRead(pathfinder net.Conn, target *net.UDPConn) {
log.Debug("Reading from Pathfinder.")
buffer, _, err := reader.ReadLine()
if err != nil {
log.Errorf("Error '%s'", err)
log.WithError(err).Fatal("Failed to read from Pathfinder.")
}
trimmedData := strings.TrimRight(string(buffer), "\x00\r\n")

log.Infof("Received data '%s'", trimmedData)

if trimmedData == "login successful" {
switch trimmedData {
case "login successful":
continue
case "login failed":
log.Fatal("Failed to login to Pathfinder.")
}

if pinIsLow.MatchString(trimmedData) {
Expand Down

0 comments on commit f56f108

Please sign in to comment.