mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
round 1 of follow-up for metadata (#2277)
* refactoring * send an empty batch if necessary, as per spec * don't broadcast no-op updates * don't trim spaces before validating the key * bump irctest to cover metadata * replay existing metadata to reattaching always-on clients * use canonicalized name everywhere * use utils.SafeErrorParam in FAIL lines * validate key names for sub * fix error for METADATA CLEAR * max-keys is enforced for channels as well * remove unlimited configurations * maintain the limit exactly without off-by-one cases * add final channel registration check
This commit is contained in:
parent
4dcbc48159
commit
3b7db7fff7
12 changed files with 213 additions and 172 deletions
|
|
@ -728,7 +728,7 @@ type Config struct {
|
|||
Enabled bool
|
||||
MaxSubs int `yaml:"max-subs"`
|
||||
MaxKeys int `yaml:"max-keys"`
|
||||
MaxValueBytes int `yaml:"max-value-length"` // todo: currently unenforced!!
|
||||
MaxValueBytes int `yaml:"max-value-length"`
|
||||
}
|
||||
|
||||
WebPush struct {
|
||||
|
|
@ -1649,19 +1649,20 @@ func LoadConfig(filename string) (config *Config, err error) {
|
|||
config.Server.supportedCaps.Disable(caps.Metadata)
|
||||
} else {
|
||||
var metadataValues []string
|
||||
if config.Metadata.MaxSubs >= 0 {
|
||||
metadataValues = append(metadataValues, fmt.Sprintf("max-subs=%d", config.Metadata.MaxSubs))
|
||||
// these are required for normal operation, so set sane defaults:
|
||||
if config.Metadata.MaxSubs == 0 {
|
||||
config.Metadata.MaxSubs = 10
|
||||
}
|
||||
if config.Metadata.MaxKeys > 0 {
|
||||
metadataValues = append(metadataValues, fmt.Sprintf("max-keys=%d", config.Metadata.MaxKeys))
|
||||
metadataValues = append(metadataValues, fmt.Sprintf("max-subs=%d", config.Metadata.MaxSubs))
|
||||
if config.Metadata.MaxKeys == 0 {
|
||||
config.Metadata.MaxKeys = 10
|
||||
}
|
||||
metadataValues = append(metadataValues, fmt.Sprintf("max-keys=%d", config.Metadata.MaxKeys))
|
||||
// this is not required since we enforce a hardcoded upper bound on key+value
|
||||
if config.Metadata.MaxValueBytes > 0 {
|
||||
metadataValues = append(metadataValues, fmt.Sprintf("max-value-bytes=%d", config.Metadata.MaxValueBytes))
|
||||
}
|
||||
if len(metadataValues) != 0 {
|
||||
config.Server.capValues[caps.Metadata] = strings.Join(metadataValues, ",")
|
||||
}
|
||||
|
||||
config.Server.capValues[caps.Metadata] = strings.Join(metadataValues, ",")
|
||||
}
|
||||
|
||||
err = config.processExtjwt()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue