This commit is contained in:
parent
1b2f1e6374
commit
a51faba9af
File diff suppressed because it is too large
Load Diff
|
@ -15,6 +15,7 @@
|
|||
"@waiting/base64": "^4.2.9",
|
||||
"axios": "^1.2.1",
|
||||
"js-base64": "^3.7.5",
|
||||
"link-chang": "file:",
|
||||
"quasar": "^2.6.0",
|
||||
"vue": "^3.0.0",
|
||||
"vue-router": "^4.0.0",
|
||||
|
@ -22,6 +23,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@quasar/app-vite": "^1.0.0",
|
||||
"@quasar/quasar-app-extension-testing": "^2.2.0",
|
||||
"@types/node": "^12.20.21",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/parser": "^5.10.0",
|
||||
|
@ -33,7 +35,7 @@
|
|||
"typescript": "^4.5.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18 || ^16 || ^14.19",
|
||||
"node": "^22 || ^18 || ^16 || ^14.19",
|
||||
"npm": ">= 6.13.4",
|
||||
"yarn": ">= 1.21.1"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
import { decode, encode } from 'js-base64'
|
||||
import { getdata } from 'src/api/api';
|
||||
import { vless, VlessLink, vmess } from 'src/components/models';
|
||||
|
||||
const is_ip = (ip: string) => {
|
||||
const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
|
||||
return reg.test(ip);
|
||||
}
|
||||
/**
|
||||
* 创建直连vmess
|
||||
* @param ip 服务器IP地址
|
||||
* @returns vmess链接
|
||||
*/
|
||||
async function CreatVmessDirect(ip: string): Promise<string> {
|
||||
let tmp = ''
|
||||
const api = new getdata;
|
||||
const def_link = 'ew0KICAidiI6ICIyIiwNCiAgInBzIjogIjAiLA0KICAiYWRkIjogIjE4NS4yMTguNi4xMDgiLA0KICAicG9ydCI6ICI5MDAwIiwNCiAgImlkIjogIjJlZTU3ODA2LWY2ZTQtNDgyYS1lZjA4LTczNjBjMDRjZDNlNSIsDQogICJhaWQiOiAiMCIsDQogICJzY3kiOiAiYXV0byIsDQogICJuZXQiOiAid3MiLA0KICAidHlwZSI6ICJub25lIiwNCiAgImhvc3QiOiAiIiwNCiAgInBhdGgiOiAiLyIsDQogICJ0bHMiOiAiIiwNCiAgInNuaSI6ICIiLA0KICAiYWxwbiI6ICIiDQp9'
|
||||
const obj = JSON.parse(decode(def_link))
|
||||
const array = ip.split(/[\s\n]/)
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
if (!is_ip(array[index])) {
|
||||
return ''
|
||||
}
|
||||
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
const name = await api.get_country(array[index])
|
||||
obj.ps = name + array[index]
|
||||
obj.add = array[index]
|
||||
tmp += 'vmess://' + encode(JSON.stringify(obj)) + '\n'
|
||||
}
|
||||
|
||||
}
|
||||
return tmp
|
||||
}
|
||||
|
||||
function ChangVmessServer() {
|
||||
return 0
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param type 生成链接的类型 vmess |vless
|
||||
*/
|
||||
function CreateLink(type: string, linkinfo: vmess | vless) {
|
||||
const tmp = ''
|
||||
switch (type) {
|
||||
case 'vless':
|
||||
linkinfo.add
|
||||
break;
|
||||
case 'vmess':
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return tmp
|
||||
}
|
||||
|
||||
// async function CreatVmessDirect(ip: string): Promise<string> {
|
||||
|
||||
// }
|
||||
/**
|
||||
* 解析vless
|
||||
* @param link
|
||||
* @returns
|
||||
*/
|
||||
function parseVlessLink(link: string): VlessLink | null {
|
||||
const regex = /^vless:\/\/([a-f0-9-]+)@([^:]+):(\d+)(\?.*)?(#.*)?$/i;
|
||||
const match = link.match(regex);
|
||||
|
||||
if (!match) {
|
||||
console.error('Invalid VLESS link format.');
|
||||
return null;
|
||||
}
|
||||
|
||||
const uuid = match[1];
|
||||
const host = match[2];
|
||||
const port = parseInt(match[3], 10);
|
||||
const params = parseParams(match[4]);
|
||||
const name = match[5] ? match[5].slice(1) : undefined; // 去掉 # 符号
|
||||
|
||||
return {
|
||||
uuid,
|
||||
host,
|
||||
port,
|
||||
params,
|
||||
name,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 解析vless携带的其他参数
|
||||
* @param paramString
|
||||
* @returns
|
||||
*/
|
||||
function parseParams(paramString: string | undefined): Record<string, string> {
|
||||
if (!paramString) return {};
|
||||
|
||||
const params: Record<string, string> = {};
|
||||
const query = paramString.slice(1); // Remove the "?" at the start
|
||||
const pairs = query.split('&');
|
||||
|
||||
pairs.forEach((pair) => {
|
||||
const [key, value] = pair.split('=');
|
||||
if (key && value) {
|
||||
params[key] = decodeURIComponent(value);
|
||||
}
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
/**
|
||||
* 创建vless链接
|
||||
* @param param0
|
||||
* @returns
|
||||
*/
|
||||
function createVlessLink({ uuid, host, port, params, name }: VlessLink): string {
|
||||
// 基本的 VLESS 链接格式
|
||||
let link = `vless://${uuid}@${host}:${port}`;
|
||||
|
||||
// 如果有查询参数,则拼接它们
|
||||
if (params && Object.keys(params).length > 0) {
|
||||
const queryString = new URLSearchParams(params).toString();
|
||||
link += `?${queryString}`;
|
||||
}
|
||||
|
||||
// 如果有名称字段,将名称放在 # 后面
|
||||
if (name) {
|
||||
link += `#${name}`;
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
export { CreatVmessDirect, ChangVmessServer, CreateLink, parseVlessLink }
|
|
@ -1,13 +1,20 @@
|
|||
import { api } from 'src/boot/axios';
|
||||
class getdata {
|
||||
async get_server() {
|
||||
return await api.get('https://api.shagain.club/api.php?type=list');
|
||||
return await api.get('https://api.giaogiao.uk/api.php?type=list');
|
||||
}
|
||||
async text_server(url: string) {
|
||||
return await api.post('https://api.shagain.club/textserver', { url });
|
||||
return await api.post(
|
||||
'https://service-7hslob28-1258902677.nj.apigw.tencentcs.com/release/',
|
||||
{ url }
|
||||
);
|
||||
}
|
||||
async get_country(ip: string) {
|
||||
return await api.post('https://api.shagain.club/api.php?type=searchip', { ip });
|
||||
let res = await api.post('https://api.giaogiao.uk/api.php?type=searchip', {
|
||||
ip,
|
||||
});
|
||||
res = res.data.country
|
||||
return res
|
||||
}
|
||||
}
|
||||
export { getdata };
|
||||
|
|
|
@ -113,6 +113,31 @@ export default defineComponent({
|
|||
})
|
||||
})
|
||||
}
|
||||
const getColorByBaiFenBi = (bili: number) => {
|
||||
//var 百分之一 = (单色值范围) / 50; 单颜色的变化范围只在50%之内
|
||||
let one = (255 + 255) / 100;
|
||||
let r = 0;
|
||||
let g = 0;
|
||||
let b = 0;
|
||||
|
||||
if (bili < 50) {
|
||||
// 比例小于50的时候红色是越来越多的,直到红色为255时(红+绿)变为黄色.
|
||||
r = one * bili;
|
||||
g = 255;
|
||||
}
|
||||
if (bili >= 50) {
|
||||
// 比例大于50的时候绿色是越来越少的,直到0 变为纯红
|
||||
g = 255 - ((bili - 50) * one);
|
||||
r = 255;
|
||||
}
|
||||
r = Math.round(r);// 取整
|
||||
g = Math.round(g);// 取整
|
||||
b = Math.round(b);// 取整
|
||||
|
||||
return 'rgb(' + r + ',' + g + ',' + b + ')';
|
||||
|
||||
}
|
||||
|
||||
return { props, outtext, copy, online, time, signal_style };
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,6 +6,9 @@ export interface Todo {
|
|||
export interface Meta {
|
||||
totalCount: number;
|
||||
}
|
||||
/**
|
||||
* 服务器结构体
|
||||
*/
|
||||
export interface server {
|
||||
host: string;
|
||||
id: number;
|
||||
|
@ -14,7 +17,9 @@ export interface server {
|
|||
port: number;
|
||||
tips: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* vmess结构体
|
||||
*/
|
||||
export interface vmess {
|
||||
v: string;
|
||||
ps: string;
|
||||
|
@ -31,3 +36,32 @@ export interface vmess {
|
|||
sni: string;
|
||||
alpn: string
|
||||
}
|
||||
/**
|
||||
* vless结构体
|
||||
*/
|
||||
export interface vless {
|
||||
add: string;
|
||||
port: number;
|
||||
id: string;
|
||||
encryption: string;
|
||||
/**传输协议 */
|
||||
net: string;
|
||||
/**伪装类型 */
|
||||
type: string;
|
||||
/**地址 */
|
||||
host: string;
|
||||
/**路径 */
|
||||
path: string;
|
||||
/**tls */
|
||||
tls: string;
|
||||
/**sni */
|
||||
sni: string;
|
||||
name: string
|
||||
}
|
||||
export interface VlessLink {
|
||||
uuid: string;
|
||||
host: string;
|
||||
port: number;
|
||||
params?: Record<string, string>;
|
||||
name?: string; // 允许传入名称
|
||||
}
|
||||
|
|
|
@ -2,9 +2,13 @@ import { MutationTree } from 'vuex';
|
|||
import { ExampleStateInterface } from './state';
|
||||
|
||||
const mutation: MutationTree<ExampleStateInterface> = {
|
||||
someMutation (/* state: ExampleStateInterface */) {
|
||||
someMutation(/* state: ExampleStateInterface */) {
|
||||
// your code
|
||||
}
|
||||
},
|
||||
//改动url
|
||||
set_text_server_url(state, url) {
|
||||
state.text_server_url = url;
|
||||
},
|
||||
};
|
||||
|
||||
export default mutation;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
export interface ExampleStateInterface {
|
||||
prop: boolean;
|
||||
text_server_url: string;
|
||||
}
|
||||
|
||||
function state(): ExampleStateInterface {
|
||||
return {
|
||||
prop: false
|
||||
}
|
||||
prop: false,
|
||||
text_server_url: '',
|
||||
};
|
||||
}
|
||||
|
||||
export default state;
|
||||
|
|
Loading…
Reference in New Issue