add plugin system
This commit is contained in:
@ -35,7 +35,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
|
||||
return err
|
||||
}
|
||||
|
||||
if h.options.Bypass != nil && h.options.Bypass.Contains(address) {
|
||||
if h.options.Bypass != nil && h.options.Bypass.Contains(ctx, address) {
|
||||
log.Debug("bypass: ", address)
|
||||
resp.Status = relay.StatusForbidden
|
||||
_, err := resp.WriteTo(conn)
|
||||
@ -112,7 +112,7 @@ func (h *relayHandler) handleConnectTunnel(ctx context.Context, conn net.Conn, n
|
||||
|
||||
host, sp, _ := net.SplitHostPort(address)
|
||||
|
||||
if h.options.Bypass != nil && h.options.Bypass.Contains(address) {
|
||||
if h.options.Bypass != nil && h.options.Bypass.Contains(ctx, address) {
|
||||
log.Debug("bypass: ", address)
|
||||
resp.Status = relay.StatusForbidden
|
||||
_, err := resp.WriteTo(conn)
|
||||
@ -121,7 +121,7 @@ func (h *relayHandler) handleConnectTunnel(ctx context.Context, conn net.Conn, n
|
||||
|
||||
var tid relay.TunnelID
|
||||
if ingress := h.md.ingress; ingress != nil {
|
||||
tid = parseTunnelID(ingress.Get(host))
|
||||
tid = parseTunnelID(ingress.Get(ctx, host))
|
||||
}
|
||||
if !tid.Equal(tunnelID) && !h.md.directTunnel {
|
||||
resp.Status = relay.StatusBadRequest
|
||||
|
@ -185,7 +185,7 @@ func (h *tunnelHandler) Handle(ctx context.Context, conn net.Conn, opts ...handl
|
||||
|
||||
var tunnelID relay.TunnelID
|
||||
if h.ingress != nil {
|
||||
tunnelID = parseTunnelID(h.ingress.Get(host))
|
||||
tunnelID = parseTunnelID(h.ingress.Get(ctx, host))
|
||||
}
|
||||
if tunnelID.IsZero() {
|
||||
err := fmt.Errorf("no route to host %s", host)
|
||||
@ -248,7 +248,7 @@ func (h *tunnelHandler) handleHTTP(ctx context.Context, raddr net.Addr, rw io.Re
|
||||
|
||||
var tunnelID relay.TunnelID
|
||||
if h.ingress != nil {
|
||||
tunnelID = parseTunnelID(h.ingress.Get(req.Host))
|
||||
tunnelID = parseTunnelID(h.ingress.Get(ctx, req.Host))
|
||||
}
|
||||
if tunnelID.IsZero() {
|
||||
err := fmt.Errorf("no route to host %s", req.Host)
|
||||
|
@ -196,7 +196,7 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle
|
||||
}
|
||||
|
||||
if h.options.Auther != nil &&
|
||||
!h.options.Auther.Authenticate(user, pass) {
|
||||
!h.options.Auther.Authenticate(ctx, user, pass) {
|
||||
resp.Status = relay.StatusUnauthorized
|
||||
resp.WriteTo(conn)
|
||||
return ErrUnauthorized
|
||||
|
Reference in New Issue
Block a user