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

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

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

import static io.wdd.func.xray.beans.config.TcpHttpHeaderTemplate.HttpRequestTemplate;


public class OutboundVmessHTTPTemplateClass {

    public static OutboundObject OutboundVmessHTTPTemplate;
    public static OutboundObject OutboundFree;
    public static OutboundObject OutboundBlackHole;

    static {

        OutboundVmessHTTPTemplate = new VMESS();

        // 构造TCP
        TcpObject tcpObject = new TcpObject();

        // 设置TCP的伪装部分
        // 参考 https://www.v2ray.com/chapter_02/transport/tcp.html
        HttpHeaderObject httpHeaderObject = new HttpHeaderObject();
        httpHeaderObject.setRequest(HttpRequestTemplate);
        tcpObject.setHeader(httpHeaderObject);


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

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

        // mux的部分
        MuxObject muxObject = new MuxObject();
        muxObject.setConcurrency(-1);
        muxObject.setEnabled(Boolean.FALSE);
        OutboundVmessHTTPTemplate.setMux(muxObject);


        // 其它的部分
        OutboundFree = new Freedom();

        OutboundBlackHole = new Blackhole();
        OutboundBlackHole.setTag("block");

    }
}
