You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerObject.cs 1.1 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Generic;
  2. using System.Net;
  3. namespace Shadowsocks.Interop.V2Ray.Protocols.Socks
  4. {
  5. public class ServerObject
  6. {
  7. public string Address { get; set; }
  8. public int Port { get; set; }
  9. public List<UserObject>? Users { get; set; }
  10. public ServerObject()
  11. {
  12. Address = "";
  13. Port = 0;
  14. }
  15. public ServerObject(DnsEndPoint socksEndPoint, string? username = null, string? password = null)
  16. {
  17. Address = socksEndPoint.Host;
  18. Port = socksEndPoint.Port;
  19. Users = new();
  20. var hasCredential = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password);
  21. if (hasCredential)
  22. {
  23. var user = new UserObject()
  24. {
  25. User = username!, // null check already performed at line 23.
  26. Pass = password!,
  27. };
  28. Users = new()
  29. {
  30. user,
  31. };
  32. }
  33. }
  34. }
  35. }