Skip to content

Commit

Permalink
reworked 'tail' function for subordinate access (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Nov 12, 2024
1 parent 94cfba7 commit f5601e3
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions agent/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,37 @@ func (a *access) tail(data []byte) {
if line, err := a.readBuffer.ReadString('\n'); err == nil {
line = strings.Trim(line, "\n")
if !a.booted {
in := make(map[string]interface{})
if err := json.Unmarshal([]byte(line), &in); err == nil {
if v, found := in["frontend_token"]; found {
if str, ok := v.(string); ok {
a.frontendToken = str
}
}
if v, found := in["bind_address"]; found {
if str, ok := v.(string); ok {
a.bindAddress = str
if strings.HasPrefix(line, "{") {
in := make(map[string]interface{})
if err := json.Unmarshal([]byte(line), &in); err == nil {
if v, found := in["message"]; found {
if str, ok := v.(string); ok {
if str == "boot" {
if v, found := in["frontend_token"]; found {
if str, ok := v.(string); ok {
a.frontendToken = str
}
}
if v, found := in["bind_address"]; found {
if str, ok := v.(string); ok {
a.bindAddress = str
}
}
a.booted = true
}
} else {
a.bootErr = errors.New(line)
}
} else {
logrus.Warn(line)
}
} else {
a.bootErr = errors.New(line)
}
a.booted = true
close(a.bootComplete)
} else {
a.bootErr = errors.New(line)
logrus.Warn(line)
}
close(a.bootComplete)

} else {
if strings.HasPrefix(line, "{") {
in := make(map[string]interface{})
Expand Down

0 comments on commit f5601e3

Please sign in to comment.