mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
重新实现套餐
This commit is contained in:
@@ -16,6 +16,7 @@ type BaseClientConn struct {
|
||||
|
||||
isBound bool
|
||||
userId int64
|
||||
userPlanId int64
|
||||
serverId int64
|
||||
remoteAddr string
|
||||
hasLimit bool
|
||||
@@ -106,11 +107,31 @@ func (this *BaseClientConn) SetUserId(userId int64) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *BaseClientConn) SetUserPlanId(userPlanId int64) {
|
||||
this.userPlanId = userPlanId
|
||||
|
||||
// 设置包装前连接
|
||||
switch conn := this.rawConn.(type) {
|
||||
case *tls.Conn:
|
||||
nativeConn, ok := conn.NetConn().(ClientConnInterface)
|
||||
if ok {
|
||||
nativeConn.SetUserPlanId(userPlanId)
|
||||
}
|
||||
case *ClientConn:
|
||||
conn.SetUserPlanId(userPlanId)
|
||||
}
|
||||
}
|
||||
|
||||
// UserId 获取当前连接所属服务的用户ID
|
||||
func (this *BaseClientConn) UserId() int64 {
|
||||
return this.userId
|
||||
}
|
||||
|
||||
// UserPlanId 用户套餐ID
|
||||
func (this *BaseClientConn) UserPlanId() int64 {
|
||||
return this.userPlanId
|
||||
}
|
||||
|
||||
// RawIP 原本IP
|
||||
func (this *BaseClientConn) RawIP() string {
|
||||
if len(this.rawIP) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user