add tunnel handler and connector

This commit is contained in:
ginuerzh
2023-10-15 15:39:25 +08:00
parent 033151a770
commit 497915f465
24 changed files with 1375 additions and 63 deletions

View File

@ -143,15 +143,12 @@ func (h *relayHandler) handleConnectTunnel(ctx context.Context, conn net.Conn, n
tid = parseTunnelID(ingress.Get(ctx, host))
}
// client is not an public entrypoint.
if h.md.entryPointID.IsZero() || !tunnelID.Equal(h.md.entryPointID) {
if !tid.Equal(tunnelID) && !h.md.directTunnel {
resp.Status = relay.StatusHostUnreachable
resp.WriteTo(conn)
err := fmt.Errorf("no route to host %s", host)
log.Error(err)
return err
}
if !tid.Equal(tunnelID) && !h.md.directTunnel {
resp.Status = relay.StatusHostUnreachable
resp.WriteTo(conn)
err := fmt.Errorf("no route to host %s", host)
log.Error(err)
return err
}
cc, _, err := getTunnelConn(network, h.pool, tid, 3, log)