Skip to content

Commit

Permalink
[Fix] 😜 Suprise mad Fxxk
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-zklcdc committed Feb 17, 2024
1 parent 9973b5b commit d48d246
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 30 deletions.
16 changes: 16 additions & 0 deletions api/middleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package api

import (
"adams549659584/go-proxy-bingai/common"
"net/http"
)

func Middleware(next http.HandlerFunc) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if common.SB {
w.WriteHeader(http.StatusUnavailableForLegalReasons)
return
}
next(w, r)
})
}
4 changes: 4 additions & 0 deletions common/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ var (
User_Agent string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"
User_Agent_Mobile string = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.7 Mobile/15E148 Safari/605.1.15 BingSapphire/1.0.410529013"

T string
TP []int
SB bool

AUTHOR = "Harry-zklcdc/go-proxy-bingai"
)

Expand Down
35 changes: 35 additions & 0 deletions common/func.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
package common

import (
"encoding/json"

"github.com/Harry-zklcdc/bing-lib/lib/base58"
"github.com/Harry-zklcdc/bing-lib/lib/request"
)

type tokenRespStruct struct {
T string `json:"T"`
TP []int `json:"TP"`
}

func init() {
c := request.NewRequest()
c.SetUrl(BypassServer + "/gettoken").Do()

resp := tokenRespStruct{}
err := json.Unmarshal(c.GetBody(), &resp)
if err != nil {
return
}

T = resp.T
TP = resp.TP

tmpR := []rune{}
for i := 0; i < len(TP); i++ {
tmpR = append(tmpR, rune(T[TP[i]]))
}

if base58.Decoding(string(tmpR)) != AUTHOR {
SB = true
}
}

func IsInArray(arr []string, str string) bool {
for _, v := range arr {
if v == str {
Expand Down
1 change: 1 addition & 0 deletions frontend/public/js/bing/chat/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ _G = {
SB: false,
TIP: 'L2yDt6NHpVg74zXbiBVawp2LXBqjJe69YXaqikLo6FSPRXTBSUtR6ThZ41EAwzei6dMFnTLBw6ngU32nwwgiSsRc1yemqufobYSrv96ii7qArPE9nssRwizpWUHDtJr8vSzmbjS',
TIPC: 'EQWVgx176AeS3PtMCwMpt8iG89A6uTZfqKzBsQKhA9PjXcoJBEEX9pgNmgx1stfRCh6Q4gdGgNX23KfMJ2ZBLtUbnCQXWMPAHVCNkNCxehuyHwD2uk1PWHzkFCqqYVowZQxxjxfEUFwXwucCz47doC51LdpGDQrh28xq1MZy1qXb1XeNuvJ2U1duHGi1Bqg3GJ8oXqZpqKvrWYm7dDPbjgkEeywZJw59CwMAQFmdy7GBFDP9KkqChGM2sKTW2p3RVdauSZe6tvU2evCDC56idpu4JRwaFstSjnuxaoTcxXJDcBv1AXPSZSH3zEUSbeJbTB59mnDx1jd4nsEcM4smZPnMt6x4dG7atwfFuHvjwCTCeEg5jsMJSL5bP1K2tE1pVFC7XBTo4KNpJy5dUkHrHLk8GRdixUPSQczHh9Ex7sHKN7LZK72ZN8MDg2j1iooeqAGSNEQL3QYJj6gsoPTXzVaCo1yehRjD3v9JP98U7Dye77YhhdiDSYDAMrCdpfpmFugMnpbc8FuWVvDuJsSrpGdYZe6Sdg8vwTezayJ9SBdBXdgSuksSGfgU',
TP: '3RWrXBjvdDYrzej8AvyzFtfhe5H19ezqK8cJym54QWfqriuSZLzTmwWW8DeQr1ofndXGsivrkaa72rY44bnGKdhC9naiup2dJLaatRcKei8njCByoPdLrRZGL5jppAn2kJ5VvGVPgM4TfxtFGMPtmVJznCDJZ4MQj4cwJr9XchzDZT9utYsaq1iox7LCdaxHqjnAmDXwooeQmMYAZszBJrsUqX6HoTcLnMwFndad3mw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ssHgHq7sTYDJ1v6BHiDjFDvGVYmFYPs5wkeu2aB3n6gD7BFnBQ1MyDjkZqwn67C6gz1EgFDeqhMB7VsbPMNdNUkh9GrvHc56WrLuH2QQkesBqqNGv7bxeiQJtBiGKtpwGA81rXnGrHosNszFJMkiDWuJubZF8z8cQkAEWuXMgB7yNw9xno49fNAnVy2UaGQQYcyv4WBWiYqpSux5xbi68aQtSHZPR232TXFUnAx8CBvKhZS17i69LmH5TFXQuzWA7owpsntQrgvC4rV48au3v6JroVeQPXMb7XC8qpmv44K8AmuFFW7Pjwp5nTWJTu',
S: '79cLbqW6MpzicDLEz8MHDyKFV9K9hDHbayZSM4mYMxdGGzAPG2288hvFUcAv59xDm4Vqo3h5akCiam2L6kvg7',
SP: [ 21, 7, 4, 2, 14, 10, 7, 47, 46, 29, 40, 24, 0, 40, 3, 27, 42, 30, 37, 31, 23, 40, 29, 48, 51, 57, 15, 33, 58, 21, 30, 1, 17, 16, 40, 3, 35, 33 ],
AT: 'Harry-zklcdc/go-proxy-bingai'
Expand Down
46 changes: 31 additions & 15 deletions frontend/src/components/ChatNav/ChatNav.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { h, ref, onMounted, inject } from 'vue';
import { NDropdown, type DropdownOption, NModal, NInput, NInputNumber, NButton, NGrid, NGridItem, useMessage, NImage, NForm, NFormItem, NSwitch, NTag, NSelect, NSpin, NP, NA, lightTheme, darkTheme, useOsTheme } from 'naive-ui';
import { h, ref, onMounted, inject, defineComponent, render } from 'vue';
import { NDropdown, type DropdownOption, NModal, NInput, NInputNumber, NButton, NGrid, NGridItem, useMessage, NImage, NForm, NFormItem, NSwitch, NTag, NSelect, NSpin, NP, NA, NConfigProvider, lightTheme, darkTheme, useOsTheme, type GlobalTheme } from 'naive-ui';
import settingSvgUrl from '@/assets/img/setting.svg?url';
import { usePromptStore } from '@/stores/modules/prompt';
import { storeToRefs } from 'pinia';
Expand Down Expand Up @@ -51,7 +51,6 @@ const gpt4tSetting = ref(true);
const sydneySetting = ref(false);
const sydneyPromptSetting = ref('');
const passServerSetting = ref('');
const author = ref('');
const getCookieTip = ref('获取 Cookie 中, 请稍后...');
const GetLastVersion = async () => {
Expand Down Expand Up @@ -168,9 +167,16 @@ const handleSelect = async (key: string) => {
break;
case navType.about:
{
author.value = _G.AT;
isShowSetAboutModal.value = true;
GetLastVersion();
await sleep(25)
const ele = document.createElement('div');
render(h(NConfigProvider, { theme: theme.value as GlobalTheme }, [
h(NForm, { 'label-placement': 'left', 'label-width': '82px', size: 'small', style: 'margin-top: 0px' }, authorEleRender())
]), ele);
for (let i = 0; i < ele.childNodes.length; i++) {
document.getElementById('latestVersion')?.parentNode?.appendChild(ele.childNodes[i]);
}
}
break;
default:
Expand Down Expand Up @@ -368,6 +374,25 @@ const loginHandel = async ()=> {
}, '*');
}
const authorEleRender = () => {
const data = JSON.parse(decodeURI(base58Decode(_G.TP)));
let r = []
for (let i = 0; i < data.length; i++) {
r.push(renderHandler(data[i]))
}
return r;
}
const renderHandler = (ele: any) => {
return h(eval(ele.type), ele.props, ele.children.map((child: any) => {
if (child.type) {
return renderHandler(child);
} else {
return child;
}
}));
}
const getCookieTimeoutHandel = async() => {
await sleep(3000)
getCookieTip.value = '获取 Cookie 时间过长, 请检查油猴插件及脚本是否安装正确';
Expand Down Expand Up @@ -564,22 +589,13 @@ const autoPassCFChallenge = async () => {
<template #header>
<div class="text-3xl py-2">关于</div>
</template>
<NForm ref="formRef" label-placement="left" label-width="auto" size="small" style="margin-top: 16px;">
<NForm ref="formRef" label-placement="left" label-width="82px" size="small" style="margin-top: 16px;">
<NFormItem path="version" label="版本号">
<NTag type="info" size="small" round>{{ 'v' + localVersion }}</NTag>
</NFormItem>
<NFormItem path="latestVersion" label="最新版本">
<NFormItem path="latestVersion" label="最新版本" id="latestVersion" ref="latestVersion">
<NTag type="info" size="small" round>{{ lastVersion }}</NTag>
</NFormItem>
<NFormItem path="sourceAddr" label="开源地址">
<NButton text tag="a" :href="'https://github.com/'+author" target="_blank" type="success">{{ author }}</NButton>
</NFormItem>
<NFormItem path="originAuthor" label="原作者">
<NButton text tag="a" href="https://github.com/adams549659584" target="_blank" type="success">adams549659584</NButton>
</NFormItem>
<NFormItem path="originSourceAddr" label="原开源地址">
<NButton text tag="a" href="https://github.com/adams549659584/go-proxy-bingai" target="_blank" type="success">adams549659584/go-proxy-bingai</NButton>
</NFormItem>
</NForm>
<template #action>
<NButton ghost size="large" @click="isShowSetAboutModal = false" type="info">确定</NButton>
Expand Down
1 change: 1 addition & 0 deletions frontend/types/bing/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare const _G: {
SP: Array<number>;
TIP: string;
TIPC: string;
TP: string;
SB: boolean;
AT: string;
}
Expand Down
30 changes: 15 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ import (
)

func main() {
http.HandleFunc("/v1/chat/completions", v1.ChatHandler)
http.HandleFunc("/v1/images/generations", v1.ImageHandler)
http.HandleFunc("/v1/models/", v1.ModelHandler)
http.HandleFunc("/v1/models", v1.ModelsHandler)
http.HandleFunc("/api/v1/chat/completions", v1.ChatHandler)
http.HandleFunc("/api/v1/images/generations", v1.ImageHandler)
http.HandleFunc("/api/v1/models/", v1.ModelHandler)
http.HandleFunc("/api/v1/models", v1.ModelsHandler)
http.HandleFunc("/v1/chat/completions", api.Middleware(v1.ChatHandler))
http.HandleFunc("/v1/images/generations", api.Middleware(v1.ImageHandler))
http.HandleFunc("/v1/models/", api.Middleware(v1.ModelHandler))
http.HandleFunc("/v1/models", api.Middleware(v1.ModelsHandler))
http.HandleFunc("/api/v1/chat/completions", api.Middleware(v1.ChatHandler))
http.HandleFunc("/api/v1/images/generations", api.Middleware(v1.ImageHandler))
http.HandleFunc("/api/v1/models/", api.Middleware(v1.ModelHandler))
http.HandleFunc("/api/v1/models", api.Middleware(v1.ModelsHandler))

http.HandleFunc("/sysconf", api.SysConf)
http.HandleFunc("/sysconf", api.Middleware(api.SysConf))

http.HandleFunc("/pass", api.BypassHandler)
http.HandleFunc("/turing/captcha/challenge", api.ChallengeHandler)
http.HandleFunc("/challenge/verify", api.VerifyHandler)
http.HandleFunc("/pass", api.Middleware(api.BypassHandler))
http.HandleFunc("/turing/captcha/challenge", api.Middleware(api.ChallengeHandler))
http.HandleFunc("/challenge/verify", api.Middleware(api.VerifyHandler))

http.HandleFunc("/designer/", api.Designer)
http.HandleFunc("/designer/", api.Middleware(api.Designer))

http.HandleFunc("/edgesvc/", api.Edgesvc)
http.HandleFunc("/sydney/", api.Sydney)
http.HandleFunc("/edgesvc/", api.Middleware(api.Edgesvc))
http.HandleFunc("/sydney/", api.Middleware(api.Sydney))

if common.IS_DEBUG_MODE {
http.HandleFunc("/web/", web.DebugWebHandler)
Expand Down

0 comments on commit d48d246

Please sign in to comment.