using Shadowsocks.Interop.V2Ray.Outbound;
using Shadowsocks.Interop.V2Ray.Transport;
using Shadowsocks.Models;
using System;
using System.Net;
namespace Shadowsocks.Interop.V2Ray
{
public class OutboundObject
{
public string Tag { get; set; }
public string? SendThrough { get; set; }
public string Protocol { get; set; }
public object? Settings { get; set; }
public StreamSettingsObject? StreamSettings { get; set; }
public ProxySettingsObject? ProxySettings { get; set; }
public MuxObject? Mux { get; set; }
public OutboundObject()
{
Tag = "";
Protocol = "";
}
///
/// Gets the for the SOCKS server.
///
/// SOCKS server name. Used as outbound tag.
/// The SOCKS server.
///
///
///
public static OutboundObject GetSocks(string name, DnsEndPoint socksEndPoint, string username = "", string password = "") => new()
{
Tag = name,
Protocol = "socks",
Settings = new Protocols.Socks.OutboundConfigurationObject(socksEndPoint, username, password),
};
///
/// Gets the for the Shadowsocks server.
/// Plugins are not supported.
///
///
///
public static OutboundObject GetShadowsocks(IServer server)
{
if (!string.IsNullOrEmpty(server.Plugin))
throw new InvalidOperationException("V2Ray doesn't support SIP003 plugins.");
return new()
{
Tag = server.Name,
Protocol = "shadowsocks",
Settings = new Protocols.Shadowsocks.OutboundConfigurationObject(server.Host, server.Port, server.Method, server.Password),
};
}
///
/// Gets the for the Trojan server.
///
///
///
///
///
public static OutboundObject GetTrojan(string name, string address, int port, string password) => new()
{
Tag = name,
Protocol = "trojan",
Settings = new Protocols.Trojan.OutboundConfigurationObject(address, port, password),
};
///
/// Gets the for the VMess server.
///
///
///
///
///
///
public static OutboundObject GetVMess(string name, string address, int port, string id) => new()
{
Tag = name,
Protocol = "vmess",
Settings = new Protocols.VMess.OutboundConfigurationObject(address, port, id),
};
}
}