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.

OutboundObject.cs 3.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Shadowsocks.Interop.V2Ray.Outbound;
  2. using Shadowsocks.Interop.V2Ray.Transport;
  3. using Shadowsocks.Models;
  4. using System.Net;
  5. namespace Shadowsocks.Interop.V2Ray
  6. {
  7. public class OutboundObject
  8. {
  9. public string Tag { get; set; }
  10. public string? SendThrough { get; set; }
  11. public string Protocol { get; set; }
  12. public object? Settings { get; set; }
  13. public StreamSettingsObject? StreamSettings { get; set; }
  14. public ProxySettingsObject? ProxySettings { get; set; }
  15. public MuxObject? Mux { get; set; }
  16. public OutboundObject()
  17. {
  18. Tag = "";
  19. Protocol = "";
  20. }
  21. /// <summary>
  22. /// Gets the <see cref="OutboundObject"/> for the SOCKS server.
  23. /// </summary>
  24. /// <param name="name">SOCKS server name. Used as outbound tag.</param>
  25. /// <param name="socksEndPoint">The SOCKS server.</param>
  26. /// <param name="username"></param>
  27. /// <param name="password"></param>
  28. /// <returns></returns>
  29. public static OutboundObject GetSocks(string name, DnsEndPoint socksEndPoint, string username = "", string password = "") => new()
  30. {
  31. Tag = name,
  32. Protocol = "socks",
  33. Settings = new Protocols.Socks.OutboundConfigurationObject(socksEndPoint, username, password),
  34. };
  35. /// <summary>
  36. /// Gets the <see cref="OutboundObject"/> for the Shadowsocks server.
  37. /// Plugins are not supported. Plugin information is silently discarded.
  38. /// </summary>
  39. /// <param name="server"></param>
  40. /// <returns></returns>
  41. public static OutboundObject GetShadowsocks(IServer server) => new()
  42. {
  43. Tag = server.Name,
  44. Protocol = "shadowsocks",
  45. Settings = new Protocols.Shadowsocks.OutboundConfigurationObject(server.Host, server.Port, server.Method, server.Password),
  46. };
  47. /// <summary>
  48. /// Gets the <see cref="OutboundObject"/> for the Trojan server.
  49. /// </summary>
  50. /// <param name="address"></param>
  51. /// <param name="port"></param>
  52. /// <param name="password"></param>
  53. /// <returns></returns>
  54. public static OutboundObject GetTrojan(string name, string address, int port, string password) => new()
  55. {
  56. Tag = name,
  57. Protocol = "trojan",
  58. Settings = new Protocols.Trojan.OutboundConfigurationObject(address, port, password),
  59. };
  60. /// <summary>
  61. /// Gets the <see cref="OutboundObject"/> for the VMess server.
  62. /// </summary>
  63. /// <param name="name"></param>
  64. /// <param name="address"></param>
  65. /// <param name="port"></param>
  66. /// <param name="id"></param>
  67. /// <returns></returns>
  68. public static OutboundObject GetVMess(string name, string address, int port, string id) => new()
  69. {
  70. Tag = name,
  71. Protocol = "vmess",
  72. Settings = new Protocols.VMess.OutboundConfigurationObject(address, port, id),
  73. };
  74. }
  75. }