core

package
v0.0.0-...-7873db6 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelValue

func DelValue(key string) error

DelValue 删除值

func GetValue

func GetValue(key string) (string, error)

GetValue 获取leveldb值

func GetValueJSON

func GetValueJSON(key string) (string, error)

GetValueJSON 从json文件读取

func Save

func Save(config *ServerConfig, path string) bool

Save 保存服务端配置文件

func SetValue

func SetValue(key string, value string) error

SetValue 设置leveldb值 admin的密码是保存在leveldb中

func SetValueJSON

func SetValueJSON(key string, value string) error

SetValueJSON 设置json文件

func WriteDomain

func WriteDomain(domain string) bool

WriteDomain 写域名

func WriteLogLevel

func WriteLogLevel(level string) bool

WriteLogLevel 写日志等级

func WriteTls

func WriteTls(cert, key, domain string) bool

WriteTls 写tls配置

Types

type CertificateConfig

type CertificateConfig struct {
	CertificateFile string `json:"certificateFile"`
	KeyFile         string `json:"keyFile"`
}

CertificateConfig 结构体

type InBoundConfig

type InBoundConfig struct {
	OutBoundConfig
	Port           int                        `json:"port"`
	Settings       InBoundSettingConfig       `json:"settings"`
	StreamSettings InBoundStreamSettingConfig `json:"streamSettings"`
}

InBoundConfig 结构体

type InBoundSettingClientConfig

type InBoundSettingClientConfig struct {
	Id       string `json:"id"`
	Flow     string `json:"flow"`
	Password string `json:"password"`
	Level    int    `json:"level"`
	Email    string `json:"email"`
}

InBoundSettingClientConfig 结构体

type InBoundSettingConfig

type InBoundSettingConfig struct {
	Clients    []InBoundSettingClientConfig   `json:"clients"`
	Decryption string                         `json:"decryption"`
	Fallbacks  []InBoundSettingFallbackConfig `json:"fallbacks"`
}

InBoundSettingConfig 结构体

type InBoundSettingFallbackConfig

type InBoundSettingFallbackConfig struct {
	Path string `json:"path"`
	Xver int    `json:"xver"`
	Dest int    `json:"dest"`
}

InBoundSettingFallbackConfig 结构体

type InBoundStreamSettingConfig

type InBoundStreamSettingConfig struct {
	Network      string            `json:"network"`
	Security     string            `json:"security"`
	XtlsSettings XtlsSettingConfig `json:"xtlsSettings"`
	TcpSettings  TcpSettingConfig  `json:"tcpSettings"`
	WsSettings   WsSettingConfig   `json:"wsSettings"`
}

InBoundStreamSettingConfig 结构体

type LogLevel

type LogLevel struct {
	LogLevel string `json: "loglevel"`
}

LogLevel 结构体

type LoginInfo

type LoginInfo struct {
	Username string `json: "username"`
	Password string `json: "password"`
}

LoginInfo Only for Admin to store its information

type OutBoundConfig

type OutBoundConfig struct {
	Protocol string `json:"protocol"`
}

OutBoundConfig 结构体

type PageQueryUser

type PageQueryUser struct {
	PageNum  int
	CurPage  int
	Total    int
	PageSize int
	DataList []*User
}

PageQueryUser 分页查询

type SSL

type SSL struct {
	Cert          string   `json:"cert"`
	Cipher        string   `json:"cipher"`
	CipherTls13   string   `json:"cipher_tls13"`
	Alpn          []string `json:"alpn"`
	ReuseSession  bool     `json:"reuse_session"`
	SessionTicket bool     `json:"session_ticket"`
	Curves        string   `json:"curves"`
	Sni           string   `json:"sni"`
}

SSL 结构体

type ServerConfig

type ServerConfig struct{}

ServerConfig 服务器结构体定义

func Load

func Load(path string) *ServerConfig

Load 加载服务端配置文件

type Sqlite

type Sqlite struct {
	Path string `json:"path"`
}

Sqlite 结构体

func NewSqlite

func NewSqlite(path string) *Sqlite

NewSqlite constructor 模拟面向对象编程的New函数

func (*Sqlite) Connect

func (s *Sqlite) Connect() *gorm.DB

Connect Sqlite的连接方法,默认从Path中读取数据库地址

func (*Sqlite) CreateUserORM

func (s *Sqlite) CreateUserORM(id string, username string, password string) error

CreateUserORM 使用给定信息创建成员

func (*Sqlite) DeleteUserORM

func (s *Sqlite) DeleteUserORM(id string) error

DeleteUserORM 使用给定信息删除用户

func (*Sqlite) HasDuplicateUserORM

func (s *Sqlite) HasDuplicateUserORM(username, password string) bool

HasDuplicateUserORM 检查是否重复密码和用户名

func (*Sqlite) PageQueryUsersORM

func (s *Sqlite) PageQueryUsersORM(curPage int, pageSize int) (*PageQueryUser, error)

PageQueryUsersORM 分页查询用户信息

func (*Sqlite) QueryUserORM

func (s *Sqlite) QueryUserORM(id string) (*User, error)

QueryUserORM 用id查询数据

func (*Sqlite) QueryUsersORM

func (s *Sqlite) QueryUsersORM(ids ...string) ([]*User, error)

QueryUsersORM 根据指定多个id获取用户记录

func (*Sqlite) QueryUsersWithInterface

func (s *Sqlite) QueryUsersWithInterface(cond map[string]interface{}) ([]*User, error)

QueryUsersWithInterface 根据map[string]interface{}获取用户记录 [Map] db.Where(map[string]interface{}{"name": "jinzhu", "age": 20}).Find(&users) SELECT * FROM users WHERE name = "jinzhu" AND age = 20;

func (*Sqlite) QueryUsersWithStructORM

func (s *Sqlite) QueryUsersWithStructORM(cond *User) ([]*User, error)

QueryUsersWithStructORM 根据Struct User获取用户记录 用户结构体查询是,会忽略空值、零值和假值 [Struct] db.Where(&User{Name: "jinzhu", Age: 20}).First(&user) SELECT * FROM users WHERE name = "jinzhu" AND age = 20 ORDER BY id LIMIT 1; [Slice of primary keys] db.Where([]int64{20, 21, 22}).Find(&users) SELECT * FROM users WHERE id IN (20, 21, 22);

func (*Sqlite) UpdateUserByIdORM

func (s *Sqlite) UpdateUserByIdORM(id string, data *User) error

UpdateUserByIdORM 使用给定信息更新用户名和密码

func (*Sqlite) UpdateUserCondORM

func (s *Sqlite) UpdateUserCondORM(cond *User, data *User) error

UpdateUserCondORM 使用给定信息更新用户名和密码 FIXED Do not use pointer, because User Struct Not initialized

func (*Sqlite) UpdateUserORM

func (s *Sqlite) UpdateUserORM(id string, username string, password string) error

UpdateUserORM 使用给定信息更新用户名和密码

type TCP

type TCP struct {
	NoDelay      bool `json:"no_delay"`
	KeepAlive    bool `json:"keep_alive"`
	ReusePort    bool `json:"reuse_port"`
	FastOpen     bool `json:"fast_open"`
	FastOpenQlen int  `json:"fast_open_qlen"`
}

TCP 结构体

type TcpSettingConfig

type TcpSettingConfig struct {
	AcceptProxyProtocol bool `json:"acceptProxyProtocol"`
	Header              struct {
		Type    string `json:"type"`
		Request struct {
			Path []string `json:"path"`
		} `json:"request"`
	} `json:"header"`
}

TcpSettingConfig 结构体

type TrojanConfig

type TrojanConfig struct {
	RunType    string   `json:"run_type"`
	LocalAddr  string   `json:"local_addr"`
	LocalPort  int      `json:"local_port"`
	RemoteAddr string   `json:"remote_addr"`
	RemotePort int      `json:"remote_port"`
	Password   []string `json:"password"`
	LogLevel   int      `json:"log_level"`
}

TrojanConfig struct

type User

type User struct {
	gorm.Model
	ID           uint `gorm:"primarykey"`
	Username     string
	Password     string
	PasswordShow string
	Level        string
	Email        string
	Quota        int64
	Download     uint64
	Upload       uint64
	UseDays      uint
	ExpiryDate   string
}

User Model

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate 创建前hook

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) (err error)

BeforeSave 保存前hook

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(tx *gorm.DB) (err error)

BeforeUpdate 更新前hook

type WsSettingConfig

type WsSettingConfig struct {
	Path string `json:"path"`
}

type XrayConfig

type XrayConfig struct {
	Log       LogLevel         `json:"log"`
	Inbounds  []InBoundConfig  `json:"inbounds"`
	Outbounds []OutBoundConfig `json:"outbounds"`
}

XrayConfig 结构体

type XtlsSettingConfig

type XtlsSettingConfig struct {
	Alpn         []string            `json:"alpn"`
	Certificates []CertificateConfig `json:"certificates"`
}

XtlsSettingConfig 结构体

Jump to

Keyboard shortcuts

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