add router handler option
This commit is contained in:
@ -35,9 +35,7 @@ func NewHandler(opts ...handler.Option) handler.Handler {
|
||||
|
||||
return &ssuHandler{
|
||||
bypass: options.Bypass,
|
||||
router: (&chain.Router{}).
|
||||
WithLogger(options.Logger).
|
||||
WithResolver(options.Resolver),
|
||||
router: options.Router,
|
||||
logger: options.Logger,
|
||||
}
|
||||
}
|
||||
@ -47,16 +45,9 @@ func (h *ssuHandler) Init(md md.Metadata) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
h.router.WithRetry(h.md.retryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithChain implements chain.Chainable interface
|
||||
func (h *ssuHandler) WithChain(chain *chain.Chain) {
|
||||
h.router.WithChain(chain)
|
||||
}
|
||||
|
||||
func (h *ssuHandler) Handle(ctx context.Context, conn net.Conn) {
|
||||
defer conn.Close()
|
||||
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
type metadata struct {
|
||||
cipher core.Cipher
|
||||
readTimeout time.Duration
|
||||
retryCount int
|
||||
bufferSize int
|
||||
}
|
||||
|
||||
@ -22,7 +21,6 @@ func (h *ssuHandler) parseMetadata(md mdata.Metadata) (err error) {
|
||||
users = "users"
|
||||
key = "key"
|
||||
readTimeout = "readTimeout"
|
||||
retryCount = "retry"
|
||||
bufferSize = "bufferSize"
|
||||
)
|
||||
|
||||
@ -42,7 +40,6 @@ func (h *ssuHandler) parseMetadata(md mdata.Metadata) (err error) {
|
||||
}
|
||||
|
||||
h.md.readTimeout = mdata.GetDuration(md, readTimeout)
|
||||
h.md.retryCount = mdata.GetInt(md, retryCount)
|
||||
|
||||
if bs := mdata.GetInt(md, bufferSize); bs > 0 {
|
||||
h.md.bufferSize = int(math.Min(math.Max(float64(bs), 512), 64*1024))
|
||||
|
Reference in New Issue
Block a user