(List<string> args)
| 563 | } |
| 564 | |
| 565 | public static async Task<int> Execute(List<string> args) |
| 566 | { |
| 567 | using (var loggerFactory = new LoggerFactory()) //.AddConsole().AddDebug(); |
| 568 | { |
| 569 | var logger = loggerFactory.CreateLogger("Test"); |
| 570 | |
| 571 | try |
| 572 | { |
| 573 | var param = new ServerParam(); |
| 574 | |
| 575 | try |
| 576 | { |
| 577 | param.Parse(args); |
| 578 | } |
| 579 | catch (Exception ex) |
| 580 | { |
| 581 | Console.WriteLine("*** FAILED ***"); |
| 582 | Console.WriteLine("Error while parsing arguments"); |
| 583 | Console.WriteLine("{0} {1}\nStack:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace); |
| 584 | return 1; |
| 585 | } |
| 586 | |
| 587 | |
| 588 | // Endpoint transport (mandatory) |
| 589 | TServerTransport trans; |
| 590 | switch (param.transport) |
| 591 | { |
| 592 | case TransportChoice.NamedPipe: |
| 593 | Debug.Assert(param.pipe != null); |
| 594 | var numListen = (param.server == ServerChoice.Simple) ? 1 : 16; |
| 595 | trans = new TNamedPipeServerTransport(param.pipe, Configuration, NamedPipeServerFlags.OnlyLocalClients, numListen); |
| 596 | break; |
| 597 | |
| 598 | |
| 599 | case TransportChoice.TlsSocket: |
| 600 | var cert = GetServerCert(); |
| 601 | if (cert == null || !cert.HasPrivateKey) |
| 602 | { |
| 603 | cert?.Dispose(); |
| 604 | throw new InvalidOperationException("Certificate doesn't contain private key"); |
| 605 | } |
| 606 | |
| 607 | trans = new TTlsServerSocketTransport(param.port, Configuration, |
| 608 | cert, |
| 609 | (sender, certificate, chain, errors) => true, |
| 610 | null); |
| 611 | break; |
| 612 | |
| 613 | case TransportChoice.Socket: |
| 614 | default: |
| 615 | trans = new TServerSocketTransport(param.port, Configuration); |
| 616 | break; |
| 617 | } |
| 618 | |
| 619 | // Layered transport (mandatory) |
| 620 | TTransportFactory? transFactory; |
| 621 | switch (param.buffering) |
| 622 | { |
no test coverage detected