Skip to content

Commit b6266de

Browse files
feat: ⚡ 优化随机IP、未登录回复次数显示、小屏历史记录显示、授权弹窗、pwa等
1 parent 681b0ca commit b6266de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1784
-7650
lines changed

Taskfile.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tasks:
4444
cmds:
4545
- |
4646
GOOS={{.GOOS}} GOARCH={{.GOARCH}} GOARM={{.GOARM}} GOMIPS={{.GOMIPS}} GOAMD64={{.GOAMD64}} \
47-
go build -tags netgo -trimpath -o release/go_proxy_bingai_{{.TASK}} -ldflags \
47+
go build -tags netgo -trimpath -o release/go-proxy-bingai_{{.TASK}} -ldflags \
4848
"-w -s -X 'main.version={{.BUILD_VERSION}}' -X 'main.buildDate={{.BUILD_DATE}}' -X 'main.commitID={{.COMMIT_ID}}'"
4949
linux_386:
5050
cmds:
@@ -234,27 +234,27 @@ tasks:
234234
cmds:
235235
- task: clean
236236
- task: build_web
237-
- task: linux_386
237+
# - task: linux_386
238238
- task: linux_amd64
239-
- task: linux_amd64_v2
240-
- task: linux_amd64_v3
241-
- task: linux_amd64_v4
242-
- task: linux_armv5
243-
- task: linux_armv6
244-
- task: linux_armv7
239+
# - task: linux_amd64_v2
240+
# - task: linux_amd64_v3
241+
# - task: linux_amd64_v4
242+
# - task: linux_armv5
243+
# - task: linux_armv6
244+
# - task: linux_armv7
245245
- task: linux_armv8
246-
- task: linux_mips_hardfloat
247-
- task: linux_mipsle_softfloat
248-
- task: linux_mipsle_hardfloat
249-
- task: linux_mips64
250-
- task: linux_mips64le
251-
- task: windows_386.exe
252-
- task: windows_amd64.exe
253-
- task: windows_amd64_v2.exe
254-
- task: windows_amd64_v3.exe
255-
- task: windows_amd64_v4.exe
256-
- task: darwin_amd64
257-
- task: darwin_arm64
246+
# - task: linux_mips_hardfloat
247+
# - task: linux_mipsle_softfloat
248+
# - task: linux_mipsle_hardfloat
249+
# - task: linux_mips64
250+
# - task: linux_mips64le
251+
# - task: windows_386.exe
252+
# - task: windows_amd64.exe
253+
# - task: windows_amd64_v2.exe
254+
# - task: windows_amd64_v3.exe
255+
# - task: windows_amd64_v4.exe
256+
# - task: darwin_amd64
257+
# - task: darwin_arm64
258258
release:
259259
cmds:
260260
- task: default
File renamed without changes.

cloudflare/index.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
6+
<link rel="icon" type="image/svg+xml" href="https://bing.vcanbb.top/web/img/logo.svg" />
7+
<meta content="yes" name="apple-mobile-web-app-capable" />
8+
<link rel="apple-touch-icon" href="https://bing.vcanbb.top/web/favicon.ico">
9+
<meta name="viewport"
10+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
11+
<meta name="referrer" content="origin-when-cross-origin" />
12+
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
13+
<title>BingAI - 聊天</title>
14+
<script src="https://cdn.tailwindcss.com"></script>
15+
<!-- Google tag (gtag.js) -->
16+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MM5J5X8QQC"></script>
17+
<script>
18+
window.dataLayer = window.dataLayer || [];
19+
function gtag () { dataLayer.push(arguments); }
20+
gtag('js', new Date());
21+
22+
gtag('config', 'G-MM5J5X8QQC');
23+
</script>
24+
<!-- 百度统计 -->
25+
<script>
26+
var _hmt = _hmt || [];
27+
(function () {
28+
var hm = document.createElement("script");
29+
hm.src = "https://hm.baidu.com/hm.js?299c614daa53fbcede70f2d22df0a31b";
30+
var s = document.getElementsByTagName("script")[0];
31+
s.parentNode.insertBefore(hm, s);
32+
})();
33+
</script>
34+
</head>
35+
36+
<body>
37+
<div class="relative flex min-h-screen flex-col justify-center overflow-hidden bg-gray-50 py-6 px-4 sm:py-12">
38+
<div class="absolute inset-0 bg-slate-100 bg-center [mask-image:linear-gradient(180deg,white,rgba(255,255,255,0))]">
39+
</div>
40+
<div
41+
class="relative bg-white px-6 pb-8 pt-10 shadow-xl ring-1 ring-gray-900/5 sm:mx-auto sm:max-w-lg sm:rounded-lg sm:px-10 lg:max-w-3xl">
42+
<div class="mx-auto max-w-3xl">
43+
<div class="flex justify-center">
44+
<img src="https://bing.vcanbb.top/web/img/logo.svg" class="h-24" alt="BingAI" />
45+
</div>
46+
<div class="mt-6 text-center text-3xl text-gray-600">聊天服务器已部署完成</div>
47+
<div class="divide-y divide-gray-300/50">
48+
<div class="space-y-6 py-8 text-base leading-7 text-gray-600">
49+
<ul class="space-y-4">
50+
<li class="flex items-center">
51+
<svg class="h-6 w-6 flex-none fill-sky-100 stroke-sky-500 stroke-2" stroke-linecap="round"
52+
stroke-linejoin="round">
53+
<circle cx="12" cy="12" r="11" />
54+
<path d="m8 13 2.165 2.165a1 1 0 0 0 1.521-.126L16 9" fill="none" />
55+
</svg>
56+
<p class="ml-4">
57+
在基于 go-proxy-bingai 搭建的站点中
58+
<code class="text-sm font-bold text-sky-500">设置 => 服务选择</code>
59+
添加此站点即可
60+
</p>
61+
</li>
62+
<li class="flex items-center">
63+
<svg class="h-6 w-6 flex-none fill-sky-100 stroke-sky-500 stroke-2" stroke-linecap="round"
64+
stroke-linejoin="round">
65+
<circle cx="12" cy="12" r="11" />
66+
<path d="m8 13 2.165 2.165a1 1 0 0 0 1.521-.126L16 9" fill="none" />
67+
</svg>
68+
<p class="ml-4">
69+
如有疑问,请参考
70+
<a href="https://github.com/adams549659584/go-proxy-bingai/issues/81" target="_blank"
71+
class="text-sky-500 hover:text-sky-600">issues #81</a>
72+
</p>
73+
</li>
74+
</ul>
75+
</div>
76+
<div class="pt-8 text-base font-semibold leading-7">
77+
<p class="text-gray-600 overflow-hidden">开源地址:<a href="https://github.com/adams549659584/go-proxy-bingai"
78+
target="_blank"
79+
class="text-sky-500 hover:text-sky-600">https://github.com/adams549659584/go-proxy-bingai</a></p>
80+
</div>
81+
</div>
82+
</div>
83+
</div>
84+
</div>
85+
</body>
86+
87+
</html>

cloudflare/worker.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ const getRandomIP = () => {
7070
return randomIP;
7171
};
7272

73+
const home = async () => {
74+
const res = await fetch('https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/cloudflare/index.html');
75+
const newRes = new Response(res.body, res);
76+
newRes.headers.set('content-type', 'text/html; charset=utf-8');
77+
return newRes;
78+
};
79+
7380
export default {
7481
/**
7582
* fetch
@@ -80,6 +87,9 @@ export default {
8087
*/
8188
async fetch(request, env, ctx) {
8289
const currentUrl = new URL(request.url);
90+
if (currentUrl.pathname === '/') {
91+
return home();
92+
}
8393
const targetUrl = new URL(SYDNEY_ORIGIN + currentUrl.pathname + currentUrl.search);
8494

8595
const newHeaders = new Headers();
@@ -115,10 +125,5 @@ export default {
115125
// console.log('request url : ', newReq.url);
116126
const res = await fetch(newReq);
117127
return res;
118-
// const newRes = new Response(res.body, res);
119-
// newRes.headers.set('access-control-allow-origin', '*');
120-
// newRes.headers.set('access-control-allow-methods', '*');
121-
// newRes.headers.set('access-control-allow-headers', '*');
122-
// return newRes;
123128
},
124129
};

common/env.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package common
2+
3+
import (
4+
"os"
5+
"strings"
6+
)
7+
8+
var (
9+
// is debug
10+
IS_DEBUG_MODE bool
11+
// socks
12+
SOCKS_URL string
13+
SOCKS_USER string
14+
SOCKS_PWD string
15+
// user token
16+
USER_TOKEN_ENV_NAME_PREFIX = "Go_Proxy_BingAI_USER_TOKEN"
17+
USER_TOKEN_LIST []string
18+
// 访问权限密钥,可选
19+
AUTH_KEY string
20+
AUTH_KEY_COOKIE_NAME = "BingAI_Auth_Key"
21+
)
22+
23+
func init() {
24+
initEnv()
25+
initUserToken()
26+
}
27+
28+
func initEnv() {
29+
// is debug
30+
IS_DEBUG_MODE = os.Getenv("Go_Proxy_BingAI_Debug") != ""
31+
// socks
32+
SOCKS_URL = os.Getenv("Go_Proxy_BingAI_SOCKS_URL")
33+
SOCKS_USER = os.Getenv("Go_Proxy_BingAI_SOCKS_USER")
34+
SOCKS_PWD = os.Getenv("Go_Proxy_BingAI_SOCKS_PWD")
35+
// auth
36+
AUTH_KEY = os.Getenv("Go_Proxy_BingAI_AUTH_KEY")
37+
}
38+
39+
func initUserToken() {
40+
for _, env := range os.Environ() {
41+
if strings.HasPrefix(env, USER_TOKEN_ENV_NAME_PREFIX) {
42+
parts := strings.SplitN(env, "=", 2)
43+
USER_TOKEN_LIST = append(USER_TOKEN_LIST, parts[1])
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)