mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 01:28:13 -05:00
feat: show online user id
Some checks are pending
CodeQL / Analyze (go) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Contributors / contributors (push) Waiting to run
Sync / sync-to-jihulab (push) Waiting to run
Run Tests / tests (macos) (push) Waiting to run
Run Tests / tests (ubuntu) (push) Waiting to run
Run Tests / tests (windows) (push) Waiting to run
Some checks are pending
CodeQL / Analyze (go) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Contributors / contributors (push) Waiting to run
Sync / sync-to-jihulab (push) Waiting to run
Run Tests / tests (macos) (push) Waiting to run
Run Tests / tests (ubuntu) (push) Waiting to run
Run Tests / tests (windows) (push) Waiting to run
This commit is contained in:
parent
d50605d668
commit
5128bfff61
@ -33,7 +33,7 @@ func listBlockedAddress(c *gin.Context) (*model.Value[[]*model.WAF], error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var waf []*model.WAF
|
var waf []*model.WAF
|
||||||
if err := singleton.DB.Limit(limit).Offset(offset).Find(&waf).Error; err != nil {
|
if err := singleton.DB.Order("block_timestamp DESC").Limit(limit).Offset(offset).Find(&waf).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,14 @@ func serverStream(c *gin.Context) (any, error) {
|
|||||||
userIp = c.RemoteIP()
|
userIp = c.RemoteIP()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
||||||
|
var userId uint64
|
||||||
|
if isMember {
|
||||||
|
userId = u.(*model.User).ID
|
||||||
|
}
|
||||||
|
|
||||||
singleton.AddOnlineUser(connId, &model.OnlineUser{
|
singleton.AddOnlineUser(connId, &model.OnlineUser{
|
||||||
|
UserID: userId,
|
||||||
IP: userIp,
|
IP: userIp,
|
||||||
ConnectedAt: time.Now(),
|
ConnectedAt: time.Now(),
|
||||||
Conn: conn,
|
Conn: conn,
|
||||||
@ -128,7 +135,7 @@ func serverStream(c *gin.Context) (any, error) {
|
|||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
for {
|
for {
|
||||||
stat, err := getServerStat(c, count == 0)
|
stat, err := getServerStat(count == 0, isMember)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -149,9 +156,7 @@ func serverStream(c *gin.Context) (any, error) {
|
|||||||
|
|
||||||
var requestGroup singleflight.Group
|
var requestGroup singleflight.Group
|
||||||
|
|
||||||
func getServerStat(c *gin.Context, withPublicNote bool) ([]byte, error) {
|
func getServerStat(withPublicNote, authorized bool) ([]byte, error) {
|
||||||
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
|
||||||
authorized := isMember // TODO || isViewPasswordVerfied
|
|
||||||
v, err, _ := requestGroup.Do(fmt.Sprintf("serverStats::%t", authorized), func() (interface{}, error) {
|
v, err, _ := requestGroup.Do(fmt.Sprintf("serverStats::%t", authorized), func() (interface{}, error) {
|
||||||
singleton.SortedServerLock.RLock()
|
singleton.SortedServerLock.RLock()
|
||||||
defer singleton.SortedServerLock.RUnlock()
|
defer singleton.SortedServerLock.RUnlock()
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
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.8.0"
|
version: "v1.8.1"
|
||||||
isofficial: true
|
isofficial: true
|
||||||
- path: "nazhua-dist"
|
- path: "nazhua-dist"
|
||||||
name: "Nazhua"
|
name: "Nazhua"
|
||||||
|
Loading…
Reference in New Issue
Block a user