xray

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XrayAPITag         = "api"
	XraySSProxyTag     = "ss_proxy"
	XrayTrojanProxyTag = "trojan_proxy"
	XrayVmessProxyTag  = "vmess_proxy"
	XrayVlessProxyTag  = "vless_proxy"
	XraySSRProxyTag    = "ssr_proxy"

	SyncTime = 60

	ProtocolSS     = "ss"
	ProtocolTrojan = "trojan"
)

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 InProxyTags added in v1.1.3

func InProxyTags(tag string) bool

func NewBandwidthRecorder added in v1.1.3

func NewBandwidthRecorder(metricsURL string) *bandwidthRecorder

func PrettyByteSize added in v1.1.3

func PrettyByteSize(bf float64) string

func RemoveInboundUser

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

RemoveInboundUser remove user from inbound by tag

Types

type SyncTrafficReq

type SyncTrafficReq struct {
	Data              []*UserTraffic `json:"data"`
	UploadBandwidth   int64          `json:"upload_bandwidth"`
	DownloadBandwidth int64          `json:"download_bandwidth"`
}

func (*SyncTrafficReq) GetTotalTraffic added in v1.1.3

func (s *SyncTrafficReq) GetTotalTraffic() int64

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 use 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
}

func NewUserPool

func NewUserPool(grpcEndPoint, remoteConfigURL, metricURL string, proxyTags []string) *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) Start added in v1.1.3

func (up *UserPool) Start(ctx context.Context) error

func (*UserPool) Stop added in v1.1.3

func (up *UserPool) Stop()

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"`
}

type XrayServer added in v1.1.3

type XrayServer struct {
	// contains filtered or unexported fields
}

func NewXrayServer added in v1.1.3

func NewXrayServer(cfg *config.Config) *XrayServer

func (*XrayServer) Reload added in v1.1.3

func (xs *XrayServer) Reload() error

func (*XrayServer) Setup added in v1.1.3

func (xs *XrayServer) Setup() error

func (*XrayServer) Start added in v1.1.3

func (xs *XrayServer) Start(ctx context.Context) error

func (*XrayServer) Stop added in v1.1.3

func (xs *XrayServer) Stop()

Jump to

Keyboard shortcuts

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