UnmarshalCaddyfile sets up the MatchRemoteIP from Caddyfile tokens. Syntax: remote_ip <ranges...> Note: IPs and CIDRs prefixed with ! symbol are treated as not_ranges
(d *caddyfile.Dispenser)
| 399 | // |
| 400 | // Note: IPs and CIDRs prefixed with ! symbol are treated as not_ranges |
| 401 | func (m *MatchRemoteIP) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { |
| 402 | for d.Next() { |
| 403 | wrapper := d.Val() |
| 404 | |
| 405 | // At least one same-line option must be provided |
| 406 | if d.CountRemainingArgs() == 0 { |
| 407 | return d.ArgErr() |
| 408 | } |
| 409 | |
| 410 | for d.NextArg() { |
| 411 | val := d.Val() |
| 412 | var exclamation bool |
| 413 | if len(val) > 1 && val[0] == '!' { |
| 414 | exclamation, val = true, val[1:] |
| 415 | } |
| 416 | ranges := []string{val} |
| 417 | if val == "private_ranges" { |
| 418 | ranges = internal.PrivateRangesCIDR() |
| 419 | } |
| 420 | if exclamation { |
| 421 | m.NotRanges = append(m.NotRanges, ranges...) |
| 422 | } else { |
| 423 | m.Ranges = append(m.Ranges, ranges...) |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | // No blocks are supported |
| 428 | if d.NextBlock(d.Nesting()) { |
| 429 | return d.Errf("malformed TLS handshake matcher '%s': blocks are not supported", wrapper) |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | return nil |
| 434 | } |
| 435 | |
| 436 | // MatchLocalIP matches based on the IP address of the interface |
| 437 | // receiving the connection. Specific IPs or CIDR ranges can be specified. |
nothing calls this directly
no test coverage detected