mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-11-04 16:40:21 +00:00
Merge upstream monitoring features preserving domain extensions and require fixed Go toolchain
This commit is contained in:
commit
71dd21269b
92 files changed
+8557
-874
No files matched your search
+26
-6
@@ -12,7 +12,6 @@ import (
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"time"
|
||||
_ "time/tzdata"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -86,6 +85,16 @@ func initSystem(bus chan<- *model.Service) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 在线会话兜底清扫:状态流异常断开(失联)时由这里关闭进行中的会话
|
||||
if _, err := singleton.CronShared.AddFunc("@every 30s", singleton.SweepOnlineSessions); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 在线会话保留清理:超出后台设置的统计窗口后删除
|
||||
if _, err := singleton.CronShared.AddFunc("0 30 4 * * *", singleton.PruneOnlineSessions); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := singleton.StartJWTSessionGC(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -178,12 +187,11 @@ func main() {
|
||||
grpcHandler := rpc.ServeRPC()
|
||||
httpHandler := controller.ServeWeb(frontendDist)
|
||||
controller.InitUpgrader()
|
||||
wireNATDashboardCredentialGate()
|
||||
|
||||
muxHandler := newHTTPandGRPCMux(httpHandler, grpcHandler)
|
||||
muxServerHTTP := &http.Server{
|
||||
Handler: muxHandler,
|
||||
ReadHeaderTimeout: time.Second * 5,
|
||||
}
|
||||
muxServerHTTP := newDashboardHTTPServer(muxHandler)
|
||||
|
||||
muxServerHTTP.Protocols = new(http.Protocols)
|
||||
muxServerHTTP.Protocols.SetHTTP1(true)
|
||||
muxServerHTTP.Protocols.SetUnencryptedHTTP2(true)
|
||||
@@ -191,9 +199,9 @@ func main() {
|
||||
var muxServerHTTPS *http.Server
|
||||
if singleton.Conf.HTTPS.ListenPort != 0 {
|
||||
muxServerHTTPS = &http.Server{
|
||||
ReadHeaderTimeout: dashboardReadHeaderTimeout,
|
||||
Addr: fmt.Sprintf("%s:%d", singleton.Conf.ListenHost, singleton.Conf.HTTPS.ListenPort),
|
||||
Handler: muxHandler,
|
||||
ReadHeaderTimeout: time.Second * 5,
|
||||
TLSConfig: &tls.Config{
|
||||
InsecureSkipVerify: singleton.Conf.HTTPS.InsecureTLS,
|
||||
},
|
||||
@@ -237,6 +245,18 @@ func main() {
|
||||
close(errChan)
|
||||
}
|
||||
|
||||
// wireNATDashboardCredentialGate connects the NAT ingress to the real
|
||||
// dashboard-credential classifiers. The NAT ingress strips dashboard-issued
|
||||
// credentials (panel JWT / panel PAT) from every channel the panel's own
|
||||
// TokenLookup accepts — the Authorization header, the ?token= query parameter
|
||||
// and the nz-jwt cookie — before tunneling a request to the agent, and
|
||||
// forwards foreign values untouched. ServeWeb built the JWT parser the
|
||||
// classifier reuses, so the gate is wired right after it and before any
|
||||
// listener starts serving.
|
||||
func wireNATDashboardCredentialGate() {
|
||||
rpc.SetNATDashboardCredentialGate(controller.ClassifyDashboardCredentialValues)
|
||||
}
|
||||
|
||||
func newHTTPandGRPCMux(httpHandler http.Handler, grpcHandler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
natConfig := singleton.NATShared.GetNATConfigByDomain(r.Host)
|
||||
|
||||
Reference in new issue
Block a user