vhost: use new readClientHello function (#2504)

This commit is contained in:
fatedier
2021-08-03 22:58:03 +08:00
committed by GitHub
parent 09f39de74e
commit 86b2e686a5
3 changed files with 80 additions and 155 deletions

View File

@@ -11,7 +11,7 @@ import (
type Server struct {
bindAddr string
bindPort int
hanlder http.Handler
handler http.Handler
l net.Listener
tlsConfig *tls.Config
@@ -54,14 +54,14 @@ func WithTlsConfig(tlsConfig *tls.Config) Option {
func WithHandler(h http.Handler) Option {
return func(s *Server) *Server {
s.hanlder = h
s.handler = h
return s
}
}
func WithResponse(resp []byte) Option {
return func(s *Server) *Server {
s.hanlder = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
s.handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(resp)
})
return s
@@ -76,7 +76,7 @@ func (s *Server) Run() error {
addr := net.JoinHostPort(s.bindAddr, strconv.Itoa(s.bindPort))
hs := &http.Server{
Addr: addr,
Handler: s.hanlder,
Handler: s.handler,
TLSConfig: s.tlsConfig,
}