Commit 96fcc2fc authored by 王明明's avatar 王明明

vy 0321

parent 979ffc14
```shell ```shell
docker run -itd --name lcc-akm-api1 --privileged=true --restart=always -v /home/opt/lcc-akm/src:/root/src/ -p 59001:59001 --cpus=1 -m 1G --log-driver=json-file --log-opt max-size=50m --log-opt max-file=3 golang/goenv:2.0 /bin/sh "/root/src/run.sh" docker run -itd --name lcc-akm-api12 --privileged=true --restart=always -v /home/opt/lcc-akm2/src:/root/src/ -p 59002:59001 --cpus=1 -m 1G --log-driver=json-file --log-opt max-size=50m --log-opt max-file=3 golang/goenv:2.0 /bin/sh "/root/src/run.sh"
``` ```
\ No newline at end of file
package model package model
import ( import (
"encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
...@@ -150,6 +151,24 @@ func (akm *AkmClient) postSensorJs(times int) error { ...@@ -150,6 +151,24 @@ func (akm *AkmClient) postSensorJs(times int) error {
akm.logger.Info("第", times, "生成一次 abck 耗时 ", t2.Sub(t1).String(), " 响应abck结果 ", statusCode, " abck长度 ", len(abck), " 请求耗时 ", time.Since(t2).String()) akm.logger.Info("第", times, "生成一次 abck 耗时 ", t2.Sub(t1).String(), " 响应abck结果 ", statusCode, " abck长度 ", len(abck), " 请求耗时 ", time.Since(t2).String())
return nil return nil
} }
func (akm *AkmClient) getSensorBm(times int) string {
abck, bm_sz := akm.GetCookie()
t1 := time.Now()
datas := fmt.Sprintf("times=%d&abck=%s&bm_sz=%s&url=%s", times, abck, bm_sz, akm.postUrl)
r, _ := http.Post("http://127.0.0.1:3033/akm2t", "application/x-www-form-urlencoded", strings.NewReader(datas))
rs, _ := io.ReadAll(r.Body)
rsss := strings.Split(string(rs), "|||||")
sensorData := rsss[0]
t2 := time.Now()
bmRes := ""
abckList := strings.Split(abck, "~")
bmRes = fmt.Sprintf("a=%s&&&e=%s&&&sensor_data=%s", abckList[0], base64.StdEncoding.EncodeToString([]byte(bmRes)), base64.StdEncoding.EncodeToString([]byte(sensorData)))
akm.logger.Info("第", times, "生成一次 bm 耗时 ", t2.Sub(t1).String())
return bmRes
}
func (akm *AkmClient) postSensor(times int) error { func (akm *AkmClient) postSensor(times int) error {
abck, bmsz := akm.GetCookie() abck, bmsz := akm.GetCookie()
......
package model
import "github.com/sirupsen/logrus"
func Common(carrierType, proxyUrl string) (*Akm, error) {
logger := logrus.WithField("type", carrierType)
logger.Info("使用代理", proxyUrl)
akmClient := NewAkmClient(NKURL, NKPostUrl, proxyUrl, logger)
err := akmClient.init()
if err != nil {
return nil, err
}
for i := 0; i < 4; i++ {
err := akmClient.postSensorJs(i)
if err != nil {
akmClient.logger.WithError(err).Errorln("请求失败")
return nil, err
}
}
akm := &Akm{
Cookies: akmClient.GetAllCookie(),
Ua: akmClient.ua,
}
//query()
return akm, nil
}
package model
import "github.com/sirupsen/logrus"
func EW(carrierType, proxyUrl string) (*Akm, error) {
// 特殊处理
bm := "akamai-bm-telemetry"
logger := logrus.WithField("type", carrierType)
logger.Info("使用代理", proxyUrl)
akmClient := NewAkmClient(EWUrl, EWPostUrl, proxyUrl, logger)
err := akmClient.init()
if err != nil {
return nil, err
}
for i := 0; i < 3; i++ {
err := akmClient.postSensorJs(i)
if err != nil {
akmClient.logger.WithError(err).Errorln("请求失败")
return nil, err
}
a, _ := akmClient.GetCookie()
if len(a) == 494 {
break
}
}
cookies := akmClient.GetAllCookie()
cookies[bm] = akmClient.getSensorBm(4)
akm := &Akm{
Cookies: cookies,
Ua: akmClient.ua,
}
//query()
return akm, nil
}
...@@ -28,6 +28,8 @@ func routeAkm(w http.ResponseWriter, r *http.Request) { ...@@ -28,6 +28,8 @@ func routeAkm(w http.ResponseWriter, r *http.Request) {
akm, akmErr = VueLing(carrierType, data["proxy"]) akm, akmErr = VueLing(carrierType, data["proxy"])
case "NK": case "NK":
akm, akmErr = NK(carrierType, data["proxy"]) akm, akmErr = NK(carrierType, data["proxy"])
case "EW":
akm, akmErr = EW(carrierType, data["proxy"])
default: default:
util.WriteJson(w, util.ErrorJson("不支持的航司")) util.WriteJson(w, util.ErrorJson("不支持的航司"))
return return
......
...@@ -14,4 +14,7 @@ const ( ...@@ -14,4 +14,7 @@ const (
VYPostUrl = "https://m.vueling.com/SB" VYPostUrl = "https://m.vueling.com/SB"
NKURL = "https://www.spirit.com" NKURL = "https://www.spirit.com"
NKPostUrl = "https://www.spirit.com" NKPostUrl = "https://www.spirit.com"
EWUrl = "https://www.eurowings.com/"
EWPostUrl = "https://www.eurowings.com/"
) )
...@@ -26,8 +26,8 @@ func query(data []byte) { ...@@ -26,8 +26,8 @@ func query(data []byte) {
tls_client.WithClientProfile(tls_client.Chrome_110), tls_client.WithClientProfile(tls_client.Chrome_110),
tls_client.WithNotFollowRedirects(), tls_client.WithNotFollowRedirects(),
tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument
tls_client.WithProxyUrl("http://127.0.0.1:8890"), //tls_client.WithProxyUrl("http://127.0.0.1:8890"),
//tls_client.WithProxyUrl("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600"), tls_client.WithProxyUrl("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600"),
tls_client.WithInsecureSkipVerify(), tls_client.WithInsecureSkipVerify(),
} }
uri, _ := url.Parse("https://www.easyjet.com/") uri, _ := url.Parse("https://www.easyjet.com/")
...@@ -64,6 +64,53 @@ func query(data []byte) { ...@@ -64,6 +64,53 @@ func query(data []byte) {
//readBytes, _ := io.ReadAll(resp.Body) //readBytes, _ := io.ReadAll(resp.Body)
//fmt.Println(string(readBytes)) //fmt.Println(string(readBytes))
}
func querynk(data []byte) {
v := model.Akm{}
json.Unmarshal(data, &v)
fmt.Println(v)
jar := tls_client.NewCookieJar()
options := []tls_client.HttpClientOption{
tls_client.WithTimeoutSeconds(30),
tls_client.WithClientProfile(tls_client.Chrome_110),
tls_client.WithNotFollowRedirects(),
tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument
//tls_client.WithProxyUrl("http://127.0.0.1:8890"),
tls_client.WithProxyUrl("http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600"),
tls_client.WithInsecureSkipVerify(),
}
uri, _ := url.Parse("https://www.spirit.com/")
var cookies []*http.Cookie
for key, value := range v.Cookies {
cookies = append(cookies, &http.Cookie{
Name: key,
Value: value,
})
}
jar.SetCookies(uri, cookies)
Client, err := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...)
req, err := http.NewRequest("POST", "https://www.spirit.com/api/nk-token/api/v1/token", strings.NewReader("{\"applicationName\": \"dotRezWeb\"}"))
if err != nil {
panic(err)
}
req.Header = http.Header{
"accept": {"application/json, text/plain, */*"},
"accept-language": {"de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"},
"user-agent": {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"},
"ocp-apim-subscription-key": {"dc6844776fe84b1c8b68affe7deb7916"},
"content-type": {"application/json"},
}
resp, err := Client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("响应结果", resp.StatusCode)
readBytes, _ := io.ReadAll(resp.Body)
fmt.Println(string(readBytes))
} }
func actU2() { func actU2() {
t1 := time.Now() t1 := time.Now()
...@@ -87,10 +134,10 @@ func actVY() { ...@@ -87,10 +134,10 @@ func actVY() {
px = "http://127.0.0.1:8890" px = "http://127.0.0.1:8890"
} }
t1 := time.Now() t1 := time.Now()
//resp, err := http.Post("http://lcc.unififi.com/akamai/gen", resp, err := http.Post("http://lcc.unififi.com/akamai/gen",
resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", //resp, err := http.Post("http://127.0.0.1:59001/akamai/gen",
//"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \""+px+"\"}")) "application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \""+px+"\"}"))
"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \"http://127.0.0.1:8890\"}")) //"application/json", strings.NewReader("{\"type\": \"VY\", \"proxy\": \"http://127.0.0.1:8890\"}"))
//resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", "application/json", strings.NewReader("{\"type\": \"u2\", \"proxy\": \"http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600\"}")) //resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", "application/json", strings.NewReader("{\"type\": \"u2\", \"proxy\": \"http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600\"}"))
if err != nil { if err != nil {
//panic(err) //panic(err)
...@@ -101,6 +148,22 @@ func actVY() { ...@@ -101,6 +148,22 @@ func actVY() {
fmt.Println("abck cost", time.Since(t1).String()) fmt.Println("abck cost", time.Since(t1).String())
testVY(px, body) testVY(px, body)
} }
func actnk() {
t1 := time.Now()
resp, err := http.Post("http://lcc.unififi.com/akamai/gen",
//resp, err := http.Post("http://127.0.0.1:59001/akamai/gen",
"application/json", strings.NewReader("{\"type\": \"NK\", \"proxy\": \"http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600\"}"))
//"application/json", strings.NewReader("{\"type\": \"U2\", \"proxy\": \"http://127.0.0.1:8890\"}"))
//resp, err := http.Post("http://127.0.0.1:59001/akamai/gen", "application/json", strings.NewReader("{\"type\": \"u2\", \"proxy\": \"http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600\"}"))
if err != nil {
//panic(err)
fmt.Println(err)
return
}
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("abck cost", time.Since(t1).String())
querynk(body)
}
var Debug *bool var Debug *bool
...@@ -115,10 +178,12 @@ func main() { ...@@ -115,10 +178,12 @@ func main() {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
fmt.Println("开始vytest") //fmt.Println("开始vytest")
actVY() //actVY()
fmt.Println("开始u2test") //fmt.Println("开始u2test")
actU2() //actU2()
fmt.Println("开始NKtest")
actnk()
}() }()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment