Documentation
¶
Index ¶
- type Allconfigs
- type BroadcastSig
- type Controller
- func (c *Controller) AddEvent(userId int64, name string) error
- func (c *Controller) AddResetUserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
- func (w *Controller) Addquemg(upxctx context.Context, msg any)
- func (c *Controller) Addsession(closefunc ForceCloser, UserId int64)
- func (c *Controller) AdduserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
- func (c *Controller) CancleUpdateContexs()
- func (c *Controller) CheckLock() bool
- func (c *Controller) Checksession(UserId int64) (any, bool)
- func (c *Controller) ClaimReferVerified(owenerid int64) (int, error)
- func (c *Controller) Close() error
- func (c *Controller) CreateRefrral(owenerid, userid int64) (*db.Reffral, error)
- func (c *Controller) CreateSboxConf(userId int64, name string) (db.SboxConfigs, error)
- func (c *Controller) DecCriticalOp()
- func (c *Controller) DeleteConf(confId int64) error
- func (c *Controller) DirectMg(text string, UserId int64, ChatID int64) error
- func (c *Controller) GetBaseContext() context.Context
- func (c *Controller) GetHelepCmdInfo() bottype.HelpCommandInfo
- func (c *Controller) GetLastRefreshtime() time.Time
- func (c *Controller) GetSboxConfig(userID int64) ([]db.SboxConfigs, error)
- func (c *Controller) GetSpecificConf(userId int64, name string) (db.SboxConfigs, error)
- func (c *Controller) GetUnVerifiedUserList(in *[]int64) error
- func (c *Controller) GetUser(user *tgbotapi.User) (*bottype.User, bool, error)
- func (c *Controller) GetUserById(userId int64) (*db.User, error)
- func (c *Controller) GetUserByUserName(userName string) (*db.User, error)
- func (c *Controller) GetUserConfigs(userID int64) ([]db.Config, error)
- func (c *Controller) GetUserList(in *[]int64) error
- func (c *Controller) GetVerifiedUserList(in *[]int64) error
- func (c *Controller) Getadminchat() (map[int64]string, error)
- func (c *Controller) Getmgque() chan any
- func (c *Controller) GetstatusUserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
- func (c *Controller) Gift(upx *update.Updatectx, to any, quota C.Bwidth) (*db.User, error)
- func (c *Controller) IncCriticalOp()
- func (c *Controller) IncreaseUserCount(count int)
- func (c *Controller) Init() error
- func (c *Controller) LoadEvents(userID int64) (map[string]db.Event, error)
- func (c *Controller) Newuser(user *tgbotapi.User, chat *tgbotapi.Chat) (*bottype.User, error)
- func (c *Controller) RecalculateConfigquotas(user *db.User) error
- func (c *Controller) ReffralCount(owenerid int64) (int64, int64, error)
- func (c *Controller) RefreshUrlTest()
- func (c *Controller) RefreshUser(ctx context.Context, dbuser *db.User) error
- func (c *Controller) RemoveSesion(UserId int64)
- func (c *Controller) RemoveUserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
- func (c *Controller) SearchUserByUsername(username string) (*db.User, bool, error)
- func (c *Controller) SendMsgContext(ctx context.Context, msg any) (*tgbotapi.Message, error)
- func (c *Controller) SetIsbotarted(userID int64, val bool) error
- func (c *Controller) SetLastRefreshtime()
- func (c *Controller) UpdatePoint(newpointCount int64, userId int64) error
- func (c *Controller) UrlTestOut(tag string) (int16, error)
- func (c *Controller) WaitCriticalop()
- func (c *Controller) WatchmanLock()
- func (c *Controller) WatchmanUnlock()
- type CtrlSession
- func (c *CtrlSession) ActivateAll() error
- func (c *CtrlSession) ActivateConfig(confid int64) (sbox.Sboxstatus, error)
- func (c *CtrlSession) AddNewConfig(inboundid int16, outboundid int16, Quota C.Bwidth, login int16, name string) (*sbox.Userconfig, error)
- func (c *CtrlSession) Banuser(chat string)
- func (c *CtrlSession) ChangeIO(ioboundname string, confid, ioid int64) error
- func (c *CtrlSession) ChangeInbound(confid, inboundid int64) error
- func (c *CtrlSession) ChangeLoginLimit(confid int64, newlimit int32) (sbox.Sboxstatus, error)
- func (c *CtrlSession) ChangeOutbound(confid, inboundid int64) error
- func (c *CtrlSession) Chatupdate(chat string, val bool)
- func (c *CtrlSession) Close() error
- func (c *CtrlSession) ConfigCloseConn(confid int64) error
- func (c *CtrlSession) CreateUsagehistory(status sbox.Sboxstatus, confid int64) error
- func (c *CtrlSession) DeactivateAll() error
- func (c *CtrlSession) DeactivateConfig(configID int64) (sbox.Sboxstatus, error)
- func (c *CtrlSession) DeleteConfig(configID int64) error
- func (c *CtrlSession) ForceClose() error
- func (c *CtrlSession) FullUsageHistory()
- func (c *CtrlSession) GetConfig(confid int64) (*db.Config, error)
- func (c *CtrlSession) GetConfigFullUsage(confid int64) (bottype.FullUsage, sbox.Sboxstatus)
- func (c *CtrlSession) GetFullUsage() bottype.FullUsage
- func (c *CtrlSession) GetUsage() (C.Bwidth, C.Bwidth)
- func (c *CtrlSession) GetUser() *db.User
- func (c *CtrlSession) GetconfigQuota(confid int64) C.Bwidth
- func (c *CtrlSession) GetconfigUsage(confid int64) (C.Bwidth, C.Bwidth, error)
- func (c *CtrlSession) GetconfigUsageTotal(confid int64) C.Bwidth
- func (c *CtrlSession) Getstatus(confid int64) (sbox.Sboxstatus, error)
- func (c *CtrlSession) LeftQuota() C.Bwidth
- func (c *CtrlSession) LeftQuotaFromOrigin() C.Bwidth
- func (c *CtrlSession) LeftUsage() C.Bwidth
- func (c *CtrlSession) ReActivateConfig(confid int64) (sbox.Sboxstatus, error)
- func (c *CtrlSession) RemoveRestrict()
- func (c *CtrlSession) Restrict()
- func (c *CtrlSession) Save() error
- func (c *CtrlSession) SaveConfigs() error
- func (c *CtrlSession) TotalUsage() C.Bwidth
- type ForceCloser
- type ForceResetUsage
- type Metadata
- func (m *Metadata) ConfFolder() string
- func (m *Metadata) DefaultInboud() (sbox.Inboud, db.Inbound)
- func (m *Metadata) Defaultoutboud() (sbox.Outbound, db.Outbound)
- func (m *Metadata) GetInlinePost() []string
- func (m *Metadata) GetdbInbound(id int) (db.Inbound, error)
- func (m *Metadata) GetdbOutbound(id int) (db.Outbound, error)
- func (m *Metadata) Getinbound(id int) (sbox.Inboud, bool)
- func (m *Metadata) Getinbounds() []sbox.Inboud
- func (m *Metadata) Getoutbound(id int) (sbox.Outbound, bool)
- func (m *Metadata) Getoutbounds() []sbox.Outbound
- func (m *Metadata) Init(metaconf MetadataConf) error
- func (m *Metadata) StorePath() string
- type MetadataConf
- type Overview
- type RefreshSignal
- type SboxIO
- type UserCount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allconfigs ¶
func (Allconfigs) Appendconf ¶
func (a Allconfigs) Appendconf(conf *sbox.Userconfig, userid int64)
func (Allconfigs) RemoveAll ¶
func (a Allconfigs) RemoveAll()
type BroadcastSig ¶
type BroadcastSig string //use to send Broadcast signal with broadcast msg
type Controller ¶
type Controller struct {
Lockval *atomic.Int32
Metaconfig *MetadataConf
*Metadata
Overview *Overview
Usermgrsession *sync.Map
// contains filtered or unexported fields
}
func (*Controller) AddResetUserSbox ¶
func (c *Controller) AddResetUserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
func (*Controller) Addquemg ¶
func (w *Controller) Addquemg(upxctx context.Context, msg any)
msg should be type controller.UserCount, *botapi.Msgcommon, botapi.UpMessage: remove ctx argument later
func (*Controller) Addsession ¶
func (c *Controller) Addsession(closefunc ForceCloser, UserId int64)
func (*Controller) AdduserSbox ¶
func (c *Controller) AdduserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
func (*Controller) CancleUpdateContexs ¶
func (c *Controller) CancleUpdateContexs()
canceling all ongoing upx
func (*Controller) CheckLock ¶
func (c *Controller) CheckLock() bool
check is that controller locked by watchman if locked this function wait for it to unlock
func (*Controller) Checksession ¶
func (c *Controller) Checksession(UserId int64) (any, bool)
func (*Controller) ClaimReferVerified ¶
func (c *Controller) ClaimReferVerified(owenerid int64) (int, error)
heavy load on db optimize later
func (*Controller) Close ¶
func (c *Controller) Close() error
func (*Controller) CreateRefrral ¶
func (c *Controller) CreateRefrral(owenerid, userid int64) (*db.Reffral, error)
func (*Controller) CreateSboxConf ¶
func (c *Controller) CreateSboxConf(userId int64, name string) (db.SboxConfigs, error)
func (*Controller) DecCriticalOp ¶
func (c *Controller) DecCriticalOp()
func (*Controller) DeleteConf ¶
func (c *Controller) DeleteConf(confId int64) error
Deletes buildconfig not releted to server configs
func (*Controller) DirectMg ¶
func (c *Controller) DirectMg(text string, UserId int64, ChatID int64) error
func (*Controller) GetBaseContext ¶
func (c *Controller) GetBaseContext() context.Context
func (*Controller) GetHelepCmdInfo ¶
func (c *Controller) GetHelepCmdInfo() bottype.HelpCommandInfo
func (*Controller) GetLastRefreshtime ¶
func (c *Controller) GetLastRefreshtime() time.Time
func (*Controller) GetSboxConfig ¶
func (c *Controller) GetSboxConfig(userID int64) ([]db.SboxConfigs, error)
func (*Controller) GetSpecificConf ¶
func (c *Controller) GetSpecificConf(userId int64, name string) (db.SboxConfigs, error)
func (*Controller) GetUnVerifiedUserList ¶
func (c *Controller) GetUnVerifiedUserList(in *[]int64) error
func (*Controller) GetUserById ¶
func (c *Controller) GetUserById(userId int64) (*db.User, error)
func (*Controller) GetUserByUserName ¶
func (c *Controller) GetUserByUserName(userName string) (*db.User, error)
func (*Controller) GetUserConfigs ¶
func (c *Controller) GetUserConfigs(userID int64) ([]db.Config, error)
this give configs according to server not from builder
func (*Controller) GetUserList ¶
func (c *Controller) GetUserList(in *[]int64) error
func (*Controller) GetVerifiedUserList ¶
func (c *Controller) GetVerifiedUserList(in *[]int64) error
func (*Controller) Getadminchat ¶
func (c *Controller) Getadminchat() (map[int64]string, error)
func (*Controller) Getmgque ¶
func (c *Controller) Getmgque() chan any
returning channel can be used many things, user update count, que sending msg to user when buffring usercount update type should be UserCount
func (*Controller) GetstatusUserSbox ¶
func (c *Controller) GetstatusUserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
func (*Controller) Gift ¶
Only checks reciver can recive the gift if not return err, Caller should check sender is valid input quota should be BYte format
func (*Controller) IncCriticalOp ¶
func (c *Controller) IncCriticalOp()
func (*Controller) IncreaseUserCount ¶
func (c *Controller) IncreaseUserCount(count int)
func (*Controller) Init ¶
func (c *Controller) Init() error
func (*Controller) LoadEvents ¶
func (*Controller) RecalculateConfigquotas ¶
func (c *Controller) RecalculateConfigquotas(user *db.User) error
user struct should have been preloaded configs this method does not save to db, caller should
func (*Controller) ReffralCount ¶
func (c *Controller) ReffralCount(owenerid int64) (int64, int64, error)
return reffrld, verified, error
func (*Controller) RefreshUrlTest ¶
func (c *Controller) RefreshUrlTest()
func (*Controller) RefreshUser ¶
func (*Controller) RemoveSesion ¶
func (c *Controller) RemoveSesion(UserId int64)
func (*Controller) RemoveUserSbox ¶
func (c *Controller) RemoveUserSbox(conf *sbox.Userconfig) (sbox.Sboxstatus, error)
func (*Controller) SearchUserByUsername ¶
func (*Controller) SendMsgContext ¶
func (*Controller) SetIsbotarted ¶
func (c *Controller) SetIsbotarted(userID int64, val bool) error
Do not use this func its slow
func (*Controller) SetLastRefreshtime ¶
func (c *Controller) SetLastRefreshtime()
only use In watchman, Do not use elsewhere
func (*Controller) UpdatePoint ¶
func (c *Controller) UpdatePoint(newpointCount int64, userId int64) error
func (*Controller) UrlTestOut ¶
func (c *Controller) UrlTestOut(tag string) (int16, error)
func (*Controller) WaitCriticalop ¶
func (c *Controller) WaitCriticalop()
func (*Controller) WatchmanLock ¶
func (c *Controller) WatchmanLock()
func (*Controller) WatchmanUnlock ¶
func (c *Controller) WatchmanUnlock()
type CtrlSession ¶
type CtrlSession struct {
// contains filtered or unexported fields
}
Ctrlsession is not theadsafe use in single thread
func NewctrlSession ¶
func NewctrlSession(ctrl *Controller, upx *update.Updatectx, ForceCloseOldSession bool) (*CtrlSession, error)
func (*CtrlSession) ActivateAll ¶
func (c *CtrlSession) ActivateAll() error
func (*CtrlSession) ActivateConfig ¶
func (c *CtrlSession) ActivateConfig(confid int64) (sbox.Sboxstatus, error)
func (*CtrlSession) AddNewConfig ¶
func (c *CtrlSession) AddNewConfig(inboundid int16, outboundid int16, Quota C.Bwidth, login int16, name string) (*sbox.Userconfig, error)
func (*CtrlSession) Banuser ¶
func (c *CtrlSession) Banuser(chat string)
func (*CtrlSession) ChangeIO ¶
func (c *CtrlSession) ChangeIO(ioboundname string, confid, ioid int64) error
func (*CtrlSession) ChangeInbound ¶
func (c *CtrlSession) ChangeInbound(confid, inboundid int64) error
func (*CtrlSession) ChangeLoginLimit ¶
func (c *CtrlSession) ChangeLoginLimit(confid int64, newlimit int32) (sbox.Sboxstatus, error)
func (*CtrlSession) ChangeOutbound ¶
func (c *CtrlSession) ChangeOutbound(confid, inboundid int64) error
func (*CtrlSession) Chatupdate ¶
func (c *CtrlSession) Chatupdate(chat string, val bool)
func (*CtrlSession) Close ¶
func (c *CtrlSession) Close() error
func (*CtrlSession) ConfigCloseConn ¶
func (c *CtrlSession) ConfigCloseConn(confid int64) error
func (*CtrlSession) CreateUsagehistory ¶
func (c *CtrlSession) CreateUsagehistory(status sbox.Sboxstatus, confid int64) error
func (*CtrlSession) DeactivateAll ¶
func (c *CtrlSession) DeactivateAll() error
func (*CtrlSession) DeactivateConfig ¶
func (c *CtrlSession) DeactivateConfig(configID int64) (sbox.Sboxstatus, error)
func (*CtrlSession) DeleteConfig ¶
func (c *CtrlSession) DeleteConfig(configID int64) error
func (*CtrlSession) ForceClose ¶
func (c *CtrlSession) ForceClose() error
func (*CtrlSession) FullUsageHistory ¶
func (c *CtrlSession) FullUsageHistory()
func (*CtrlSession) GetConfigFullUsage ¶
func (c *CtrlSession) GetConfigFullUsage(confid int64) (bottype.FullUsage, sbox.Sboxstatus)
func (*CtrlSession) GetFullUsage ¶
func (c *CtrlSession) GetFullUsage() bottype.FullUsage
func (*CtrlSession) GetUsage ¶
func (c *CtrlSession) GetUsage() (C.Bwidth, C.Bwidth)
return current vpn usage, old usage from db total usage for now = vpn usage + old Every thing in byte format retur today, monthusage
func (*CtrlSession) GetUser ¶
func (c *CtrlSession) GetUser() *db.User
func (*CtrlSession) GetconfigQuota ¶
func (c *CtrlSession) GetconfigQuota(confid int64) C.Bwidth
func (*CtrlSession) GetconfigUsage ¶
returns today, month, usage as byte
func (*CtrlSession) GetconfigUsageTotal ¶
func (c *CtrlSession) GetconfigUsageTotal(confid int64) C.Bwidth
func (*CtrlSession) Getstatus ¶
func (c *CtrlSession) Getstatus(confid int64) (sbox.Sboxstatus, error)
func (*CtrlSession) LeftQuota ¶
func (c *CtrlSession) LeftQuota() C.Bwidth
this returns left quota for user userquota - quota elpsed for configs
func (*CtrlSession) LeftQuotaFromOrigin ¶
func (c *CtrlSession) LeftQuotaFromOrigin() C.Bwidth
this is special for gift command
func (*CtrlSession) LeftUsage ¶
func (c *CtrlSession) LeftUsage() C.Bwidth
func (*CtrlSession) ReActivateConfig ¶
func (c *CtrlSession) ReActivateConfig(confid int64) (sbox.Sboxstatus, error)
func (*CtrlSession) RemoveRestrict ¶
func (c *CtrlSession) RemoveRestrict()
func (*CtrlSession) Save ¶
func (c *CtrlSession) Save() error
func (*CtrlSession) SaveConfigs ¶
func (c *CtrlSession) SaveConfigs() error
func (*CtrlSession) TotalUsage ¶
func (c *CtrlSession) TotalUsage() C.Bwidth
return total usage for this month
type ForceCloser ¶
type ForceCloser interface {
ForceClose() error
}
type ForceResetUsage ¶
type ForceResetUsage uint16 //use to send Newrefresh signal wit force reset all usage database checkcount will reset
type Metadata ¶
type Metadata struct {
ChannelId int64
GroupID int64
//UserQuota C.Bwidth // Last calculated userquota should use with rwmutext
CommonQuota *atomic.Int64 // This is commonquota for all user userquota may vary to their settings
//Channelusercount *atomic.Int32
//Groupusercount *atomic.Int32
VerifiedUserCount *atomic.Int32
Maxconfigcount int16
Dbusercount *atomic.Int32
LoginLimit int32
BandwidthAvelable C.Bwidth
Inbounds []sbox.Inboud
Outbounds []sbox.Outbound
CheckCount *atomic.Int32
ResetCount int32 //static value that db should reset when checkcount eqal to this
RefreshRate int32
GroupLink string
Channelink string
Botlink string
GroupName string
ChannelName string
BotName string
DefaultDomain string
DefaultPubip string
MaxRecurtion int
SudoAdmin int64
ConfigFolder string
HelperInfo bottype.HelpCommandInfo
// contains filtered or unexported fields
}
func (*Metadata) ConfFolder ¶
func (*Metadata) GetInlinePost ¶
func (*Metadata) Getinbounds ¶
func (*Metadata) Getoutbounds ¶
func (*Metadata) Init ¶
func (m *Metadata) Init(metaconf MetadataConf) error
type MetadataConf ¶
type MetadataConf struct {
//ForceAdd bool `json:"forceAdd,omitempty"`
ChannelID int64 `json:"channel_id,omitempty"`
GroupID int64 `json:"groupd_id,omitempty"`
BandwidthAvelable string `json:"bandwidth,omitempty"`
LoginLimit int16 `json:"login_limit,omitempty"`
//Userquota int32 `json:"userquota,omitempty"`
//Verifiedcount int32 `json:"verifiedcount,omitempty"`
Maxconfigcount int16 `json:"max_config_count,omitempty"`
//CheckCount int32 `json:"checkcount,omitempty"` // database checked count for exting period
RefreshRate int32 `json:"refresh_rate,omitempty"` //rate of db refresh in hours
GroupLink string `json:"group_link,omitempty"`
Channelink string `json:"channel_link,omitempty"`
Botlink string `json:"bot_link,omitempty"`
GroupName string `json:"group_name,omitempty"`
ChannelName string `json:"channel_name,omitempty"`
BotName string `json:"bot_name,omitempty"`
//SudoAdminId int64 `json:"adminId,omitempty"`
//AllAdmin []int64 `json:"alladmin,omitempty"`
SudoAdmin int64 `json:"admin,omitempty"`
WatchMgbuf int `json:"group_maxmg,omitempty"`
DefaultDomain string `json:"default_domain,omitempty"`
DefaultPublicIp string `json:"default_publicip,omitempty"`
StorePath string `json:"store_path,omitempty"`
ConfigFolder string `json:"config_folder,omitempty"`
HelperInfo bottype.HelpCommandInfo `json:"help_cmd,omitempty"`
InlinePost []string `json:"inline_posts,omitempty"`
}
type RefreshSignal ¶
type RefreshSignal uint16 //use to send Newrefresh signal