|
|
@ -479,12 +479,12 @@ func (s *Server) StreamNetworkEvents(w http.ResponseWriter, req *http.Request) { |
|
|
|
func NewMsgFilters(filterParam string) (MsgFilters, error) { |
|
|
|
func NewMsgFilters(filterParam string) (MsgFilters, error) { |
|
|
|
filters := make(MsgFilters) |
|
|
|
filters := make(MsgFilters) |
|
|
|
for _, filter := range strings.Split(filterParam, "-") { |
|
|
|
for _, filter := range strings.Split(filterParam, "-") { |
|
|
|
protoCodes := strings.SplitN(filter, ":", 2) |
|
|
|
proto, codes, found := strings.Cut(filter, ":") |
|
|
|
if len(protoCodes) != 2 || protoCodes[0] == "" || protoCodes[1] == "" { |
|
|
|
if !found || proto == "" || codes == "" { |
|
|
|
return nil, fmt.Errorf("invalid message filter: %s", filter) |
|
|
|
return nil, fmt.Errorf("invalid message filter: %s", filter) |
|
|
|
} |
|
|
|
} |
|
|
|
proto := protoCodes[0] |
|
|
|
|
|
|
|
for _, code := range strings.Split(protoCodes[1], ",") { |
|
|
|
for _, code := range strings.Split(codes, ",") { |
|
|
|
if code == "*" || code == "-1" { |
|
|
|
if code == "*" || code == "-1" { |
|
|
|
filters[MsgFilter{Proto: proto, Code: -1}] = struct{}{} |
|
|
|
filters[MsgFilter{Proto: proto, Code: -1}] = struct{}{} |
|
|
|
continue |
|
|
|
continue |
|
|
|