Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

581 B
Raw Blame
package dockeragent

import (
	"fmt"
	"io"
)

const (
	maxPulseResponseBodyBytes    = 1 * 1024 * 1024
	maxVersionResponseBodyBytes  = 64 * 1024
	maxRegistryManifestBodyBytes = 4 * 1024 * 1024
	maxRegistryTokenBodyBytes    = 1 * 1024 * 1024
	maxContainerStatsBodyBytes   = 4 * 1024 * 1024
)

func readBodyWithLimit(r io.Reader, maxBytes int64) ([]byte, error) {
	body, err := io.ReadAll(io.LimitReader(r, maxBytes+1))
	if err != nil {
		return nil, err
	}
	if int64(len(body)) > maxBytes {
		return nil, fmt.Errorf("response body exceeds %d bytes", maxBytes)
	}
	return body, nil
}