-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (48 loc) · 2.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"adams549659584/go-proxy-bingai/api"
"adams549659584/go-proxy-bingai/common"
wss_api "adams549659584/go-proxy-bingai/common/api"
v1 "adams549659584/go-proxy-bingai/common/api/v1"
"adams549659584/go-proxy-bingai/common/helper"
"adams549659584/go-proxy-bingai/web"
"net/http"
"time"
)
func main() {
http.HandleFunc("/v1/chat/completions", helper.Middleware(v1.ChatHandler))
http.HandleFunc("/v1/images/generations", helper.Middleware(v1.ImageHandler))
http.HandleFunc("/v1/models/", helper.Middleware(v1.ModelHandler))
http.HandleFunc("/v1/models", helper.Middleware(v1.ModelsHandler))
http.HandleFunc("/api/v1/chat/completions", helper.Middleware(v1.ChatHandler))
http.HandleFunc("/api/v1/images/generations", helper.Middleware(v1.ImageHandler))
http.HandleFunc("/api/v1/models/", helper.Middleware(v1.ModelHandler))
http.HandleFunc("/api/v1/models", helper.Middleware(v1.ModelsHandler))
http.HandleFunc("/sysconf", helper.Middleware(api.SysConf))
http.HandleFunc("/api/ms/login", helper.Middleware(api.LoginHandler))
http.HandleFunc("/pass", helper.Middleware(api.BypassHandler))
http.HandleFunc("/turing/captcha/challenge", helper.Middleware(api.ChallengeHandler))
http.HandleFunc("/challenge/verify", helper.Middleware(api.VerifyHandler))
http.HandleFunc("/th/", helper.Middleware(api.Th))
http.HandleFunc("/designer/", helper.Middleware(api.Designer))
http.HandleFunc("/edgesvc/", helper.Middleware(api.Edgesvc))
http.HandleFunc("/sydney/", helper.Middleware(wss_api.Sydney))
http.HandleFunc("/opaluqu/", helper.Middleware(wss_api.Opaluqu))
if common.IS_DEBUG_MODE {
http.HandleFunc("/web/", helper.Middleware(web.DebugWebHandler))
} else {
http.HandleFunc("/web/", helper.Middleware(api.WebStatic))
}
http.HandleFunc("/", api.Index)
addr := ":" + common.PORT
if common.LOCAL_MODE {
addr = "127.0.0.1:" + common.PORT
}
common.Logger.Info("Starting BingAI Proxy At " + addr)
srv := &http.Server{
Addr: addr,
WriteTimeout: 5 * time.Minute,
ReadTimeout: 15 * time.Second,
}
common.Logger.Fatal(srv.ListenAndServe())
}