package main

import "C"
import (
	"Sunny/SunnyProxy"
	"Sunny/src/net/http"
	"runtime"
	"time"
)
import _ "Sunny/src/net/http/pprof"

func init() {
	runtime.GOMAXPROCS(runtime.NumCPU() - 1)

	go func() {
		http.ListenAndServe("127.0.0.1:6060", nil)
	}()
	SetNetworkConnectNumber()
	//_ = exec.Command("netsh", "int", "ipv4", "set", "dynamicport", "tcp", "start=10000", "num=55000").Run()
	//_ = exec.Command("netsh", "int", "ipv6", "set", "dynamicport", "tcp", "start=10000", "num=55000").Run()

}
func SetNetworkConnectNumber() {
	if runtime.GOOS == "windows" {
		var args []string
		args = append(args, "int")
		args = append(args, "ipv4")
		args = append(args, "set")
		args = append(args, "dynamicport")
		args = append(args, "tcp")
		args = append(args, "start=10000")
		args = append(args, "num=55000")
		execCommand("netsh", args)
		var args1 []string
		args1 = append(args1, "int")
		args1 = append(args1, "ipv6")
		args1 = append(args1, "set")
		args1 = append(args1, "dynamicport")
		args1 = append(args1, "tcp")
		args1 = append(args1, "start=10000")
		args1 = append(args1, "num=55000")
		execCommand("netsh", args1)
	}
}
func main() {
	/*
		for x := 0; x < 100-1; x++ {
			go asd()
		}

		asd()
		time.Sleep(100000 * time.Minute)
	*/
	//
	//Stop()
	//asd()
	//runtime.GOMAXPROCS(16)
	//SunnyProxy.OpenTcpcallback = true
	//OpenTcp(1)

	//	SunnyProxy.AddP12Certificate( "api.yekp.org.cn", "C:\\Users\\qinka\\Desktop\\android_client.p12", "woshimimavvv", 3)

	//SunnyProxy.GlobalProxyIp = "s5|192.168.31.155:2022"
	//GET https://getnewversion.playmeta.pro/app-api/v1/play03-info/appInfo/getVersionInfoByAppName
	//SunnyProxy.AddP12Certificate("getnewversion.playmeta.pro","C:\\Users\\qinka\\Desktop\\dex\\608363d5347c422b.p12","ly7rQjjc1m44c4IyupA", 1)
	//os.Exit(0)
	//SunnyProxy.MustTcp = true

	//SunnyProxy.VerifyUser = true
	/*
		SunnyProxy.VerifyUserList["admin"] = "123456"
		SunnyProxy.Stat(2222, &Handler{}, "", "", OpenTcpcallback)
		fmt.Println("启动失败")
	*/
	SunnyProxy.Stat(2022, &Handler{}, "", "", OpenTcpcallback)
	/*
		PInit(2056, 0, 0, 0)
		time.Sleep(3 * time.Second) //等待1秒
		fmt.Println(StartProcess())
		time.Sleep(3 * time.Second) //等待1秒
		fmt.Println(ProcessStart())
		time.Sleep(3 * time.Second) //等待1秒
		fmt.Println(ProcessAddPID(133724))

	*/
	time.Sleep(100000 * time.Minute)
}
