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.

Config.cs 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Shadowsocks.Models;
  2. using System.Collections.Generic;
  3. using System.Text.Json.Serialization;
  4. namespace Shadowsocks.Interop.SsRust
  5. {
  6. public class Config : IGroup<Server>
  7. {
  8. /// <inheritdoc/>
  9. public int Version { get; set; }
  10. /// <inheritdoc/>
  11. public List<Server> Servers { get; set; }
  12. /// <summary>
  13. /// Gets or sets the listening address.
  14. /// </summary>
  15. public string LocalAddress { get; set; }
  16. /// <summary>
  17. /// Gets or sets the listening port.
  18. /// </summary>
  19. public int LocalPort { get; set; }
  20. /// <summary>
  21. /// Gets or sets the timeout for UDP associations in seconds.
  22. /// Defaults to 300 seconds (5 minutes).
  23. /// </summary>
  24. public int? UdpTimeout { get; set; }
  25. /// <summary>
  26. /// Gets or sets the maximum number of UDP associations.
  27. /// Defaults to 0 (unlimited).
  28. /// </summary>
  29. public int UdpMaxAssociations { get; set; }
  30. /// <summary>
  31. /// Gets or sets the server manager address.
  32. /// </summary>
  33. public string? ManagerAddress { get; set; }
  34. /// <summary>
  35. /// Gets or sets the server manager port.
  36. /// </summary>
  37. public int ManagerPort { get; set; }
  38. /// <summary>
  39. /// Gets or sets the DNS server used to resolve hostnames.
  40. /// </summary>
  41. public string? Dns { get; set; }
  42. /// <summary>
  43. /// Gets or sets the mode.
  44. /// Defaults to tcp_only.
  45. /// Can also be tcp_and_udp or udp_only.
  46. /// </summary>
  47. public string Mode { get; set; }
  48. /// <summary>
  49. /// Gets or sets TCP_NODELAY.
  50. /// Defaults to false.
  51. /// </summary>
  52. public bool NoDelay { get; set; }
  53. /// <summary>
  54. /// Gets or sets the soft and hard limit of file descriptors.
  55. /// </summary>
  56. public int Nofile { get; set; }
  57. /// <summary>
  58. /// Gets or sets whether IPv6 addresses take precedence over IPv4 addresses for resolved hostnames.
  59. /// Defaults to false.
  60. /// </summary>
  61. public bool Ipv6First { get; set; }
  62. public Config()
  63. {
  64. Version = 1;
  65. Servers = new();
  66. LocalAddress = "";
  67. LocalPort = 1080;
  68. Mode = "tcp_only";
  69. }
  70. /// <summary>
  71. /// Gets the default configuration for Linux.
  72. /// </summary>
  73. public static Config DefaultLinux => new()
  74. {
  75. LocalAddress = "::1",
  76. Mode = "tcp_and_udp",
  77. NoDelay = true,
  78. Nofile = 32768,
  79. Ipv6First = true,
  80. };
  81. /// <summary>
  82. /// Gets the default configuration for Windows.
  83. /// </summary>
  84. public static Config DefaultWindows => new()
  85. {
  86. LocalAddress = "::1",
  87. Mode = "tcp_and_udp",
  88. Ipv6First = true,
  89. };
  90. }
  91. }