remove limit from UserList

This commit is contained in:
yuzuki999 2022-06-13 14:47:01 +08:00
parent 2d279aa202
commit 297d9cc618
3 changed files with 16 additions and 23 deletions

View File

@ -20,14 +20,14 @@ type TrojanUserInfo struct {
Password string `json:"password"`
}
type UserInfo struct {
DeviceLimit int `json:"device_limit"`
SpeedLimit uint64 `json:"speed_limit"`
UID int `json:"id"`
Port int `json:"port"`
Cipher string `json:"cipher"`
Secret string `json:"secret"`
V2rayUser *V2RayUserInfo `json:"v2ray_user"`
TrojanUser *TrojanUserInfo `json:"trojan_user"`
/*DeviceLimit int `json:"device_limit"`
SpeedLimit uint64 `json:"speed_limit"`*/
UID int `json:"id"`
Port int `json:"port"`
Cipher string `json:"cipher"`
Secret string `json:"secret"`
V2rayUser *V2RayUserInfo `json:"v2ray_user"`
TrojanUser *TrojanUserInfo `json:"trojan_user"`
}
func (p *UserInfo) GetUserEmail() string {

View File

@ -490,13 +490,6 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
// Check if domain and protocol hit the rule
sessionInbound := session.InboundFromContext(ctx)
// Whether the inbound connection contains a user
/*if protocol == "bittorrent" {
newError(fmt.Sprintf("User %s access %s reject by protocol rule", sessionInbound.User.Email, destination.String())).AtError().WriteToLog()
newError("destination is reject by protocol rule")
common.Close(link.Writer)
common.Interrupt(link.Reader)
return
}*/
if sessionInbound.User != nil {
if d.RuleManager.ProtocolDetect(sessionInbound.Tag, protocol) {
newError(fmt.Sprintf("User %s access %s reject by protocol rule", sessionInbound.User.Email, destination.String())).AtError().WriteToLog()

View File

@ -43,16 +43,16 @@ func (l *Limiter) AddInboundLimiter(tag string, nodeInfo *api.NodeInfo, userList
}
userMap := new(sync.Map)
for i := range *userList {
if (*userList)[i].SpeedLimit == 0 {
/*if (*userList)[i].SpeedLimit == 0 {
(*userList)[i].SpeedLimit = nodeInfo.SpeedLimit
}
if (*userList)[i].DeviceLimit == 0 {
(*userList)[i].DeviceLimit = nodeInfo.DeviceLimit
}
}*/
userMap.Store(fmt.Sprintf("%s|%s|%d", tag, (*userList)[i].GetUserEmail(), (*userList)[i].UID), UserInfo{
UID: (*userList)[i].UID,
SpeedLimit: (*userList)[i].SpeedLimit,
DeviceLimit: (*userList)[i].DeviceLimit,
SpeedLimit: nodeInfo.SpeedLimit,
DeviceLimit: nodeInfo.DeviceLimit,
})
}
inboundInfo.UserInfo = userMap
@ -66,16 +66,16 @@ func (l *Limiter) UpdateInboundLimiter(tag string, nodeInfo *api.NodeInfo, updat
inboundInfo := value.(*InboundInfo)
// Update User info
for _, u := range *usersIndex {
if (*updatedUserList)[u].SpeedLimit == 0 {
/*if (*updatedUserList)[u].SpeedLimit == 0 {
(*updatedUserList)[u].SpeedLimit = nodeInfo.SpeedLimit
}
if (*updatedUserList)[u].DeviceLimit == 0 {
(*updatedUserList)[u].DeviceLimit = nodeInfo.DeviceLimit
}
}*/
inboundInfo.UserInfo.Store(fmt.Sprintf("%s|%s|%d", tag, (*updatedUserList)[u].GetUserEmail(), (*updatedUserList)[u].UID), UserInfo{
UID: (*updatedUserList)[u].UID,
SpeedLimit: (*updatedUserList)[u].SpeedLimit,
DeviceLimit: (*updatedUserList)[u].DeviceLimit,
SpeedLimit: nodeInfo.SpeedLimit,
DeviceLimit: nodeInfo.DeviceLimit,
})
inboundInfo.BucketHub.Delete(fmt.Sprintf("%s|%s|%d", tag, (*updatedUserList)[u].GetUserEmail(), (*updatedUserList)[u].UID)) // Delete old limiter bucket
}