package tunnel import ( "context" "gitlab.com/wpetit/goweb/logger" ) type OnClientAuthFunc func(ctx context.Context, remoteClient *RemoteClient, credentials interface{}) (bool, error) type OnClientAuthHook interface { OnClientAuth(ctx context.Context, remoteClient *RemoteClient, credentials interface{}) (bool, error) } type OnClientConnectFunc func(ctx context.Context, remoteClient *RemoteClient) error type OnClientConnectHook interface { OnClientConnect(ctx context.Context, remoteClient *RemoteClient) error } type OnClientDisconnectFunc func(ctx context.Context, remoteClient *RemoteClient) error type OnClientDisconnectHook interface { OnClientDisconnect(ctx context.Context, remoteClient *RemoteClient) error } func DefaultOnClientAuth(ctx context.Context, remoteClient *RemoteClient, credentials interface{}) (bool, error) { return true, nil } func DefaultOnClientConnect(ctx context.Context, remoteClient *RemoteClient) error { logger.Debug(ctx, "client connected") return nil } func DefaultOnClientDisconnect(ctx context.Context, remoteClient *RemoteClient) error { logger.Debug(ctx, "client disconnected") return nil } type ServerHooks struct { onClientAuth OnClientAuthFunc onClientConnect OnClientConnectFunc onClientDisconnect OnClientDisconnectFunc } func (h *ServerHooks) OnClientAuth(ctx context.Context, remoteClient *RemoteClient, credentials interface{}) (bool, error) { return h.onClientAuth(ctx, remoteClient, credentials) } func (h *ServerHooks) OnClientConnect(ctx context.Context, remoteClient *RemoteClient) error { return h.onClientConnect(ctx, remoteClient) } func (h *ServerHooks) OnClientDisconnect(ctx context.Context, remoteClient *RemoteClient) error { return h.onClientDisconnect(ctx, remoteClient) }