http: better logging

This commit is contained in:
nadoo 2020-09-13 23:28:01 +08:00
parent 0e89d1879f
commit b3b11b4188
4 changed files with 8 additions and 10 deletions

View File

@ -13,6 +13,8 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.15.x
- name: Go Env
run: go env
- name: Test
run: go test -v .
@ -27,5 +29,7 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.15.x
- name: Go Env
run: go env
- name: Build
run: go build -v .

View File

@ -17,6 +17,8 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.15.x
- name: Go Env
run: go env
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:

10
main.go
View File

@ -1,10 +1,8 @@
package main
import (
"context"
"fmt"
stdlog "log"
"net"
"os"
"os/signal"
"syscall"
@ -36,7 +34,7 @@ import (
_ "github.com/nadoo/glider/proxy/ws"
)
var version = "0.10.3"
var version = "0.10.4"
func main() {
// read configs
@ -78,12 +76,6 @@ func main() {
}
d.Start()
net.DefaultResolver.PreferGo = true
net.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{}
return d.DialContext(ctx, "udp", conf.DNS)
}
}
// enable checkers

View File

@ -161,7 +161,7 @@ func (s *HTTP) servHTTP(req *request, c *conn.Conn) {
writeStartLine(buf, proto, code, status)
writeHeaders(buf, header)
log.F("[http] %s <-> %s", c.RemoteAddr(), req.target)
log.F("[http] %s <-> %s via %s", c.RemoteAddr(), req.target, dialer.Addr())
c.Write(buf.Bytes())
conn.Copy(c, r)