Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyUserProxy(user User) error
- func GetUserProxyMessage(user User) string
- func InitDBwithFile(path string) error
- func InitV2rayService(inboundTag string, vmessPort, vmessClientPort int, ...) error
- func NewUUID() string
- func Restore() error
- func V2rayUpdateUserTraffic() error
- type GormDB
- type NamedTraffic
- type Proxy
- type SystemCtlService
- type TelegramAuthService
- type TrafficValue
- type User
- type UserManager
- type V2rayService
- type V2rayTrafficStat
Constants ¶
View Source
const UUIDLen = 36
Variables ¶
View Source
var VConfJson = template.Must(template.New("confjson").Parse(`
{
"add":"{{.Domain}}",
"aid":"0",
"host":"{{.Domain}}",
"id":"{{.ID}}",
"net":"ws",
"path":"{{.Path}}",
"port":"{{.Port}}",
"ps":"{{.Name}}",
"scy":"auto",
"sni":"{{.Domain}}",
"tls":"tls",
"type":"",
"v":"2"
}
`))
View Source
var VConfText = template.Must(template.New("conftext").Parse(`
协议类型: vmess
地址: {{.Domain}}
伪装域名/SNI: {{.Domain}}
端口: <code>{{.Port}}</code>
用户ID: <code>{{.ID}}</code>
安全: tls
传输方式: ws
路径: <code>{{.Path}}</code>
`))
Functions ¶
func ApplyUserProxy ¶
func GetUserProxyMessage ¶
func InitDBwithFile ¶
func InitV2rayService ¶
func V2rayUpdateUserTraffic ¶
func V2rayUpdateUserTraffic() error
Types ¶
type NamedTraffic ¶
type NamedTraffic struct { TrafficValue Name string }
func GetV2rayTraffic ¶
func GetV2rayTraffic() ([]NamedTraffic, error)
Get current traffic stats of all inbounds. Note that user stats is not correct due to V2rayUpdateUserTraffic
type Proxy ¶
type Proxy interface { // identify this proxy ProxyID() uint // apply this proxy Activate() error // remove this proxy Deactivate() error // introduce this proxy in telegram message Message() string }
describe a proxy config. Proxy can be store in sqldb
type SystemCtlService ¶
type SystemCtlService interface { StartV2rayServer() error StopV2rayServer() error RestartV2rayServer() error }
need implementation
type TelegramAuthService ¶
type TelegramAuthService interface { // 生成一个注册用的 token GenToken() (token string) // 使用 token 注册用户,注册失败(token不匹配)返回错误 Register(token string, tid int) (User, error) }
implemented by simpleTelegramAuthService
var AuthServiceInstance TelegramAuthService
type TrafficValue ¶
type User ¶
type User interface { TelegramID() int Name() string Proxy() []Proxy SetProxy(proxy []Proxy) error SetName(name string) error // total traffic stored Traffic() TrafficValue SetTraffic(val TrafficValue) error }
Interface for User. Typically implemented by UserManager.NewUser
type UserManager ¶
type UserManager interface { AddUser(user User) error SetUser(user User) error DeleteUser(user User) error // find user by id, nil for not found FindUserByTelegramID(tid int) (User, error) // find user by proxy id, nil for not found FindUserByProxy(proxyid uint) (User, error) // generate new user by id NewUser(tid int) User All() ([]User, error) }
implemented by simpleUserManager
var UserManagerInstance UserManager
type V2rayService ¶
type V2rayService interface { SetUser(email string, uuid string) error AddUser(email string) (uuid string, err error) // remove a user identified by email RemoveUser(email string) error QueryTraffic(pattern string, reset bool) (stat []V2rayTrafficStat, err error) // query traffic for user under control only QueryUserTraffic(reset bool) (stat []V2rayTrafficStat, err error) Start(listen string) error VmessText(vmessid string) string VmessLink(vmessid string) string NewProxy() Proxy AddVmessWsInbound(tag string, port uint16, wspath string) error RemoveInbound(tag string) error }
implemented by v2rayClient
var V2rayServiceInstance V2rayService
type V2rayTrafficStat ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.