xray

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XrayAPITag         = "api"
	XraySSProxyTag     = "ss_proxy"
	XrayTrojanProxyTag = "trojan_proxy"

	SyncTime = 60
)

Variables

This section is empty.

Functions

func AddInboundUser

func AddInboundUser(ctx context.Context, c proxy.HandlerServiceClient, tag string, user *User) error

AddInboundUser add user to inbound by tag

func RemoveInboundUser

func RemoveInboundUser(ctx context.Context, c proxy.HandlerServiceClient, tag string, user *User) error

RemoveInboundUser remove user from inbound by tag

func StartSyncTask

func StartSyncTask(ctx context.Context, cfg *config.Config) error

func StartXrayServer

func StartXrayServer(ctx context.Context, cfg *config.Config) (*core.Instance, error)

Types

type SyncTrafficReq

type SyncTrafficReq struct {
	Data []*UserTraffic `json:"data"`
}

type SyncUserConfigsResp

type SyncUserConfigsResp struct {
	Users []*User `json:"users"`
}

type User

type User struct {
	ID       int    `json:"user_id"`
	Method   string `json:"method"`
	Password string `json:"password"`

	Level           int   `json:"level"`
	Enable          bool  `json:"enable"`
	UploadTraffic   int64 `json:"upload_traffic"`
	DownloadTraffic int64 `json:"download_traffic"`

	Protocol string `json:"protocol"`
	// contains filtered or unexported fields
}

func (*User) Equal

func (u *User) Equal(new *User) bool

func (*User) GenTraffic

func (u *User) GenTraffic() *UserTraffic

func (*User) GetEmail

func (u *User) GetEmail() string

NOTE we user user id as email

func (*User) ResetTraffic

func (u *User) ResetTraffic()

func (*User) ToXrayUser

func (u *User) ToXrayUser() *protocol.User

func (*User) UpdateFromServer

func (u *User) UpdateFromServer(serverSideUser *User)

type UserPool

type UserPool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UserPool user pool

func NewUserPool

func NewUserPool(ctx context.Context, xrayEndPoint string) (*UserPool, error)

NewUserPool New UserPool

func (*UserPool) CreateUser

func (up *UserPool) CreateUser(userId, level int, password, method, protocol string, enable bool) *User

func (*UserPool) GetAllUsers

func (up *UserPool) GetAllUsers() []*User

func (*UserPool) GetUser

func (up *UserPool) GetUser(id int) (*User, bool)

func (*UserPool) RemoveUser

func (up *UserPool) RemoveUser(id int)

func (*UserPool) StartSyncUserTask

func (up *UserPool) StartSyncUserTask(ctx context.Context, endpoint, tag string)

type UserTraffic

type UserTraffic struct {
	ID              int      `json:"user_id"`
	UploadTraffic   int64    `json:"upload_traffic"`
	DownloadTraffic int64    `json:"download_traffic"`
	IPList          []string `json:"ip_list"`
	TcpCount        int64    `json:"tcp_conn_num"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL