mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
Compare commits
2 Commits
312086abe5
...
7831e2d1f8
Author | SHA1 | Date | |
---|---|---|---|
|
7831e2d1f8 | ||
|
9791c81a03 |
@ -64,6 +64,7 @@ func createNAT(c *gin.Context) (uint64, error) {
|
|||||||
uid := getUid(c)
|
uid := getUid(c)
|
||||||
|
|
||||||
n.UserID = uid
|
n.UserID = uid
|
||||||
|
n.Enabled = nf.Enabled
|
||||||
n.Name = nf.Name
|
n.Name = nf.Name
|
||||||
n.Domain = nf.Domain
|
n.Domain = nf.Domain
|
||||||
n.Host = nf.Host
|
n.Host = nf.Host
|
||||||
@ -121,6 +122,7 @@ func updateNAT(c *gin.Context) (any, error) {
|
|||||||
return nil, singleton.Localizer.ErrorT("permission denied")
|
return nil, singleton.Localizer.ErrorT("permission denied")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n.Enabled = nf.Enabled
|
||||||
n.Name = nf.Name
|
n.Name = nf.Name
|
||||||
n.Domain = nf.Domain
|
n.Domain = nf.Domain
|
||||||
n.Host = nf.Host
|
n.Host = nf.Host
|
||||||
|
@ -13,12 +13,14 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/ory/graceful"
|
"github.com/ory/graceful"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/http2/h2c"
|
"golang.org/x/net/http2/h2c"
|
||||||
|
|
||||||
"github.com/nezhahq/nezha/cmd/dashboard/controller"
|
"github.com/nezhahq/nezha/cmd/dashboard/controller"
|
||||||
|
"github.com/nezhahq/nezha/cmd/dashboard/controller/waf"
|
||||||
"github.com/nezhahq/nezha/cmd/dashboard/rpc"
|
"github.com/nezhahq/nezha/cmd/dashboard/rpc"
|
||||||
"github.com/nezhahq/nezha/model"
|
"github.com/nezhahq/nezha/model"
|
||||||
"github.com/nezhahq/nezha/proto"
|
"github.com/nezhahq/nezha/proto"
|
||||||
@ -147,6 +149,11 @@ func newHTTPandGRPCMux(httpHandler http.Handler, grpcHandler http.Handler) http.
|
|||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
natConfig := singleton.GetNATConfigByDomain(r.Host)
|
natConfig := singleton.GetNATConfigByDomain(r.Host)
|
||||||
if natConfig != nil {
|
if natConfig != nil {
|
||||||
|
if !natConfig.Enabled {
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
waf.ShowBlockPage(c, fmt.Errorf("nat host %s is disabled", natConfig.Domain))
|
||||||
|
return
|
||||||
|
}
|
||||||
rpc.ServeNAT(w, r, natConfig)
|
rpc.ServeNAT(w, r, natConfig)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package model
|
|||||||
|
|
||||||
type NAT struct {
|
type NAT struct {
|
||||||
Common
|
Common
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ServerID uint64 `json:"server_id"`
|
ServerID uint64 `json:"server_id"`
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
|
@ -2,6 +2,7 @@ package model
|
|||||||
|
|
||||||
type NATForm struct {
|
type NATForm struct {
|
||||||
Name string `json:"name,omitempty" minLength:"1"`
|
Name string `json:"name,omitempty" minLength:"1"`
|
||||||
|
Enabled bool `json:"enabled,omitempty"`
|
||||||
ServerID uint64 `json:"server_id,omitempty"`
|
ServerID uint64 `json:"server_id,omitempty"`
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
Domain string `json:"domain,omitempty"`
|
Domain string `json:"domain,omitempty"`
|
||||||
|
@ -2,22 +2,22 @@
|
|||||||
name: "OfficialAdmin"
|
name: "OfficialAdmin"
|
||||||
repository: "https://github.com/nezhahq/admin-frontend"
|
repository: "https://github.com/nezhahq/admin-frontend"
|
||||||
author: "nezhahq"
|
author: "nezhahq"
|
||||||
version: "v1.6.0"
|
version: "v1.6.2"
|
||||||
isadmin: true
|
isadmin: true
|
||||||
isofficial: true
|
isofficial: true
|
||||||
- path: "user-dist"
|
- path: "user-dist"
|
||||||
name: "Official"
|
name: "Official"
|
||||||
repository: "https://github.com/hamster1963/nezha-dash-v1"
|
repository: "https://github.com/hamster1963/nezha-dash-v1"
|
||||||
author: "hamster1963"
|
author: "hamster1963"
|
||||||
version: "v1.13.1"
|
version: "v1.13.3"
|
||||||
isofficial: true
|
isofficial: true
|
||||||
- path: "nezha-ascii-dist"
|
- path: "nezha-ascii-dist"
|
||||||
name: "Nezha-ASCII"
|
name: "Nezha-ASCII"
|
||||||
repository: "https://github.com/hamster1963/nezha-ascii"
|
repository: "https://github.com/hamster1963/nezha-ascii"
|
||||||
author: "hamster1963"
|
author: "hamster1963"
|
||||||
version: "v1.0.1"
|
version: "v1.0.2"
|
||||||
- path: "nazhua-dist"
|
- path: "nazhua-dist"
|
||||||
name: "Nazhua"
|
name: "Nazhua"
|
||||||
repository: "https://github.com/hi2shark/nazhua"
|
repository: "https://github.com/hi2shark/nazhua"
|
||||||
author: "hi2hi"
|
author: "hi2hi"
|
||||||
version: "v0.5.1"
|
version: "v0.5.3"
|
||||||
|
Loading…
Reference in New Issue
Block a user