Skip to content

Commit

Permalink
Make /data path configurable
Browse files Browse the repository at this point in the history
- Permit disable /data path to prevent DoS attack
- Fixes traefik#17
  • Loading branch information
wiltonsr committed Apr 28, 2022
1 parent 12d9acf commit ac1ca88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Heath check.
| `port` | `WHOAMI_PORT_NUMBER` | Give me a port number. (default: `80`) |
| `name` | `WHOAMI_NAME` | Give me a name. |
| `verbose` | | Enable verbose logging. |
| `no-data` | | Disable data handler. |

## Examples

Expand Down
7 changes: 7 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ var (
port string
name string
verbose bool
no_data bool
)

func init() {
flag.BoolVar(&verbose, "verbose", false, "Enable verbose logging")
flag.BoolVar(&no_data, "no-data", false, "Disable data handler")
flag.StringVar(&cert, "cert", "", "give me a certificate")
flag.StringVar(&key, "key", "", "give me a key")
flag.StringVar(&ca, "cacert", "", "give me a CA chain, enforces mutual TLS")
Expand Down Expand Up @@ -153,6 +155,11 @@ func printBinary(s []byte) {
}

func dataHandler(w http.ResponseWriter, r *http.Request) {
if no_data {
_, _ = fmt.Fprintln(w, "dataHandler disabled!")
return
}

u, _ := url.Parse(r.URL.String())
queryParams := u.Query()

Expand Down

0 comments on commit ac1ca88

Please sign in to comment.