Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never add port to RemoteAddr #297

Merged
merged 1 commit into from
Jun 12, 2020
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: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mark as generated so it won't show up in diffs etc.
pack/*.go linguist-generated=true
tpl/_backend_sitecode.gohtml linguist-generated=true
/go.mod linguist-generated=true
/go.sum linguist-generated=true
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/PuerkitoBio/goquery v1.5.1
github.com/arp242/geoip2-golang v1.4.0
github.com/go-chi/chi v4.1.1+incompatible
github.com/go-chi/chi v4.1.2+incompatible
github.com/jmoiron/sqlx v1.2.0
github.com/lib/pq v1.5.2
github.com/mattn/go-sqlite3 v2.0.3+incompatible
Expand All @@ -22,7 +22,7 @@ require (
zgo.at/isbot v0.0.0-20200518180519-d9e7a12daaea
zgo.at/tz v0.0.0-20200520034804-aeba38d94d93
zgo.at/zdb v0.0.0-20200529134049-932215d95f5b
zgo.at/zhttp v0.0.0-20200602011947-d637cf767b75
zgo.at/zhttp v0.0.0-20200612054249-79d9ae915427
zgo.at/zlog v0.0.0-20200519105857-4dc5e4ffe04c
zgo.at/zpack v1.0.1
zgo.at/zstd v0.0.0-20200528080824-83897c2259b4
Expand Down
8 changes: 4 additions & 4 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions handlers/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (h backend) Mount(r chi.Router, db zdb.DB) {
}

r.Use(
middleware.RealIP,
zhttp.RealIP,
zhttp.Unpanic(cfg.Prod),
addctx(db, true),
middleware.RedirectSlashes,
Expand Down Expand Up @@ -268,7 +268,7 @@ func (h backend) count(w http.ResponseWriter, r *http.Request) error {
// TODO: move to memstore?
{
var sess goatcounter.Session
first, err := sess.GetOrCreate(r.Context(), hit.Path, r.UserAgent(), zhttp.RemovePort(r.RemoteAddr))
first, err := sess.GetOrCreate(r.Context(), hit.Path, r.UserAgent(), r.RemoteAddr)
if err != nil {
zlog.Error(err)
}
Expand Down Expand Up @@ -782,7 +782,7 @@ func (h backend) code(w http.ResponseWriter, r *http.Request) error {
}

func (h backend) ip(w http.ResponseWriter, r *http.Request) error {
return zhttp.String(w, zhttp.RemovePort(r.RemoteAddr))
return zhttp.String(w, r.RemoteAddr)
}

func (h backend) saveSettings(w http.ResponseWriter, r *http.Request) error {
Expand Down
2 changes: 1 addition & 1 deletion handlers/website.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type website struct{}

func (h website) Mount(r *chi.Mux, db zdb.DB) {
r.Use(
middleware.RealIP,
zhttp.RealIP,
zhttp.Unpanic(cfg.Prod),
middleware.RedirectSlashes,
addctx(db, false),
Expand Down