fix export sending binary

This commit is contained in:
2025-05-12 16:22:29 -01:06
parent 41f47e8d54
commit aa9165de1d
3 changed files with 29 additions and 5 deletions

View File

@@ -74,6 +74,20 @@ func (x *Operations) RegisterConfigurationSet(api huma.API) {
return
}
}
tmpB := []string{}
tmpA := []string{}
for _, v := range input.Body.BlockList {
if len(v) > 0 {
tmpB = append(tmpB, v)
}
}
input.Body.BlockList = tmpB
for _, v := range input.Body.AllowList {
if len(v) > 0 {
tmpA = append(tmpA, v)
}
}
input.Body.AllowList = tmpA
log.I.F("setting configuration")
if err = x.SetConfiguration(input.Body); chk.E(err) {
err = huma.Error400BadRequest(err.Error())

View File

@@ -232,8 +232,14 @@ func (r *T) BlanketDownload(c context.T, w io.Writer) (counter int, err error) {
// err = nil
continue
}
if r.Binary {
ev := &event.T{}
if _, err = r.Unmarshal(ev, b); chk.E(err) {
continue
}
b = ev.Serialize()
}
// send the event to client
// the database stores correct JSON versions so no need to decode/encode.
if _, err = fmt.Fprintf(w, "%s\n", b); chk.E(err) {
return
}

View File

@@ -96,10 +96,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
}
for _, a := range s.Configuration().BlockList {
if strings.HasPrefix(remote, a) {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
blocklist := s.Configuration().BlockList
log.I.S(blocklist)
if len(blocklist) > 0 {
for _, a := range s.Configuration().BlockList {
if strings.HasPrefix(remote, a) {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
}
}
}
log.T.F("http request: %s from %s", r.URL.String(), helpers.GetRemoteFromReq(r))