mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
API: Add user online stats (#3637)
* add statsUserOnline bool to policy * add OnlineMap struct to stats * apply UserOnline functionality to dispatcher * add statsonline api command * fix comments * Update app/stats/online_map.go Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> * improve AddIP * regenerate pb --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com>
This commit is contained in:
parent
e3276df725
commit
2c72864935
15 changed files with 575 additions and 177 deletions
|
@ -46,6 +46,20 @@ func (s *statsServer) GetStats(ctx context.Context, request *GetStatsRequest) (*
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (s *statsServer) GetStatsOnline(ctx context.Context, request *GetStatsRequest) (*GetStatsResponse, error) {
|
||||
c := s.stats.GetOnlineMap(request.Name)
|
||||
if c == nil {
|
||||
return nil, errors.New(request.Name, " not found.")
|
||||
}
|
||||
value := int64(c.Count())
|
||||
return &GetStatsResponse{
|
||||
Stat: &Stat{
|
||||
Name: request.Name,
|
||||
Value: value,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *statsServer) QueryStats(ctx context.Context, request *QueryStatsRequest) (*QueryStatsResponse, error) {
|
||||
matcher, err := strmatcher.Substr.New(request.Pattern)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue