This repository has been archived by the owner on Nov 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from takayama-lily/1.14
1.14
- Loading branch information
Showing
32 changed files
with
2,249 additions
and
1,887 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/** | ||
* 设备文件和协议 | ||
*/ | ||
"use strict"; | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
@@ -11,7 +14,7 @@ function rand(n = 9) { | |
return parseInt(Math.random() * (max - min) + min); | ||
} | ||
|
||
function getMac() { | ||
function _getMac() { | ||
const o = os.networkInterfaces(); | ||
for (let k in o) { | ||
for (let v of o[k]) { | ||
|
@@ -22,7 +25,7 @@ function getMac() { | |
return `00:50:A${rand(1)}:${rand(1)}D:${rand(1)}B:C${rand(1)}`; | ||
} | ||
|
||
function genIMEI() { | ||
function _genIMEI() { | ||
let imei = Math.random() > 0.5 ? "86" : "35"; | ||
imei += rand(4) + "0" + rand(7); | ||
function calcSP(imei) { | ||
|
@@ -40,7 +43,10 @@ function genIMEI() { | |
return imei + calcSP(imei); | ||
} | ||
|
||
function genDevice(filepath) { | ||
/** | ||
* @param {string} filepath | ||
*/ | ||
function _genDevice(filepath) { | ||
const device = `{ | ||
"--begin--": "修改后可能需要重新验证设备。", | ||
"product": "iarim", | ||
|
@@ -54,9 +60,9 @@ function genDevice(filepath) { | |
"android_id": "BRAND.${rand(6)}.${rand(3)}", | ||
"boot_id": "${uuid()}", | ||
"proc_version": "Linux version 4.19.71-${rand(5)} ([email protected])", | ||
"mac_address": "${getMac()}", | ||
"mac_address": "${_getMac()}", | ||
"ip_address": "10.0.${rand(2)}.${rand(2)}", | ||
"imei": "${genIMEI()}", | ||
"imei": "${_genIMEI()}", | ||
"incremental": "${rand(7)}" | ||
}`; | ||
const dir = path.dirname(filepath); | ||
|
@@ -67,15 +73,15 @@ function genDevice(filepath) { | |
} | ||
|
||
/** | ||
* @param {String} filepath | ||
* @param {string} filepath | ||
* @returns {import("./lib/ref").Device} | ||
*/ | ||
function getDeviceInfo(filepath) { | ||
var d; | ||
try { | ||
d = JSON.parse(fs.readFileSync(filepath, { encoding: "utf-8" })); | ||
} catch { | ||
d = genDevice(filepath); | ||
d = _genDevice(filepath); | ||
} | ||
const device = { | ||
display: d.android_id, | ||
|
@@ -111,6 +117,9 @@ function getDeviceInfo(filepath) { | |
return device; | ||
} | ||
|
||
/** | ||
* @type {{[k: number]: import("./lib/ref").ApkInfo}} | ||
*/ | ||
const apk = { | ||
//android phone | ||
1: { | ||
|
@@ -156,8 +165,7 @@ apk[5] = { ...apk[2] }; | |
apk[5].subid = 537065739; | ||
|
||
/** | ||
* @param {Number} platform | ||
* @returns {import("./lib/ref").ApkInfo} | ||
* @param {number} platform | ||
*/ | ||
function getApkInfo(platform) { | ||
return apk[platform] ? apk[platform] : apk[2]; | ||
|
Oops, something went wrong.