Repository: caddyserver/caddy
File: caddyconfig/httpcaddyfile/serveroptions.go (Go)

Code before:
						return nil, d.Errf("unknown protocol '%s': expected h1, h2, h2c, or h3", proto)
					}
					if sliceContains(serverOpts.Protocols, proto) {
						return nil, d.Errf("protocol %s specified more than once", proto)
					}
					serverOpts.Protocols = append(serverOpts.Protocols, proto)
				}
				if nesting := d.Nesting(); d.NextBlock(nesting) {
					return nil, d.ArgErr()
				}

			case "strict_sni_host":
				if d.NextArg() && d.Val() != "insecure_off" && d.Val() != "on" {
					return nil, d.Errf("strict_sni_host only supports 'on' or 'insecure_off', got '%s'", d.Val())
				}
				boolVal := true
				if d.Val() == "insecure_off" {
					boolVal = false
				}
				serverOpts.StrictSNIHost = &boolVal

			case "trusted_proxies":
				if !d.NextArg() {
					return nil, d.Err("trusted_proxies expects an IP range source module name as its first argument")
				}
				modID := "http.ip_range_sources." + d.Val()
				unm, err := caddyfile.UnmarshalModule(d, modID)
				if err != nil {
					return nil, err
				}
				source, ok := unm.(caddyhttp.IPRangeSource)
				if !ok {
					return nil, fmt.Errorf("module %s (%T) is not an IP range source", modID, unm)
				}
				jsonSource := caddyconfig.JSONModuleObject(
					source,
					"source",
					source.(caddy.Module).CaddyModule().ID.Name(),
					nil,
				)
				serverOpts.TrustedProxiesRaw = jsonSource

			case "metrics":
				if d.NextArg() {
					return nil, d.ArgErr()
				}
				if nesting := d.Nesting(); d.NextBlock(nesting) {
					return nil, d.ArgErr()
				}
				serverOpts.Metrics = new(caddyhttp.Metrics)


Review comment (suggestion):
One other thought... should/could this be `http.ip_sources`, just for succinctness? Cause it could be either whole IPs or ranges.

Code after:
						return nil, d.Errf("unknown protocol '%s': expected h1, h2, h2c, or h3", proto)
					}
					if sliceContains(serverOpts.Protocols, proto) {
						return nil, d.Errf("protocol %s specified more than once", proto)
					}
					serverOpts.Protocols = append(serverOpts.Protocols, proto)
				}
				if nesting := d.Nesting(); d.NextBlock(nesting) {
					return nil, d.ArgErr()
				}

			case "strict_sni_host":
				if d.NextArg() && d.Val() != "insecure_off" && d.Val() != "on" {
					return nil, d.Errf("strict_sni_host only supports 'on' or 'insecure_off', got '%s'", d.Val())
				}
				boolVal := true
				if d.Val() == "insecure_off" {
					boolVal = false
				}
				serverOpts.StrictSNIHost = &boolVal

			case "trusted_proxies":
				if !d.NextArg() {
					return nil, d.Err("trusted_proxies expects an IP range source module name as its first argument")
				}
				modID := "http.ip_sources." + d.Val()
				unm, err := caddyfile.UnmarshalModule(d, modID)
				if err != nil {
					return nil, err
				}
				source, ok := unm.(caddyhttp.IPRangeSource)
				if !ok {
					return nil, fmt.Errorf("module %s (%T) is not an IP range source", modID, unm)
				}
				jsonSource := caddyconfig.JSONModuleObject(
					source,
					"source",
					source.(caddy.Module).CaddyModule().ID.Name(),
					nil,
				)
				serverOpts.TrustedProxiesRaw = jsonSource

			case "metrics":
				if d.NextArg() {
					return nil, d.ArgErr()
				}
				if nesting := d.Nesting(); d.NextBlock(nesting) {
					return nil, d.ArgErr()
				}
				serverOpts.Metrics = new(caddyhttp.Metrics)