Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,8 @@ allow-environment-overrides: true
metadata:
# can clients store metadata?
enabled: true
# if this is true, only server operators with the `metadata` capability can edit metadata:
operator-only-modification: false
# how many keys can a client subscribe to?
max-subs: 100
# how many keys can be stored per entity?
Expand Down
11 changes: 6 additions & 5 deletions irc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,12 @@ type Config struct {
}

Metadata struct {
Enabled bool
MaxSubs int `yaml:"max-subs"`
MaxKeys int `yaml:"max-keys"`
MaxValueBytes int `yaml:"max-value-length"`
ClientThrottle ThrottleConfig `yaml:"client-throttle"`
Enabled bool
OperatorOnlyModification bool `yaml:"operator-only-modification"`
MaxSubs int `yaml:"max-subs"`
MaxKeys int `yaml:"max-keys"`
MaxValueBytes int `yaml:"max-value-length"`
ClientThrottle ThrottleConfig `yaml:"client-throttle"`
}

WebPush struct {
Expand Down
10 changes: 8 additions & 2 deletions irc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3148,7 +3148,7 @@ func markReadHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
func metadataHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) (exiting bool) {
config := server.Config()
if !config.Metadata.Enabled {
rb.Add(nil, server.name, "FAIL", "METADATA", "FORBIDDEN", utils.SafeErrorParam(msg.Params[0]), "Metadata is disabled on this server")
rb.Add(nil, server.name, "FAIL", "METADATA", "FORBIDDEN", utils.SafeErrorParam(msg.Params[0]), client.t("Metadata is disabled on this server"))
return
}

Expand All @@ -3163,7 +3163,13 @@ func metadataHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
case "sub", "unsub", "subs":
// these are session-local and function the same whether or not the client is registered
return metadataSubsHandler(client, subcommand, msg.Params, rb)
case "get", "set", "list", "clear", "sync":
case "set", "clear":
if config.Metadata.OperatorOnlyModification && !client.HasRoleCapabs("metadata") {
rb.Add(nil, server.name, "FAIL", "METADATA", "FORBIDDEN", utils.SafeErrorParam(msg.Params[0]), client.t("Only server operators can modify metadata"))
return
}
fallthrough
case "get", "list", "sync":
if client.registered {
return metadataRegisteredHandler(client, config, subcommand, msg.Params, rb)
} else {
Expand Down
2 changes: 2 additions & 0 deletions traditional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,8 @@ allow-environment-overrides: true
metadata:
# can clients store metadata?
enabled: true
# if this is true, only server operators with the `metadata` capability can edit metadata:
operator-only-modification: false
# how many keys can a client subscribe to?
max-subs: 100
# how many keys can be stored per entity?
Expand Down