aboutsummaryrefslogtreecommitdiff
path: root/tools/Crupest.V2ray/Crupest.V2ray/V2rayV5ConfigObjects.cs
blob: f4001c15c29fe255dc28312e1d911be31916e160 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace Crupest.V2ray;

public static class V2rayV5ConfigObjects
{
    public record OutboundObject(string Protocol, object Settings, string Tag, object? StreamSettings)
    {
        public static OutboundObject VmessViaWs(string tag, string address, int port, string uuid, string path)
        {
            return new OutboundObject("vmess", new VmessSettings(address, port, uuid), tag, StreamSettingsObject.Ws(path));
        }

        public static OutboundObject Http(string tag, string address, int port)
        {
            return new OutboundObject("http", new HttpSettingsObject(address, port), tag, null);
        }
    }

    public record WsSettingsObject(string Path, Dictionary<string, string> Headers);

    public record StreamSettingsObject(string Transport, object TransportSettings, string Security, object SecuritySettings)
    {
        public static StreamSettingsObject Ws(string path)
        {
            return new StreamSettingsObject("ws", new WsSettingsObject(path, new()), "tls", new());
        }
    }

    public record VmessSettings(string Address, int Port, string Uuid);

    public record HttpSettingsObject(string Address, int Port);
}