示例#1
0
 public string AcceptClient(string[] commandParts)
 {
     if (commandParts.Length < 2)
     {
         // TODO: PrintInteractiveHelp(commandParts[0]);
         throw new ArgumentException("invalid command parts");
     }
     else
     {
         lock (_whitelist)
         {
             var thumbprint = commandParts[1];
             _whitelist.TryGetAlias(thumbprint, out string alias);
             alias = commandParts.Length > 2
                 ? commandParts[2]
                 : alias
                     ?? thumbprint;
             _whitelist.Set(thumbprint, alias);
             _cqHub.UpdatePeerInfo(peer =>
             {
                 if (peer.Thumbprint.Equals(thumbprint, StringComparison.OrdinalIgnoreCase))
                 {
                     peer.Alias = alias;
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             });
             _whitelist.StoreWhitelist();
             return($"ACCEPT: '{thumbprint}' => '{alias}'".Log());
         }
     }
 }