yao/tai/registry/testing.go
Max 6408c140fc Implement tunnel mode support in Tai service
- Introduce a new "tunnel" scheme for the Tai client, allowing connections through Yao's reverse proxy.
- Enhance the Tai registry to manage tunnel-connected nodes and their ports.
- Add WebSocket and reverse proxy routes for tunnel connections in the OpenAPI server.
- Implement tunnel-specific proxy and VNC handling to facilitate communication with containerized environments.
- Update gRPC environment variable handling to support tunnel connections.

These changes improve the Tai service's flexibility and connectivity options, enabling better integration with remote and containerized environments.
2026-03-06 17:12:36 +08:00

31 lines
807 B
Go

package registry
import (
"log/slog"
"net"
"time"
)
// NewForTest creates a standalone Registry for use in tests.
// Not intended for production use.
func NewForTest() *Registry {
return &Registry{
nodes: make(map[string]*TaiNode),
pending: make(map[string]*pendingChannel),
logger: slog.Default(),
}
}
// SetGlobalForTest replaces the global registry singleton for testing.
// Not intended for production use.
func SetGlobalForTest(r *Registry) {
global = r
}
// SetPendingForTest injects a pending channel entry for testing.
// Not intended for production use.
func (r *Registry) SetPendingForTest(channelID, taiID string, result chan net.Conn, timer *time.Timer) {
r.mu.Lock()
defer r.mu.Unlock()
r.pending[channelID] = &pendingChannel{taiID: taiID, result: result, timer: timer}
}