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 uses: actions/setup-go@v1
with: with:
go-version: 1.15.x go-version: 1.15.x
- name: Go Env
run: go env
- name: Test - name: Test
run: go test -v . run: go test -v .
@ -27,5 +29,7 @@ jobs:
uses: actions/setup-go@v1 uses: actions/setup-go@v1
with: with:
go-version: 1.15.x go-version: 1.15.x
- name: Go Env
run: go env
- name: Build - name: Build
run: go build -v . run: go build -v .

View File

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

10
main.go
View File

@ -1,10 +1,8 @@
package main package main
import ( import (
"context"
"fmt" "fmt"
stdlog "log" stdlog "log"
"net"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
@ -36,7 +34,7 @@ import (
_ "github.com/nadoo/glider/proxy/ws" _ "github.com/nadoo/glider/proxy/ws"
) )
var version = "0.10.3" var version = "0.10.4"
func main() { func main() {
// read configs // read configs
@ -78,12 +76,6 @@ func main() {
} }
d.Start() 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 // enable checkers

View File

@ -161,7 +161,7 @@ func (s *HTTP) servHTTP(req *request, c *conn.Conn) {
writeStartLine(buf, proto, code, status) writeStartLine(buf, proto, code, status)
writeHeaders(buf, header) 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()) c.Write(buf.Bytes())
conn.Copy(c, r) conn.Copy(c, r)