add Close() for relay handler
This commit is contained in:
@ -220,6 +220,14 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close implements io.Closer interface.
|
||||||
|
func (h *relayHandler) Close() error {
|
||||||
|
if h.ep != nil {
|
||||||
|
return h.ep.Close()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h *relayHandler) checkRateLimit(addr net.Addr) bool {
|
func (h *relayHandler) checkRateLimit(addr net.Addr) bool {
|
||||||
if h.options.RateLimiter == nil {
|
if h.options.RateLimiter == nil {
|
||||||
return true
|
return true
|
||||||
|
@ -2,6 +2,7 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
@ -105,6 +106,9 @@ func (s *defaultService) Close() error {
|
|||||||
s.execCmds("pre-down", s.options.preDown)
|
s.execCmds("pre-down", s.options.preDown)
|
||||||
defer s.execCmds("post-down", s.options.postDown)
|
defer s.execCmds("post-down", s.options.postDown)
|
||||||
|
|
||||||
|
if closer, ok := s.handler.(io.Closer); ok {
|
||||||
|
closer.Close()
|
||||||
|
}
|
||||||
return s.listener.Close()
|
return s.listener.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user