package pkg import ( "errors" "strings" ) type RadiusProfile struct { ProfileCommon Clients []string `json:"clients"` PersistAVP string `json:"persist_avp"` } func ParseRadius(raw string) (*RadiusProfile, error) { p := new(RadiusProfile) split := strings.Split(raw, "\n") if !strings.Contains(split[0], "ltm profile radius") { return nil, errors.New("not a radius profile") } p.ProfileCommon = parseCommon(raw) p.Clients = []string{} for _, line := range split { f := strings.Fields(line) switch strings.ToLower(f[0]) { case "clients": if f[1] != "none" { p.Clients = f[2 : len(f)-1] } case "persist-avp": p.PersistAVP = strings.Join(f[1:], " ") } } return p, nil }