feat: list & block online users

This commit is contained in:
naiba
2024-12-22 01:08:07 +08:00
parent 653d0cf2e9
commit 4af7e83004
10 changed files with 167 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ type StreamServer struct {
type StreamServerData struct {
Now int64 `json:"now,omitempty"`
Online uint64 `json:"online,omitempty"`
Online int `json:"online,omitempty"`
Servers []StreamServer `json:"servers,omitempty"`
}

View File

@@ -1,6 +1,9 @@
package model
import (
"time"
"github.com/gorilla/websocket"
"github.com/nezhahq/nezha/pkg/utils"
"gorm.io/gorm"
)
@@ -20,7 +23,6 @@ type User struct {
type UserInfo struct {
Role uint8
_ [3]byte
AgentSecret string
}
@@ -42,3 +44,11 @@ type Profile struct {
User
LoginIP string `json:"login_ip,omitempty"`
}
type OnlineUser struct {
UserID uint64 `json:"user_id,omitempty"`
ConnectedAt time.Time `json:"connected_at,omitempty"`
IP string `json:"ip,omitempty"`
Conn *websocket.Conn `json:"-"`
}

View File

@@ -14,12 +14,14 @@ const (
WAFBlockReasonTypeLoginFail
WAFBlockReasonTypeBruteForceToken
WAFBlockReasonTypeAgentAuthFail
WAFBlockReasonTypeManual
)
const (
BlockIDgRPC = -127 + iota
BlockIDToken
BlockIDUnknownUser
BlockIDManual
)
type WAFApiMock struct {