Spaces:
jiome
/
Sleeping

jiome commited on
Commit
e8662ed
·
verified ·
1 Parent(s): b284aa2

Rename indexurl.js to index.js

Browse files
Files changed (2) hide show
  1. index.js +155 -0
  2. indexurl.js +0 -64
index.js ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import express from "express";
2
+ import bodyParser from "body-parser";
3
+
4
+ const app = express();
5
+ const port = 7860;
6
+
7
+ app.use(bodyParser.json());
8
+
9
+ const isipok = async (ip) => {
10
+ const ret = await fetch("https://copilot.microsoft.com/", {
11
+ headers: {
12
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
13
+ "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
14
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0",
15
+ "X-forwarded-for": ip
16
+ }
17
+ });
18
+ if (!ret.ok) {
19
+ return { ip, status: false };
20
+ }
21
+ const txt = await ret.text();
22
+ if (txt.indexOf("studiostaticassetsprod.azureedge.net/bundle-cmc/assets/bundle.js") >= 0) {
23
+ return { ip, status: false, reason: "nononononon" };
24
+ }
25
+ if (txt.indexOf('<div class="title" role="heading" aria-level="1">登录以体验 Microsoft Copilot</div>') >= 0) {
26
+ return { ip, status: false, reason: "ddddddddddd" };
27
+ }
28
+
29
+ const rt = /Region:"(.*?)"/.exec(txt);
30
+ if (!rt) {
31
+ return { ip, status: false };
32
+ }
33
+ const rg = rt[1];
34
+ if (!rg) {
35
+ return { ip, status: false };
36
+ }
37
+ return { ip, status: true, region: rg };
38
+ }
39
+
40
+ const testAll = async (startIP, endIP) => {
41
+ const results = [];
42
+ const [startI, startI0, startI1, startI2] = startIP.split('.').map(Number);
43
+ const [endI, endI0, endI1, endI2] = endIP.split('.').map(Number);
44
+
45
+ let i = startI, i0 = startI0, i1 = startI1, i2 = startI2;
46
+
47
+ const testNext = async () => {
48
+ i2++;
49
+ if (i2 > 255) {
50
+ i2 = 0;
51
+ i1++;
52
+ }
53
+ if (i1 > 255) {
54
+ i1 = 0;
55
+ i0++;
56
+ }
57
+ if (i0 > 255) {
58
+ i0 = 0;
59
+ i++;
60
+ }
61
+ if (i > endI || (i === endI && i0 > endI0) || (i === endI && i0 === endI0 && i1 > endI1) || (i === endI && i0 === endI0 && i1 === endI1 && i2 > endI2)) {
62
+ return false;
63
+ }
64
+ const XForwardedForIP = `${i}.${i0}.${i1}.${i2}`;
65
+ try {
66
+ const result = await isipok(XForwardedForIP);
67
+ if (result.status) {
68
+ results.push(result);
69
+ }
70
+ } catch (error) {
71
+ console.error(error);
72
+ }
73
+ return true;
74
+ }
75
+
76
+ let count = 0;
77
+ let stop = false;
78
+ while (true) {
79
+ while (count >= 16) {
80
+ await new Promise((t) => { setTimeout(t, 100) });
81
+ }
82
+ count++;
83
+ testNext().then((rt) => {
84
+ count--;
85
+ if (!rt) {
86
+ stop = true;
87
+ }
88
+ });
89
+ if (stop) {
90
+ break;
91
+ }
92
+ }
93
+ return results;
94
+ }
95
+
96
+ app.post("/test", async (req, res) => {
97
+ const { startIP, endIP } = req.body;
98
+ const results = await testAll(startIP, endIP);
99
+ res.json(results);
100
+ });
101
+
102
+ app.get("/", (req, res) => {
103
+ res.send(`
104
+ <!DOCTYPE html>
105
+ <html lang="zh-CN">
106
+ <head>
107
+ <meta charset="UTF-8">
108
+ <title>IP Range Checker</title>
109
+ </head>
110
+ <body>
111
+ <h1>IP Range Checker</h1>
112
+ <form id="ipForm">
113
+ <label for="startIP">开始地址:</label>
114
+ <input type="text" id="startIP" name="startIP" required>
115
+ <br>
116
+ <label for="endIP">结束地址:</label>
117
+ <input type="text" id="endIP" name="endIP" required>
118
+ <br>
119
+ <button type="submit">检查</button>
120
+ </form>
121
+ <h2>结果:</h2>
122
+ <textarea id="results" rows="10" cols="50"></textarea>
123
+ <br>
124
+ <button id="copyButton">复制</button>
125
+
126
+ <script>
127
+ document.getElementById('ipForm').addEventListener('submit', async (event) => {
128
+ event.preventDefault();
129
+ const startIP = document.getElementById('startIP').value;
130
+ const endIP = document.getElementById('endIP').value;
131
+ const response = await fetch('/test', {
132
+ method: 'POST',
133
+ headers: {
134
+ 'Content-Type': 'application/json'
135
+ },
136
+ body: JSON.stringify({ startIP, endIP })
137
+ });
138
+ const results = await response.json();
139
+ document.getElementById('results').value = JSON.stringify(results, null, 2);
140
+ });
141
+
142
+ document.getElementById('copyButton').addEventListener('click', () => {
143
+ const results = document.getElementById('results');
144
+ results.select();
145
+ document.execCommand('copy');
146
+ });
147
+ </script>
148
+ </body>
149
+ </html>
150
+ `);
151
+ });
152
+
153
+ app.listen(port, () => {
154
+ console.log(`Server is running at http://localhost:${port}`);
155
+ });
indexurl.js DELETED
@@ -1,64 +0,0 @@
1
- const express = require('express');
2
- const fetch = require('node-fetch');
3
- const FormData = require('form-data');
4
- const sharp = require('sharp');
5
-
6
- const app = express();
7
-
8
- app.get('/resize', async (req, res) => {
9
- const imageUrl = req.query.q;
10
-
11
- if (!imageUrl) {
12
- console.error('没有提供图像 URL');
13
- return res.status(400).send('没有提供图像 URL');
14
- }
15
-
16
- try {
17
- const response = await fetch(imageUrl);
18
- if (!response.ok) {
19
- throw new Error(`获取图像失败: ${response.statusText}`);
20
- }
21
- const imageBuffer = await response.buffer();
22
- console.log('原始图像大小:', imageBuffer.byteLength);
23
-
24
- // 使用 sharp 库来调整图像大小
25
- const resizedImageBuffer = await sharp(imageBuffer).resize(100).toBuffer();
26
- console.log('压缩后的图像大小:', resizedImageBuffer.byteLength);
27
-
28
- // 创建一个 FormData 对象并添加压缩后的图像
29
- const formData = new FormData();
30
- formData.append('file', resizedImageBuffer, { filename: 'compressed.jpg', contentType: 'image/jpeg' });
31
-
32
- // 使用新的 API 地址和方法上传文件
33
- const uploadResponse = await fetch('https://ours.pages.dev/upload', {
34
- method: 'POST',
35
- body: formData
36
- });
37
-
38
- if (!uploadResponse.ok) {
39
- throw new Error(`上传图像失败: ${uploadResponse.statusText}`);
40
- }
41
-
42
- const uploadResult = await uploadResponse.text();
43
- console.log('上传结果:', uploadResult);
44
-
45
- // Parse the JSON response and construct the full URL
46
- const uploadResultJson = JSON.parse(uploadResult);
47
- const fullUrl = `https://ours.pages.dev${uploadResultJson[0].src}`;
48
-
49
- res.setHeader('Content-Type', 'text/plain');
50
- res.setHeader('Access-Control-Allow-Origin', '*');
51
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
52
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
53
- res.setHeader('Access-Control-Max-Age', '86400');
54
- res.send(fullUrl);
55
- } catch (error) {
56
- console.error('压缩图像时出错:', error);
57
- res.status(500).send('压缩图像时出错');
58
- }
59
- });
60
-
61
- const PORT = process.env.PORT || 7860;
62
- app.listen(PORT, () => {
63
- console.log(`Server is running on port ${PORT}`);
64
- });