Skip to content

Commit

Permalink
updated logging and cli opts
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Jun 15, 2018
1 parent c9b90d0 commit d677f59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ brew install txn2/tap/n2proxy

**Use**
```bash
# get the version
n2proxy --version

# get help
n2proxy --help

# environment variable override defaults
CFG=./cfg.yml PORT=9090 BACKEND=http://example.com:80 n2proxy

# command line options override environment variables
n2proxy --port=9091 --backend=http://example.com:80

```

Browse to http://localhost:9090
5 changes: 2 additions & 3 deletions rweng/rweng.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rweng

import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"regexp"
Expand Down Expand Up @@ -37,7 +36,7 @@ func (e *Eng) ProcessRequest(w http.ResponseWriter, r *http.Request) {
for _, rgx := range e.urlBan {
buri := bytes.ToLower([]byte(r.RequestURI))
if rgx.Match(buri) {
e.logger.Info(fmt.Sprintf("URL contraband found [%s] in:\n%s\n", rgx, buri))
e.logger.Warn("URL contraband found.", zap.String("Regexp", rgx.String()), zap.ByteString("PostBody", buri))
r.URL.Path = "/"
r.URL.RawQuery = ""
break
Expand All @@ -47,7 +46,7 @@ func (e *Eng) ProcessRequest(w http.ResponseWriter, r *http.Request) {
// search for posted contraband
for _, rgx := range e.postBan {
if rgx.Match(bytes.ToLower(b)) {
e.logger.Info(fmt.Sprintf("Posted contraband found [%s] in:\n%s\n", rgx, b))
e.logger.Warn("Posted contraband found.", zap.String("Regexp", rgx.String()), zap.ByteString("PostBody", b))
b = []byte{}
break
}
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func main() {
zapCfg := zap.NewProductionConfig()
zapCfg.DisableCaller = true
zapCfg.DisableStacktrace = true
zapCfg.OutputPaths = []string{"stdout", "test.log"}
zapCfg.OutputPaths = []string{"stdout"}

logger, err := zapCfg.Build()
if err != nil {
Expand Down

0 comments on commit d677f59

Please sign in to comment.