From 9649c6df5095e2dc06fe1f99a981afef0500f7cf Mon Sep 17 00:00:00 2001 From: You Date: Thu, 1 May 2025 21:50:03 +0800 Subject: [PATCH 1/8] fix: update user-agent and platform details for 123pan API --- drivers/123/util.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/123/util.go b/drivers/123/util.go index 7e5a2397..278e3420 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -202,9 +202,13 @@ do: "origin": "https://www.123pan.com", "referer": "https://www.123pan.com/", "authorization": "Bearer " + d.AccessToken, - "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) alist-client", - "platform": "web", - "app-version": "3", + // "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) alist-client", + // "platform": "web", + // "app-version": "3", + "user-agent": "123pan/v2.5.4(Android_14.0.0;Xiaomi)", + "app-version": "77", + "platform": "android", + "x-app-version": "2.5.4", //"user-agent": base.UserAgent, }) if callback != nil { From d82a76873b8cbfd0294c37742e0a3ce97ba2c486 Mon Sep 17 00:00:00 2001 From: You Date: Thu, 1 May 2025 21:52:04 +0800 Subject: [PATCH 2/8] fix: update registry details and standardize quotes in release_docker workflow --- .github/workflows/release_docker.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index 7cd05549..ecc41282 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -3,9 +3,10 @@ name: release_docker on: push: tags: - - 'v*' + - "v*" branches: - main + - feat/123pan pull_request: branches: - main @@ -15,11 +16,11 @@ concurrency: cancel-in-progress: true env: - REGISTRY: 'xhofe/alist' - REGISTRY_USERNAME: 'xhofe' + REGISTRY: "alliot/alist" + REGISTRY_USERNAME: "alliot" REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} - ARTIFACT_NAME: 'binaries_docker_release' - RELEASE_PLATFORMS: 'linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64' + ARTIFACT_NAME: "binaries_docker_release" + RELEASE_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64" IMAGE_PUSH: ${{ github.event_name == 'push' }} IMAGE_IS_PROD: ${{ github.ref_type == 'tag' }} IMAGE_TAGS_BETA: | @@ -39,7 +40,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Cache Musl id: cache-musl @@ -98,7 +99,7 @@ jobs: - uses: actions/download-artifact@v4 with: name: ${{ env.ARTIFACT_NAME }} - path: 'build/' + path: "build/" - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -134,4 +135,4 @@ jobs: build-args: ${{ matrix.build_arg }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ env.RELEASE_PLATFORMS }} \ No newline at end of file + platforms: ${{ env.RELEASE_PLATFORMS }} From 03bf8ba0efe12bea080161ac4a4dc22dad9ef33c Mon Sep 17 00:00:00 2001 From: You Date: Thu, 1 May 2025 22:07:44 +0800 Subject: [PATCH 3/8] fix: update RELEASE_PLATFORMS to remove unsupported architectures --- .github/workflows/release_docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_docker.yml b/.github/workflows/release_docker.yml index ecc41282..23969795 100644 --- a/.github/workflows/release_docker.yml +++ b/.github/workflows/release_docker.yml @@ -20,7 +20,7 @@ env: REGISTRY_USERNAME: "alliot" REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} ARTIFACT_NAME: "binaries_docker_release" - RELEASE_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x,linux/ppc64le,linux/riscv64" + RELEASE_PLATFORMS: "linux/amd64,linux/arm64" IMAGE_PUSH: ${{ github.event_name == 'push' }} IMAGE_IS_PROD: ${{ github.ref_type == 'tag' }} IMAGE_TAGS_BETA: | From 6208648ff498669cfe731f18b65bc9412d21e6ed Mon Sep 17 00:00:00 2001 From: You Date: Thu, 1 May 2025 23:20:47 +0800 Subject: [PATCH 4/8] feat: implement dynamic User-Agent generation and header management for 123pan requests --- drivers/123/util.go | 86 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 73 insertions(+), 13 deletions(-) diff --git a/drivers/123/util.go b/drivers/123/util.go index 278e3420..970a8893 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -194,23 +194,83 @@ func (d *Pan123) login() error { // return &authKey, nil //} +func generateRandomHeaders() map[string]string { + // Define OS and versions + android := map[string]interface{}{ + "os": "Android", + "vers": []string{"13.0.3", "14.0.0", "14.0.5"}, + } + ios := map[string]interface{}{ + "os": "iOS", + "vers": []string{"12.0", "13.4", "14.0", "15.0"}, + } + + // Define device brands + devices := map[string]map[string]interface{}{ + "Apple": ios, + "Xiaomi": android, + "Samsung": android, + "Google": android, + "Oneplus": android, + "Vivo": android, + "Oppo": android, + } + + // Define app versions + appXVersions := []string{ + "2.4.7","2.5.0", "2.5.2","2.5.3", "2.5.4", "2.5.5" + } + appVersions := []string{ + "62", "76", "77", "78" + } + + // Randomly select app version + appXVer := appXVersions[rand.Intn(len(appXVersions))] + appVer := appVersions[findIndex(appXVersions, appXVer)] + + // Randomly select device brand and OS + brands := make([]string, 0, len(devices)) + for brand := range devices { + brands = append(brands, brand) + } + brand := brands[rand.Intn(len(brands))] + device := devices[brand] + + os := device["os"].(string) + versions := device["vers"].([]string) + osVersion := versions[rand.Intn(len(versions))] + + // Generate User-Agent + userAgent := fmt.Sprintf("123pan/v%s (%s_%s;%s)", appXVer, os, osVersion, brand) + + // Return headers + return map[string]string{ + "origin": "https://www.123pan.com", + "referer": "https://www.123pan.com/", + "user-agent": userAgent, + "app-version": appVer, + "platform": strings.ToLower(os), + "x-app-version": appXVer, + } +} + +// Helper function to find index of a string in a slice +func findIndex(slice []string, value string) int { + for i, v := range slice { + if v == value { + return i + } + } + return -1 +} + func (d *Pan123) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) { isRetry := false do: req := base.RestyClient.R() - req.SetHeaders(map[string]string{ - "origin": "https://www.123pan.com", - "referer": "https://www.123pan.com/", - "authorization": "Bearer " + d.AccessToken, - // "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) alist-client", - // "platform": "web", - // "app-version": "3", - "user-agent": "123pan/v2.5.4(Android_14.0.0;Xiaomi)", - "app-version": "77", - "platform": "android", - "x-app-version": "2.5.4", - //"user-agent": base.UserAgent, - }) + headers := generateRandomHeaders() + headers["authorization"] = "Bearer " + d.AccessToken + req.SetHeaders(headers) if callback != nil { callback(req) } From 2d861e61fc785286d8a808f9a93af655fbbef01e Mon Sep 17 00:00:00 2001 From: You Date: Thu, 1 May 2025 23:25:51 +0800 Subject: [PATCH 5/8] fix: standardize formatting of app version lists in generateRandomHeaders function --- drivers/123/util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/123/util.go b/drivers/123/util.go index 970a8893..993df890 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -218,10 +218,10 @@ func generateRandomHeaders() map[string]string { // Define app versions appXVersions := []string{ - "2.4.7","2.5.0", "2.5.2","2.5.3", "2.5.4", "2.5.5" + "2.4.7", "2.5.0", "2.5.2", "2.5.3", "2.5.4", "2.5.5", } appVersions := []string{ - "62", "76", "77", "78" + "62", "76", "77", "78", } // Randomly select app version From 53edc21646b8388fc4a30256c828b5c25c08be86 Mon Sep 17 00:00:00 2001 From: You Date: Fri, 2 May 2025 00:11:57 +0800 Subject: [PATCH 6/8] refactor: enhance generateRandomHeaders function with structured device data and error handling --- drivers/123/util.go | 80 +++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/drivers/123/util.go b/drivers/123/util.go index 993df890..03be351a 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -194,64 +194,58 @@ func (d *Pan123) login() error { // return &authKey, nil //} -func generateRandomHeaders() map[string]string { - // Define OS and versions - android := map[string]interface{}{ - "os": "Android", - "vers": []string{"13.0.3", "14.0.0", "14.0.5"}, - } - ios := map[string]interface{}{ - "os": "iOS", - "vers": []string{"12.0", "13.4", "14.0", "15.0"}, - } +// 初始化随机数种子 +func init() { + rand.Seed(time.Now().UnixNano()) +} - // Define device brands - devices := map[string]map[string]interface{}{ - "Apple": ios, - "Xiaomi": android, - "Samsung": android, - "Google": android, - "Oneplus": android, - "Vivo": android, - "Oppo": android, +// 生成随机HTTP头函数 +func generateRandomHeaders() (map[string]string, error) { + // 定义操作系统和版本 + deviceOS := []struct { + brand string + os string + versions []string + }{ + {"Apple", "iOS", []string{"12.0", "13.4", "14.0", "15.0"}}, + {"Xiaomi", "Android", []string{"13.0.3", "14.0.0", "14.0.5"}}, + {"Samsung", "Android", []string{"13.0.3", "14.0.0", "14.0.5"}}, + {"Google", "Android", []string{"13.0.3", "14.0.0", "14.0.5"}}, + {"Oneplus", "Android", []string{"13.0.3", "14.0.0", "14.0.5"}}, + {"Vivo", "Android", []string{"13.0.3", "14.0.0", "14.0.5"}}, + {"Oppo", "Android", []string{"13.0.3", "14.0.0", "14.0.5"}}, } - // Define app versions - appXVersions := []string{ - "2.4.7", "2.5.0", "2.5.2", "2.5.3", "2.5.4", "2.5.5", - } - appVersions := []string{ - "62", "76", "77", "78", - } + // 定义应用版本 + appXVersions := []string{"2.4.7", "2.5.0", "2.5.2", "2.5.3", "2.5.4", "2.5.5"} + appVersions := []string{"62", "76", "77", "78"} - // Randomly select app version + // 随机选择应用版本 appXVer := appXVersions[rand.Intn(len(appXVersions))] - appVer := appVersions[findIndex(appXVersions, appXVer)] - - // Randomly select device brand and OS - brands := make([]string, 0, len(devices)) - for brand := range devices { - brands = append(brands, brand) + appVerIndex := findIndex(appXVersions, appXVer) + if appVerIndex == -1 || appVerIndex >= len(appVersions) { + return nil, fmt.Errorf("Invalid app version index found") } - brand := brands[rand.Intn(len(brands))] - device := devices[brand] + appVer := appVersions[appVerIndex] - os := device["os"].(string) - versions := device["vers"].([]string) - osVersion := versions[rand.Intn(len(versions))] + // 随机选择设备品牌和操作系统 + selectedDevice := deviceOS[rand.Intn(len(deviceOS))] + osVersion := selectedDevice.versions[rand.Intn(len(selectedDevice.versions))] - // Generate User-Agent - userAgent := fmt.Sprintf("123pan/v%s (%s_%s;%s)", appXVer, os, osVersion, brand) + // 生成 User-Agent 字符串 + userAgent := fmt.Sprintf("123pan/v%s (%s_%s;%s)", appXVer, selectedDevice.os, osVersion, selectedDevice.brand) - // Return headers - return map[string]string{ + // 返回 HTTP 请求头 + headers := map[string]string{ "origin": "https://www.123pan.com", "referer": "https://www.123pan.com/", "user-agent": userAgent, "app-version": appVer, - "platform": strings.ToLower(os), + "platform": strings.ToLower(selectedDevice.os), "x-app-version": appXVer, } + + return headers, nil } // Helper function to find index of a string in a slice From 506639f05d1088b99af965bb755cdb27b4334497 Mon Sep 17 00:00:00 2001 From: You Date: Fri, 2 May 2025 00:23:36 +0800 Subject: [PATCH 7/8] fix: simplify app version selection in generateRandomHeaders and improve error handling --- drivers/123/util.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/123/util.go b/drivers/123/util.go index 03be351a..ae2ec5da 100644 --- a/drivers/123/util.go +++ b/drivers/123/util.go @@ -222,11 +222,7 @@ func generateRandomHeaders() (map[string]string, error) { // 随机选择应用版本 appXVer := appXVersions[rand.Intn(len(appXVersions))] - appVerIndex := findIndex(appXVersions, appXVer) - if appVerIndex == -1 || appVerIndex >= len(appVersions) { - return nil, fmt.Errorf("Invalid app version index found") - } - appVer := appVersions[appVerIndex] + appVer := appVersions[rand.Intn(len(appVersions))] // 随机选择设备品牌和操作系统 selectedDevice := deviceOS[rand.Intn(len(deviceOS))] @@ -248,21 +244,15 @@ func generateRandomHeaders() (map[string]string, error) { return headers, nil } -// Helper function to find index of a string in a slice -func findIndex(slice []string, value string) int { - for i, v := range slice { - if v == value { - return i - } - } - return -1 -} func (d *Pan123) Request(url string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) { isRetry := false do: req := base.RestyClient.R() - headers := generateRandomHeaders() + headers, err := generateRandomHeaders() + if err != nil { + return nil, err + } headers["authorization"] = "Bearer " + d.AccessToken req.SetHeaders(headers) if callback != nil { From 6b3d62eaa0a073b0e69ad883e9e7afa2e0badbb6 Mon Sep 17 00:00:00 2001 From: You Date: Fri, 2 May 2025 00:28:03 +0800 Subject: [PATCH 8/8] fix: reduce supported OS architectures in BuildDockerMultiplatform function --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 2dee8e20..de593374 100644 --- a/build.sh +++ b/build.sh @@ -113,7 +113,7 @@ BuildDockerMultiplatform() { docker_lflags="--extldflags '-static -fpic' $ldflags" export CGO_ENABLED=1 - OS_ARCHES=(linux-amd64 linux-arm64 linux-386 linux-s390x linux-riscv64 linux-ppc64le) + OS_ARCHES=(linux-amd64 linux-arm64) CGO_ARGS=(x86_64-linux-musl-gcc aarch64-linux-musl-gcc i486-linux-musl-gcc s390x-linux-musl-gcc riscv64-linux-musl-gcc powerpc64le-linux-musl-gcc) for i in "${!OS_ARCHES[@]}"; do os_arch=${OS_ARCHES[$i]}