Пример #1
0
func (info *DumpFileInfo) GenTencentDumpInfo() {
	path := "./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_

	version := info.info_["version"]

	count := strings.Count(version, "_")
	if count > 1 {
		index := strings.Index(version, "_")
		version = version[:index]
	}

	context := file.ReadFile(path)
	intputlibname := goCfgMgr.Get("libname", "inputname").(string)
	outputlibname := goCfgMgr.Get("libname", "outputname").(string)

	ref_str := strings.Replace(outputlibname, ".", "\\.", 1)
	re := regexp.MustCompile(ref_str)
	finale_context := string(context)
	re.ReplaceAllLiteralString(finale_context, version+"_"+intputlibname)

	file.WriteFile(path, []byte(finale_context), os.O_TRUNC)

	cmd := exec.Command("/bin/sh", "./gen_ndk_info.sh", info.info_["version"], info.file_name_, info.project)
	_, err := cmd.Output()
	if err != nil {
		log.Println("GenNdkfile err:" + err.Error())
	}

}
Пример #2
0
func TestJava(url string, ver string) {
	dump_context := file.ReadFile("./testresourse/test.java")
	out, err := exec.Command("uuidgen").Output()
	if err != nil {
		log.Println("uuidgen err :", err)
	}
	msg := "UUID:" + string(out) + "device:test_client_tool\nversion:" + ver + "\nproduct_name:test\n"

	dump := "file:" + string(dump_context)
	h := md5.New()
	h.Write([]byte(msg))
	result_str := hex.EncodeToString(h.Sum(nil))

	msg_sender := "java:" + result_str + "\n" + msg + dump
	body := bytes.NewBufferString(msg_sender)
	log.Println(url)
	resp, err_http := http.Post(url, "", body)
	if err != nil {
		log.Println("TestJava err :", err_http)
	}
	if resp != nil {
		resp.Body.Close()
	}

	c <- 1
}
Пример #3
0
func (info *DumpFileInfo) GenNdkDumpInfo() {
	context := file.ReadFile("./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_ + ".info")
	//context := file.ReadFile("./a.txt.info")
	start_pos := 0

	open_stack := false
	open_lib_info := false

	for i := 0; i < len(context); i++ {
		if context[i] == '\n' {
			if i-start_pos > 1 {
				temp_str := string(context[start_pos:i])

				matched, _ := regexp.MatchString("(?i:^Thread).*(crashed)", temp_str)
				if matched {
					//log.Println("regexp : ", temp_str)
					open_stack = true
				}

				if open_stack {
					info.GenNdkStack(temp_str)
					matched, _ = regexp.MatchString("(?i:^Thread)[\\s]\\d{1,2}$", temp_str)
					if matched {
						//log.Println("regexp : ", temp_str)
						open_stack = false
					}
				}

				matched, _ = regexp.MatchString("(?i:^Loaded)[\\s](modules:)$", temp_str)
				if matched {
					//log.Println("regexp : ", temp_str)
					open_lib_info = true
				}

				if open_lib_info {
					libname := goCfgMgr.Get("libname", "outputname").(string)
					matched, _ = regexp.MatchString("0x[0-9|a-f]{8}\\s-\\s0x[0-9|a-f]{8}\\s{2}"+libname+"\\s{2}\\?{3}$", temp_str)
					if matched {
						//log.Println("regexp : ", temp_str)
						info.GenNdkSoAddress(temp_str)
						open_lib_info = false
					}
				}

			}

			start_pos = i + 1

		}
	}

	info.GenNdkfile()

}
Пример #4
0
func (info *DumpFileInfo) GenDbInfo() {
	context := file.ReadFile("./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_ + ".ndk.info")
	//context := file.ReadFile("./a.txt.info")
	start_pos := 0

	address_info := 3
	info_str := ""
	info_key := ""
	for i := 0; i < len(context); i++ {
		if context[i] == '\n' {
			if i-start_pos > 1 {
				temp_str := string(context[start_pos:i])

				re := regexp.MustCompile("pc\\s{1}[0-9|a-f]{8}")
				matched := re.FindString(temp_str)

				if matched != "" && address_info > 0 {
					libname := goCfgMgr.Get("libname", "inputname").(string)
					prostack_flag, _ := regexp.MatchString(libname, temp_str)
					if prostack_flag {
						re = regexp.MustCompile("[0-9|a-f]{8}")
						key := re.FindString(matched)

						info_key = info_key + "_" + key
						address_info--
					}

				}

				info_str = info_str + temp_str + "<br>"

			}

			start_pos = i + 1

		}
	}
	//db.CreateDB(info.project, info.info_["version"], info_key, info_str, info.info_["UUID"])
	mysql_c, db_err := dbinfo.Init()
	if db_err == nil {
		mysql_c.AddInfo(info.project, info.info_["version"], info_key, info_str, info.info_["UUID"], info.lianyun)
		mysql_c.AddDeviceInfo(info.project, info.info_["version"], info_key, info.info_["device"], info.lianyun, info.info_["UUID"])
	}
}
Пример #5
0
func (info *JavaFileInfo) GenJavaDBInfo() {

	s := file.ReadFile("./" + info.project + "/dump/" + info.info_["version"] + "/" + info.file_name_)
	context := string(s)

	start_pos := 0
	info_key := ""
	key_index := 0
	for i := 0; i < len(context); i++ {
		if context[i] == '\n' {
			if i-start_pos > 1 {
				temp_str := string(context[start_pos:i])

				re := regexp.MustCompile("\\([^\\(\\)]*\\.java:[0-9]{0,10}\\)")
				matched := re.FindString(temp_str)
				if matched != "" {
					//fmt.Println("matched : ", matched)
					key_index++
					info_key += matched
					if key_index >= 3 {
						break
					}
				}
			}
			start_pos = i + 1

		}
	}

	h := md5.New()
	h.Write([]byte(info_key))
	result_str := hex.EncodeToString(h.Sum(nil))

	mysql_c, db_err := dbinfo.Init()
	if db_err == nil {
		mysql_c.AddInfo(info.project, info.info_["version"], result_str, context, info.info_["UUID"], info.lianyun)
		mysql_c.AddDeviceInfo(info.project, info.info_["version"], info_key, info.info_["device"], info.lianyun, info.info_["UUID"])
	}
}
Пример #6
0
func (s HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {

	//r.ParseForm()
	log.Println("Form:", r.Form)
	log.Println("Url", r.URL)
	log.Println("RequestURL", r.RequestURI)

	params := parseURL(r.URL)

	url_list := strings.Split(r.RequestURI, "/")

	if len(url_list) >= 2 {
		if url_list[1] == "file" && len(url_list) == 5 {
			pro := url_list[2]
			ver := url_list[3]
			file_name := url_list[4]

			path := "./" + pro + "/dump/" + ver + "/" + file_name
			http.ServeFile(w, r, path)
			return
		} else if url_list[1] == "tencent" {
			context := file.ReadFile("./tencent_create.html")
			fmt.Fprintf(w, string(context))
		}
	}

	log.Println("params:", params)
	// 新版参数解析
	if len(params) >= 2 {
		pat := params["pat"]
		if pat == "" {
			return
		}

		pro := params["pro"]
		if pro == "" {
			return
		}

		if pat == "get" {
			ver_array := params["ver"]
			if ver_array == "" {
				fmt.Fprintf(w, dbinfo.GerVersionList(pro))
			} else {
				ver := params["ver"]
				fmt.Fprintf(w, dbinfo.GetDumpList(pro, ver))
			}
		} else if pat == "post" {

			lianyun := params["lianyun"]
			if lianyun == "" {
				lianyun = pro
			}

			reqContent, err := ioutil.ReadAll(r.Body)
			//log.Println("reqContent ", string(reqContent))
			if err != nil {
				log.Println(err)
				return
			} else if reqContent == nil || len(reqContent) < 1 {
				log.Println("empty body!")
				return
			}
			result := CheckLegal(string(reqContent))
			if result {
				proname := GetProName(pro, lianyun)
				contentSrc := string(reqContent)
				dumpProcessChan <- 1
				go dumpfile.ProcessDumpFile(dumpProcessChan, proname, contentSrc, lianyun)
			} else {
				log.Println("error check md5 :", r.Form)
			}
		} else if pat == "recreate" {

			ver := params["ver"]
			if ver == "" {
				return
			}

			lianyun := params["lianyun"]
			if lianyun == "" {
				return
			}

			proname := GetProName(pro, lianyun)
			path := "./" + proname + "/dump/" + ver + "/"

			go dumpfile.ListFileName(path, ver, pro, lianyun)

		} else if pat == "detail" {

			id := params["id"]
			if id == "" {
				return
			}

			ver := params["ver"]
			if ver == "" {
				return
			}

			fmt.Fprintf(w, dbinfo.GetDumpFileList(pro, ver, id))

		} else if pat == "create_tencent" {

			ver := params["ver"]
			if ver == "" {
				return
			}

			lianyun := params["lianyun"]
			if lianyun == "" {
				return
			}

			proname := GetProName(pro, lianyun)
			path := "./" + proname + "/tencentdump/"

			go dumpfile.ListTencentFileName(path, ver, pro, lianyun)

		} else if pat == "allversion" {

			fmt.Fprintf(w, dbinfo.GetAllVersionList(pro))

		}

	}

	/*if len(r.Form) == 1 {
		val := r.Form["par"]

		if len(val) > 0 && val[0] == "post" {
			reqContent, err := ioutil.ReadAll(r.Body)
			if err != nil {
				log.Println(err)
				return
			} else if reqContent == nil || len(reqContent) < 1 {
				log.Println("empty body!")
				return
			}

			result := CheckLegal(string(reqContent))
			if result {
				go dumpfile.ProcessDumpFile("sxda", reqContent, "sxda")
			} else {
				log.Println("error check md5 :", r.Form)
			}
		}
	}*/

}