Skip to content

Commit

Permalink
feat: ⚡ 优化随机IP、未登录回复次数显示、小屏历史记录显示、授权弹窗、pwa等
Browse files Browse the repository at this point in the history
  • Loading branch information
adams549659584 committed May 29, 2023
1 parent 681b0ca commit b6266de
Show file tree
Hide file tree
Showing 43 changed files with 1,784 additions and 7,650 deletions.
40 changes: 20 additions & 20 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tasks:
cmds:
- |
GOOS={{.GOOS}} GOARCH={{.GOARCH}} GOARM={{.GOARM}} GOMIPS={{.GOMIPS}} GOAMD64={{.GOAMD64}} \
go build -tags netgo -trimpath -o release/go_proxy_bingai_{{.TASK}} -ldflags \
go build -tags netgo -trimpath -o release/go-proxy-bingai_{{.TASK}} -ldflags \
"-w -s -X 'main.version={{.BUILD_VERSION}}' -X 'main.buildDate={{.BUILD_DATE}}' -X 'main.commitID={{.COMMIT_ID}}'"
linux_386:
cmds:
Expand Down Expand Up @@ -234,27 +234,27 @@ tasks:
cmds:
- task: clean
- task: build_web
- task: linux_386
# - task: linux_386
- task: linux_amd64
- task: linux_amd64_v2
- task: linux_amd64_v3
- task: linux_amd64_v4
- task: linux_armv5
- task: linux_armv6
- task: linux_armv7
# - task: linux_amd64_v2
# - task: linux_amd64_v3
# - task: linux_amd64_v4
# - task: linux_armv5
# - task: linux_armv6
# - task: linux_armv7
- task: linux_armv8
- task: linux_mips_hardfloat
- task: linux_mipsle_softfloat
- task: linux_mipsle_hardfloat
- task: linux_mips64
- task: linux_mips64le
- task: windows_386.exe
- task: windows_amd64.exe
- task: windows_amd64_v2.exe
- task: windows_amd64_v3.exe
- task: windows_amd64_v4.exe
- task: darwin_amd64
- task: darwin_arm64
# - task: linux_mips_hardfloat
# - task: linux_mipsle_softfloat
# - task: linux_mipsle_hardfloat
# - task: linux_mips64
# - task: linux_mips64le
# - task: windows_386.exe
# - task: windows_amd64.exe
# - task: windows_amd64_v2.exe
# - task: windows_amd64_v3.exe
# - task: windows_amd64_v4.exe
# - task: darwin_amd64
# - task: darwin_arm64
release:
cmds:
- task: default
File renamed without changes.
87 changes: 87 additions & 0 deletions cloudflare/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!doctype html>
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<link rel="icon" type="image/svg+xml" href="https://bing.vcanbb.top/web/img/logo.svg" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<link rel="apple-touch-icon" href="https://bing.vcanbb.top/web/favicon.ico">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
<meta name="referrer" content="origin-when-cross-origin" />
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>BingAI - 聊天</title>
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MM5J5X8QQC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag () { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', 'G-MM5J5X8QQC');
</script>
<!-- 百度统计 -->
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?299c614daa53fbcede70f2d22df0a31b";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>

<body>
<div class="relative flex min-h-screen flex-col justify-center overflow-hidden bg-gray-50 py-6 px-4 sm:py-12">
<div class="absolute inset-0 bg-slate-100 bg-center [mask-image:linear-gradient(180deg,white,rgba(255,255,255,0))]">
</div>
<div
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">
<div class="mx-auto max-w-3xl">
<div class="flex justify-center">
<img src="https://bing.vcanbb.top/web/img/logo.svg" class="h-24" alt="BingAI" />
</div>
<div class="mt-6 text-center text-3xl text-gray-600">聊天服务器已部署完成</div>
<div class="divide-y divide-gray-300/50">
<div class="space-y-6 py-8 text-base leading-7 text-gray-600">
<ul class="space-y-4">
<li class="flex items-center">
<svg class="h-6 w-6 flex-none fill-sky-100 stroke-sky-500 stroke-2" stroke-linecap="round"
stroke-linejoin="round">
<circle cx="12" cy="12" r="11" />
<path d="m8 13 2.165 2.165a1 1 0 0 0 1.521-.126L16 9" fill="none" />
</svg>
<p class="ml-4">
在基于 go-proxy-bingai 搭建的站点中
<code class="text-sm font-bold text-sky-500">设置 => 服务选择</code>
添加此站点即可
</p>
</li>
<li class="flex items-center">
<svg class="h-6 w-6 flex-none fill-sky-100 stroke-sky-500 stroke-2" stroke-linecap="round"
stroke-linejoin="round">
<circle cx="12" cy="12" r="11" />
<path d="m8 13 2.165 2.165a1 1 0 0 0 1.521-.126L16 9" fill="none" />
</svg>
<p class="ml-4">
如有疑问,请参考
<a href="https://github.com/adams549659584/go-proxy-bingai/issues/81" target="_blank"
class="text-sky-500 hover:text-sky-600">issues #81</a>
</p>
</li>
</ul>
</div>
<div class="pt-8 text-base font-semibold leading-7">
<p class="text-gray-600 overflow-hidden">开源地址:<a href="https://github.com/adams549659584/go-proxy-bingai"
target="_blank"
class="text-sky-500 hover:text-sky-600">https://github.com/adams549659584/go-proxy-bingai</a></p>
</div>
</div>
</div>
</div>
</div>
</body>

</html>
15 changes: 10 additions & 5 deletions cloudflare/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ const getRandomIP = () => {
return randomIP;
};

const home = async () => {
const res = await fetch('https://raw.githubusercontent.com/adams549659584/go-proxy-bingai/master/cloudflare/index.html');
const newRes = new Response(res.body, res);
newRes.headers.set('content-type', 'text/html; charset=utf-8');
return newRes;
};

export default {
/**
* fetch
Expand All @@ -80,6 +87,9 @@ export default {
*/
async fetch(request, env, ctx) {
const currentUrl = new URL(request.url);
if (currentUrl.pathname === '/') {
return home();
}
const targetUrl = new URL(SYDNEY_ORIGIN + currentUrl.pathname + currentUrl.search);

const newHeaders = new Headers();
Expand Down Expand Up @@ -115,10 +125,5 @@ export default {
// console.log('request url : ', newReq.url);
const res = await fetch(newReq);
return res;
// const newRes = new Response(res.body, res);
// newRes.headers.set('access-control-allow-origin', '*');
// newRes.headers.set('access-control-allow-methods', '*');
// newRes.headers.set('access-control-allow-headers', '*');
// return newRes;
},
};
46 changes: 46 additions & 0 deletions common/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package common

import (
"os"
"strings"
)

var (
// is debug
IS_DEBUG_MODE bool
// socks
SOCKS_URL string
SOCKS_USER string
SOCKS_PWD string
// user token
USER_TOKEN_ENV_NAME_PREFIX = "Go_Proxy_BingAI_USER_TOKEN"
USER_TOKEN_LIST []string
// 访问权限密钥,可选
AUTH_KEY string
AUTH_KEY_COOKIE_NAME = "BingAI_Auth_Key"
)

func init() {
initEnv()
initUserToken()
}

func initEnv() {
// is debug
IS_DEBUG_MODE = os.Getenv("Go_Proxy_BingAI_Debug") != ""
// socks
SOCKS_URL = os.Getenv("Go_Proxy_BingAI_SOCKS_URL")
SOCKS_USER = os.Getenv("Go_Proxy_BingAI_SOCKS_USER")
SOCKS_PWD = os.Getenv("Go_Proxy_BingAI_SOCKS_PWD")
// auth
AUTH_KEY = os.Getenv("Go_Proxy_BingAI_AUTH_KEY")
}

func initUserToken() {
for _, env := range os.Environ() {
if strings.HasPrefix(env, USER_TOKEN_ENV_NAME_PREFIX) {
parts := strings.SplitN(env, "=", 2)
USER_TOKEN_LIST = append(USER_TOKEN_LIST, parts[1])
}
}
}
Loading

1 comment on commit b6266de

@vercel
Copy link

@vercel vercel bot commented on b6266de May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.