package io.wdd.func.xray.beans.config;

import io.wdd.func.xray.beans.xray.protocol.outbound.OutboundConfigurationObject;
import io.wdd.func.xray.beans.xray.protocol.outbound.VMESS;
import io.wdd.func.xray.beans.xray.protocol.outbound.VmessOutSettings;
import io.wdd.func.xray.beans.xray.transport.*;

import java.util.ArrayList;
import java.util.List;


public class OutboundVmessTCPTemplateClass {

    public static OutboundObject OutboundVmessTCPTemplate;

    static {
        OutboundVmessTCPTemplate = new VMESS();

        // 构造TCP
        TcpObject tcpObject = new TcpObject();
        // 默认的Header结构为
        // {
        //  "header": {
        //    "type": "none"
        //  }
        //}
        NoneHeaderObject noneHeaderObject = new NoneHeaderObject();
        tcpObject.setHeader(noneHeaderObject);

        StreamSettingsObject streamSettingsObject = new StreamSettingsObject();
        streamSettingsObject.setTcpSettings(tcpObject);
        OutboundVmessTCPTemplate.setStreamSettings(streamSettingsObject);

        // 需要初始化这个，作为结构的补充
        VmessOutSettings vmessOutSettings = new VmessOutSettings();
        OutboundConfigurationObject.ServerObject serverObject = new OutboundConfigurationObject.ServerObject();
        vmessOutSettings.setVnext(
                new ArrayList<>(
                        List.of(serverObject)
                )
        );
        OutboundVmessTCPTemplate.setSettings(vmessOutSettings);

        // mux的部分
        MuxObject muxObject = new MuxObject();
        muxObject.setConcurrency(4);
        muxObject.setEnabled(Boolean.TRUE);
        OutboundVmessTCPTemplate.setMux(muxObject);
    }
}
