NamedPipeShare.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using SMBLibrary.RPC;
  11. using SMBLibrary.Services;
  12. namespace SMBLibrary.Server
  13. {
  14. public class NamedPipeShare : List<RemoteService>, ISMBShare
  15. {
  16. // A pipe share, as defined by the SMB Protocol, MUST always have the name "IPC$".
  17. public const string NamedPipeShareName = "IPC$";
  18. public NamedPipeShare(List<string> shareList)
  19. {
  20. this.Add(new ServerService(Environment.MachineName, shareList));
  21. this.Add(new WorkstationService(Environment.MachineName, Environment.MachineName));
  22. }
  23. public RemoteService GetService(string path)
  24. {
  25. foreach (RemoteService service in this)
  26. {
  27. if (String.Equals(path, service.PipeName, StringComparison.InvariantCultureIgnoreCase))
  28. {
  29. return service;
  30. }
  31. }
  32. return null;
  33. }
  34. public string Name
  35. {
  36. get
  37. {
  38. return NamedPipeShareName;
  39. }
  40. }
  41. }
  42. }