Beispiel #1
0
        static void Server(string[] args)
        {
            var           newArgs = new ArraySegment <string> (args, 1, args.Length - 1);
            ServerFactory factory = Factory.MonoServer;
            int           repeat  = 0;

            var parameters = new ServerParameters();

            var p = new OptionSet {
                { "server=", v => factory = ConnectionFactoryProvider.GetServerFactory(v) },
                { "verbose", v => parameters.EnableDebugging = true },
                { "repeat", (int v) => repeat = v }
            };
            var extra = p.Parse(newArgs);

            if (extra.Count != 0)
            {
                throw new InvalidOperationException();
            }

            if (repeat < 0)
            {
                repeat = int.MaxValue;
            }
            else if (repeat == 0)
            {
                repeat = 1;
            }

            for (int i = 0; i < repeat; i++)
            {
                RunServer(factory, parameters).Wait();
            }
        }
Beispiel #2
0
        void Connection(params string[] args)
        {
            int repeat = 0;

            var clientFactory = Factory.OpenSslClient;
            var serverFactory = Factory.OpenSslServer;

            var parameters = new ClientAndServerParameters();

            parameters.VerifyPeerCertificate = false;
            parameters.TrustedCA             = ResourceManager.LocalCACertificate;

            var p = new OptionSet {
                { "verbose", v => parameters.EnableDebugging = true },
                { "repeat=", (int v) => repeat = v },
                { "client=", v => clientFactory = ConnectionFactoryProvider.GetClientFactory(v) },
                { "server=", v => serverFactory = ConnectionFactoryProvider.GetServerFactory(v) },
                { "verify", v => parameters.VerifyPeerCertificate = true },
                { "ask-for-cert", v => parameters.AskForClientCertificate = true },
                { "require-cert", v => parameters.RequireClientCertificate = true }
            };
            var extra = p.Parse(args);

            if (extra.Count != 0)
            {
                throw new InvalidOperationException();
            }

            if (repeat < 0)
            {
                repeat = int.MaxValue;
            }
            else if (repeat == 0)
            {
                repeat = 1;
            }

            var factory = new ClientAndServerFactory(serverFactory, clientFactory);

            for (int i = 0; i < repeat; i++)
            {
                RunWithLocalServer(factory, parameters).Wait();
            }
        }