mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
lint by golangci-lint (#3080)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@@ -44,7 +45,7 @@ func WithBindPort(port int) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithTlsConfig(tlsConfig *tls.Config) Option {
|
||||
func WithTLSConfig(tlsConfig *tls.Config) Option {
|
||||
return func(s *Server) *Server {
|
||||
s.tlsConfig = tlsConfig
|
||||
return s
|
||||
@@ -61,7 +62,7 @@ func WithHandler(h http.Handler) Option {
|
||||
func WithResponse(resp []byte) Option {
|
||||
return func(s *Server) *Server {
|
||||
s.handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(resp)
|
||||
_, _ = w.Write(resp)
|
||||
})
|
||||
return s
|
||||
}
|
||||
@@ -74,16 +75,21 @@ func (s *Server) Run() error {
|
||||
|
||||
addr := net.JoinHostPort(s.bindAddr, strconv.Itoa(s.bindPort))
|
||||
hs := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: s.handler,
|
||||
TLSConfig: s.tlsConfig,
|
||||
Addr: addr,
|
||||
Handler: s.handler,
|
||||
TLSConfig: s.tlsConfig,
|
||||
ReadHeaderTimeout: time.Minute,
|
||||
}
|
||||
|
||||
s.hs = hs
|
||||
if s.tlsConfig == nil {
|
||||
go hs.Serve(s.l)
|
||||
go func() {
|
||||
_ = hs.Serve(s.l)
|
||||
}()
|
||||
} else {
|
||||
go hs.ServeTLS(s.l, "", "")
|
||||
go func() {
|
||||
_ = hs.ServeTLS(s.l, "", "")
|
||||
}()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user