Skip to content

Commit

Permalink
增加 window 和 proxy 的 crud,增加线程锁,避免并发打开窗口时 webSocketDebuggerUrl 占用同一端口
Browse files Browse the repository at this point in the history
  • Loading branch information
niuniuland committed Apr 17, 2024
1 parent 116645d commit 7c8d517
Show file tree
Hide file tree
Showing 16 changed files with 428 additions and 180 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

此软件遵循AGPL协议,因此如果你想对其进行修改发布,请保持开源。

Chromium 源码修改请参考 [chrome-power-chromium](https://github.com/zmzimpl/chrome-power-chromium)

## 免责声明

本代码仅用于技术交流、学习,请勿用于非法、商业用途。本代码不保存任何用户数据,同时也不对用户数据负责,请知悉。
Expand Down Expand Up @@ -39,9 +41,19 @@
## 本地运行/打包

- 安装依赖 `npm i`
- 手动解压代码目录下的 `Chrome-bin.zip`,注意只有一层目录
- 运行调试 `npm run watch`
- 打包部署 `npm run publish`,注意打包时要把开发环境停掉,不然会导致 sqlite3 的包打包不了

## API 文档

[Postman API](https://documenter.getpostman.com/view/25586363/2sA3BkdZ61#intro)

## 同类开源工具

- [VirtualBrowser](https://github.com/Virtual-Browser/VirtualBrowser)
- [toolBoxClient](https://github.com/web3ToolBoxDev/toolBoxClient)

## 打赏

🙌你可以通过向下面的钱包打赏一杯咖啡来支持我
Expand Down
21 changes: 19 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"active-win": "^8.1.1",
"agent-base": "^7.1.0",
"antd": "^5.14.0",
"async-mutex": "^0.5.0",
"axios": "^1.5.1",
"btoa": "^1.2.1",
"cors": "^2.8.5",
Expand Down
14 changes: 10 additions & 4 deletions packages/main/src/db/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {IWindowTemplate} from '../types/window-template';
import {GroupDB} from './group';
import {ProxyDB} from './proxy';
import {randomUniqueProfileId} from '../../../shared/utils/random';
import { randomFingerprint } from '../services/window-service';
import {randomFingerprint} from '../services/window-service';

const all = async () => {
return await db('window')
Expand Down Expand Up @@ -118,7 +118,7 @@ const update = async (id: number, updatedData: DB.Window) => {
}
};

const create = async (windowData: DB.Window, fingerprint: SafeAny) => {
const create = async (windowData: DB.Window, fingerprint?: SafeAny) => {
if (windowData.id && typeof windowData.id === 'string') {
windowData.profile_id = windowData.id;
delete windowData.id;
Expand All @@ -130,8 +130,14 @@ const create = async (windowData: DB.Window, fingerprint: SafeAny) => {
windowData.profile_id = randomUniqueProfileId();
}
}
windowData.ua = fingerprint.ua;
windowData.fingerprint = JSON.stringify(fingerprint);
if (fingerprint) {
windowData.ua = fingerprint.ua;
windowData.fingerprint = JSON.stringify(fingerprint);
} else {
const randFingerprint = randomFingerprint();
windowData.ua = randFingerprint.ua;
windowData.fingerprint = JSON.stringify(randFingerprint);
}
const [id] = await db('window').insert(windowData);
return {
success: true,
Expand Down
Loading

0 comments on commit 7c8d517

Please sign in to comment.