0000
This commit is contained in:
parent
07dbaea8ec
commit
d3104df626
@ -49,7 +49,7 @@ if command -v node &> /dev/null; then
|
|||||||
|
|
||||||
# Download the Node.js proxy script
|
# Download the Node.js proxy script
|
||||||
echo "Downloading index.js..."
|
echo "Downloading index.js..."
|
||||||
if ! curl -o "index.js" "https://x-mo.cn:9009/XiaoMo/alist-proxy/raw/branch/master/index.js"; then
|
if ! curl -o "index.js" "https://git.x-php.com/XiaoMo/alist-proxy/raw/branch/master/index.js"; then
|
||||||
echo "Failed to download index.js. Please check your internet connection and try again."
|
echo "Failed to download index.js. Please check your internet connection and try again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -97,7 +97,7 @@ else
|
|||||||
# Check if index.php file exists, if not, download it
|
# Check if index.php file exists, if not, download it
|
||||||
if [ ! -f "index.php" ]; then
|
if [ ! -f "index.php" ]; then
|
||||||
echo "Downloading index.php..."
|
echo "Downloading index.php..."
|
||||||
if ! curl -o "index.php" "https://x-mo.cn:9009/XiaoMo/alist-proxy/raw/branch/master/index.php"; then
|
if ! curl -o "index.php" "https://git.x-php.com/XiaoMo/alist-proxy/raw/branch/master/index.php"; then
|
||||||
echo "Failed to download index.php. Please check your internet connection and try again."
|
echo "Failed to download index.php. Please check your internet connection and try again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
12
source.js
12
source.js
@ -31,7 +31,7 @@ const viewsInfo = {
|
|||||||
|
|
||||||
// 默认端口号和 API 地址
|
// 默认端口号和 API 地址
|
||||||
let port = 9001;
|
let port = 9001;
|
||||||
let apiEndpoint = 'https://oss.x-php.com/get/';
|
let apiEndpoint = 'http://47.107.93.139/get';
|
||||||
|
|
||||||
// 解析命令行参数
|
// 解析命令行参数
|
||||||
args.forEach(arg => {
|
args.forEach(arg => {
|
||||||
@ -110,7 +110,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
// 当没有 token 或 undefined
|
// 当没有 token 或 undefined
|
||||||
if (token === '' || typeof token === 'undefined') {
|
if (token === '' || typeof token === 'undefined') {
|
||||||
token = reqPath;
|
token = reqPath;
|
||||||
reqPath = 'go';
|
reqPath = 'app';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查第一个路径只能是 avatar,endpoint,go,bbs,www
|
// 检查第一个路径只能是 avatar,endpoint,go,bbs,www
|
||||||
@ -247,13 +247,15 @@ const isCacheValid = (cacheMetaFile, cacheContentFile) => {
|
|||||||
// 从 API 获取数据
|
// 从 API 获取数据
|
||||||
const fetchApiData = (reqPath, token, sign) => {
|
const fetchApiData = (reqPath, token, sign) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 将请求路径和参数进行编码
|
|
||||||
const queryParams = querystring.stringify({
|
const queryParams = querystring.stringify({
|
||||||
type: reqPath,
|
type: reqPath,
|
||||||
sign: sign
|
sign: sign
|
||||||
});
|
});
|
||||||
const apiUrl = `${apiEndpoint}?${queryParams}`;
|
const apiUrl = `${apiEndpoint}?${queryParams}`;
|
||||||
const apiReq = https.request(apiUrl, {
|
const parsedUrl = url.parse(apiUrl);
|
||||||
|
const protocol = parsedUrl.protocol === 'https:' ? https : http;
|
||||||
|
|
||||||
|
const apiReq = protocol.request(apiUrl, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json; charset=utf-8',
|
'Accept': 'application/json; charset=utf-8',
|
||||||
@ -420,4 +422,4 @@ process.on('SIGINT', () => {
|
|||||||
console.error('Forcing shutdown...');
|
console.error('Forcing shutdown...');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}, 10000);
|
}, 10000);
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user