okkur / torproxy

Caddy plugin to enable easy web to tor proxying
https://torproxy.okkur.org
Apache License 2.0
35 stars 6 forks source link

null pointer with v2 #27

Closed Raviu56 closed 4 years ago

Raviu56 commented 4 years ago

Is this a BUG REPORT or FEATURE REQUEST?: bug

What happened: build torproxy master start it with simple Caddyfile At 1st it throws the following warning

[WARNING] ModuleInfo.New() for module 'http.handlers.torproxy' did not return a pointer, so we are using reflection to make a pointer instead; please fix this by using new(Type) or &Type notation in your module's New() function.

Then when I try to connect to the site; it panics with the following error:

http2: panic serving 96.9.246.194:53060: runtime error: invalid memory address or nil pointer dereference
goroutine 26 [running]:
net/http.(*http2serverConn).runHandler.func1(0xc000010730, 0xc000121f8e, 0xc00012f500)
        /usr/lib64/go/1.14/src/net/http/h2_bundle.go:5713 +0x16b
panic(0xb96e40, 0x12a8040)
        /usr/lib64/go/1.14/src/runtime/panic.go:967 +0x166
github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy.(*Handler).ServeHTTP(0xc00023a000, 0xd9dd60, 0xc00023a3f0, 0xc0000ce800, 0x0, 0x0, 0x0, 0x0)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/reverseproxy/reverseproxy.go:242 +0x2af
go.okkur.org/torproxy.Config.Proxy(0xc00015b410, 0xc0000cd380, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0x1, 0x0)
        /root/torproxy/torproxy.go:52 +0x47f
go.okkur.org/torproxy.TorProxy.ServeHTTP(...)
        /root/torproxy/setup.go:108
github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1(0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0x0, 0x0)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/routes.go:151 +0x62
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc00021a3a0, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0xd90f20, 0xc00021a3a0)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/caddyhttp.go:532 +0x44
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).ServeHTTP(0xc00014d1a0, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0xd90f20, 0xca9b00, 0xc0000db578, 0x0)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/subroute.go:71 +0x80
github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1(0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0x0, 0x8)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/routes.go:151 +0x62
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc00021a340, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0x203000, 0x203000)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/caddyhttp.go:532 +0x44
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).enforcementHandler(0xc000143450, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0xd90f20, 0xc00021a340, 0x40e968, 0x20)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/server.go:237 +0x9b
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).wrapPrimaryRoute.func1(0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0xbdc0a0, 0xc00021a360)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/server.go:213 +0x5a
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc00021a360, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0xc00021a360, 0xc00021a340)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/caddyhttp.go:532 +0x44
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).executeCompositeRoute(0xc000143450, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800, 0xc00000c1e0, 0x1, 0x4, 0xc0001ea930, 0xc000060830)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/server.go:198 +0xff
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc000143450, 0x7fc4c6c0d918, 0xc000183580, 0xc0000ce800)
        /root/go/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0-beta9/modules/caddyhttp/server.go:135 +0x818
net/http.serverHandler.ServeHTTP(0xc0001122a0, 0xd9e720, 0xc000010730, 0xc0000ce600)
        /usr/lib64/go/1.14/src/net/http/server.go:2807 +0xa3
net/http.initALPNRequest.ServeHTTP(0xda0aa0, 0xc0001ea1e0, 0xc0001bc700, 0xc0001122a0, 0xd9e720, 0xc000010730, 0xc0000ce600)
        /usr/lib64/go/1.14/src/net/http/server.go:3381 +0x8d
net/http.(*http2serverConn).runHandler(0xc00012f500, 0xc000010730, 0xc0000ce600, 0xc00021a060)
        /usr/lib64/go/1.14/src/net/http/h2_bundle.go:5720 +0x8b
created by net/http.(*http2serverConn).processHeaders
        /usr/lib64/go/1.14/src/net/http/h2_bundle.go:5454 +0x4e1

Environment: