Beispiel #1
0
	    private static int Execute(ServerParameters arg) {
	        var config = arg.BuildServerConfig();
	        EnsureRequiredApplications(arg,config);
	        config.DllFolder = EnvironmentInfo.ResolvePath("@[email protected]/.build/bin/all");
            var command = arg.Get("command", "");
	        if (string.IsNullOrWhiteSpace(command)) {
	            Console.WriteLine("LOGLEVEL " + config.LogLevel);
	        }
	        var hostServer = new HostServer(config);
            hostServer.Initialize();
            var consoleContext = new ConsoleContext
            {
                Container = hostServer.Container,
                Parameters = arg
            };
            var listener = new ConsoleListener(consoleContext);
            
	        if (!string.IsNullOrWhiteSpace(command)) {
	            var task = listener.Call(command);
	            task.Wait();
	        }
	        else {

	            LogHostInfo(arg, config);
	            hostServer.Start();
	            Console.WriteLine("LOGLEVEL " + config.LogLevel);

	            listener.Log = hostServer.Container.Get<ILoggyManager>().Get("console");
	            listener.Run();
	            hostServer.Stop();
	        }
	        return 0;
	    }
		internal static RemoteCertificateValidationCallback GetValidationCallback (ServerParameters parameters)
		{
			var validator = parameters.ServerCertificateValidator;
			if (validator == null)
				return null;

			return ((CertificateValidator)validator).ValidationCallback;
		}
        public OutboundEventNotificationService(Session session, ICicStatusService statusService, IDeviceManager deviceManager, ITraceContext traceContext)
        {
            _deviceManager = deviceManager;
            _session = session;
            _traceContext = traceContext;
            _statusService = statusService;
            _statusService.UserStatusChanged += OnUserStatusChanged;

            _session.ConnectionStateChanged += OnConnectionStateChanged;

            _deviceManager.HeadsetConnected += OnDeviceEvent;
            _deviceManager.HeadsetDisconnected += OnDeviceEvent;
            _deviceManager.MuteChanged += OnDeviceEvent;
            _deviceManager.PlantronicsDeviceAttached += OnDeviceEvent;
            _deviceManager.PlantronicsDeviceDetached += OnDeviceEvent;

            _serverParams = new ServerParameters(_session);
            _serverParams.StartWatching(new []{ShouldSendHandlerNotificationParam, WebServerUrlParam});

            PostToWebService();
        }
Beispiel #4
0
	    private static void LogHostInfo(ServerParameters arg, HostConfig config) {
            Console.WriteLine("BinRoot: "+config.DllFolder);
	        foreach (var assembly in config.AutoconfigureAssemblies) {
                arg.Log.Trace("Lib: " + assembly);
	        }
	        foreach (var hostBinding in config.Bindings) {
                arg.Log.Info("Binding: " + hostBinding);
	        }
	        arg.Log.Trace("RootFolder: " + config.RootFolder);
	        foreach (var contentFolder in config.ContentFolders) {
	            arg.Log.Trace("ContentFolder: " + contentFolder);
	        }
	        foreach (var map in config.StaticContentMap) {
	            arg.Log.Trace("Map: "+map.Key+" : "+map.Value);
	        }
            foreach (var map in config.Proxize)
            {
                arg.Log.Trace("Proxize: " + map.Key + " : " + map.Value);
            }
	        foreach (var e in config.StaticContentCacheMap) {
	            arg.Log.Trace(e.Value.ToString());
	        }
	    }
Beispiel #5
0
	    private static void EnsureRequiredApplications(ServerParameters serverParameters, HostConfig config) {
	        var requires = config.Definition.Elements("require");
	        foreach (var require in requires) {
                if(!string.IsNullOrWhiteSpace(require.Attr("server")))continue; //external service
	            var name = require.IdCodeOrValue()+require.Attr("suffix");
	            var shadow = EnvironmentInfo.GetShadowDirectory(name);
	            var processes = Process.GetProcessesByName("qh");
                Console.WriteLine(string.Join("; ",processes.Select(_=>_.ProcessName)));
	            var required =
	                processes.FirstOrDefault(_ => _.MainModule.FileName.NormalizePath().StartsWith(shadow.NormalizePath()));
	            if (null != required) {
	                config.Log.Info("Required '" + name + "' found, PID: " + required.Id);
	            }
	            else {
	                var args = name;
	                if (serverParameters.Get("hidden", false)) {
	                    args += " --hidden";
	                }
	                required = Process.Start(EnvironmentInfo.ResolvePath("@[email protected]/.build/bin/all/qh.exe"), args);
                    config.Log.Info("Required '" + name + "' started, PID: " + required.Id);
	            }
	        }
	    }
		async Task<ISslStream> ISslStreamProvider.CreateServerStreamAsync (Stream stream, ServerParameters parameters, CancellationToken cancellationToken)
		{
			return await CreateServerStreamAsync (stream, parameters, cancellationToken).ConfigureAwait (false);
		}
		public MonoSslStream CreateServerStream (Stream stream, ServerParameters parameters)
		{
			var certificate = CertificateProvider.GetCertificate (parameters.ServerCertificate);

			var protocol = GetProtocol (parameters, true);
			var validator = CallbackHelpers.GetCertificateValidator (parameters.ServerCertificateValidator);

			var askForCert = (parameters.Flags & (ServerFlags.AskForClientCertificate|ServerFlags.RequireClientCertificate)) != 0;

			var sslStream = tlsProvider.CreateSslStream (stream, false, validator);
			sslStream.AuthenticateAsServer (certificate, askForCert, protocol, false);

			return new MonoSslStream (sslStream);
		}
		ISslStream ISslStreamProvider.CreateServerStream (Stream stream, ServerParameters parameters)
		{
			return CreateServerStream (stream, parameters);
		}
		public override IServer CreateServer (ServerParameters parameters)
		{
			if (SupportsMonoExtensions)
				return new MonoServer (this, parameters);
			else
				return new DotNetServer (this, parameters, this);
		}
		public MonoClientAndServerParameters (ClientParameters clientParameters, ServerParameters serverParameters)
			: base (clientParameters, serverParameters)
		{
		}
Beispiel #11
0
		public MonoServer (MonoConnectionProviderImpl provider, ServerParameters parameters)
			: base (provider, parameters)
		{
		}
		public override IMonoServer CreateMonoServer (ServerParameters parameters)
		{
			return new OpenSslServer (this, parameters);
		}
		public override IMonoServer CreateMonoServer (ServerParameters parameters)
		{
			if (!SupportsMonoExtensions)
				throw new InvalidOperationException ();
			return new MonoServer (this, parameters);
		}
		public abstract IMonoServer CreateMonoServer (ServerParameters parameters);
		public CipherInstrumentParameters (InstrumentationCategory category, CipherInstrumentType type, ClientParameters clientParameters, ServerParameters serverParameters)
			: base (category, clientParameters, serverParameters)
		{
			Type = type;
		}
Beispiel #16
0
		public OpenSslServer (OpenSslConnectionProvider provider, ServerParameters parameters)
			: base (provider, parameters)
		{
		}
		public HttpServer CreateServer (IPortableEndPoint endpoint, ListenerFlags flags, ServerParameters parameters = null)
		{
			return new HttpServer (this, endpoint, flags, parameters);
		}
		public override IServer CreateServer (ServerParameters parameters)
		{
			return CreateMonoServer (parameters);
		}
		public Task<MonoSslStream> CreateServerStreamAsync (Stream stream, ServerParameters parameters, CancellationToken cancellationToken)
		{
			return CreateServerStreamAsync (stream, parameters, null, cancellationToken);
		}
		public async Task<MonoSslStream> CreateServerStreamAsync (Stream stream, ServerParameters parameters, MSI.MonoTlsSettings settings, CancellationToken cancellationToken)
		{
			var certificate = CertificateProvider.GetCertificate (parameters.ServerCertificate);
			var protocol = GetProtocol (parameters, true);

			MSI.ICertificateValidator validator = null;
			if (settings != null)
				CallbackHelpers.AddCertificateValidator (settings, parameters.ServerCertificateValidator);
			else
				validator = CallbackHelpers.GetCertificateValidator (parameters.ServerCertificateValidator);

			var askForCert = (parameters.Flags & (ServerFlags.AskForClientCertificate|ServerFlags.RequireClientCertificate)) != 0;

			var sslStream = tlsProvider.CreateSslStream (stream, false, validator, settings);
			var monoSslStream = new MonoSslStream (sslStream);

			try {
				await sslStream.AuthenticateAsServerAsync (certificate, askForCert, protocol, false).ConfigureAwait (false);
			} catch (Exception ex) {
				var lastError = monoSslStream.LastError;
				if (lastError != null)
					throw new AggregateException (ex, lastError);
				throw;
			}

			return monoSslStream;
		}
		public InstrumentationParameters (InstrumentationCategory category, ClientParameters clientParameters, ServerParameters serverParameters)
			: base (clientParameters, serverParameters)
		{
			Category = category;
		}
		public SignatureInstrumentParameters (InstrumentationCategory category, SignatureInstrumentType type, ClientParameters clientParameters, ServerParameters serverParameters)
			: base (category, clientParameters, serverParameters)
		{
			Type = type;
		}
		public SimpleConnectionParameters (InstrumentationCategory category, SimpleConnectionType type, ClientParameters clientParameters, ServerParameters serverParameters)
			: base (category, clientParameters, serverParameters)
		{
			Type = type;
		}