static public bool EnsureTunnelExists(SqlDBCredentials credentials) { SSHCredentials sshCredentials = credentials.SSHCredentials; SshClient client = null; if (_clients.TryGetClient(sshCredentials, out client) == false) { PrivateKeyConnectionInfo connectionInfo = new PrivateKeyConnectionInfo( sshCredentials.Host, sshCredentials.UserName, new PrivateKeyFile[] { new PrivateKeyFile(sshCredentials.KeyFile) }); client = new SshClient(connectionInfo); client.KeepAliveInterval = TimeSpan.FromMinutes(1); client.ErrorOccurred += Client_ErrorOccurred; client.HostKeyReceived += Client_HostKeyReceived; client.Connect(); if (client.IsConnected) { ForwardedPortLocal port = new ForwardedPortLocal( IPAddress.Loopback.ToString(), sshCredentials.LocalTunnelPort, sshCredentials.TunnelHost, 3306); client.AddForwardedPort(port); port.Start(); if (port.IsStarted == false) { client.Disconnect(); client = null; throw new Exception("Could not forward port"); } _clients.Add(client); } } return(client != null); }
public TimeDataSource(SqlDBCredentials sqlCredentials) : base(sqlCredentials) { }
public DotsDataSource(SqlDBCredentials credentials) { DB = SqlConnectionPool.Instance(credentials).GetDataSource(); }