ylf

package module
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

README

A library based on netlink encapsulation

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrimaryIndex string

主索引

Functions

func AddBridge added in v1.0.5

func AddBridge(bridgeName string) error

添加网桥

func AddDefaultRoute added in v1.0.5

func AddDefaultRoute(ppp string, gatewayIp string, tableId int) error

添加默认路由

func AddDns added in v1.0.5

func AddDns(src string, tableID int, fref int) error

添加DNS

func AddIpToEth added in v1.0.5

func AddIpToEth(eth string, ip string) error

给eth添加IP/子网掩码

func AddMacVLan added in v1.0.5

func AddMacVLan(devName string, parentDevName string, macAddr string) error

添加macVLan

func AddRule added in v1.0.5

func AddRule(src string, tableID int, fref int) error

添加策略

func ArrayMap added in v1.3.6

func ArrayMap(data interface{}, fc func(i int, row interface{}) interface{}) error

func BatchSetMacVlanAndPromisc added in v1.0.8

func BatchSetMacVlanAndPromisc(cmdString string) error

func BeachCheckPort added in v1.1.9

func BeachCheckPort(ip string, port int, useFulPort *chan int)

检测端口并写入数据到channel

func CheckPid added in v1.1.1

func CheckPid(pid interface{}) bool

func CheckPort added in v1.1.9

func CheckPort(ip string, port string) bool

检查端口是否开放

func Cors added in v1.0.3

func Cors() gin.HandlerFunc

中间件 默认开启

func CreateDb added in v1.0.4

func CreateDb(conn *sql.DB, dbName string) error

func CtrlC added in v1.4.1

func CtrlC(fc func(signalTag string))

func CurrentFile added in v1.1.8

func CurrentFile() string

func Daemon

func Daemon() int

开启守护进程

func DelRuleByTableId added in v1.0.5

func DelRuleByTableId(tableID int)

批量删除策略 根据策略表ID

func DeleteDev added in v1.0.5

func DeleteDev(name string) error

删除虚拟设备 网桥 vEth等

func ExpFind added in v1.1.0

func ExpFind(rule string, srcString string) string

func ExpFindLast added in v1.2.5

func ExpFindLast(rule string, srcString string) string

func GetConn added in v1.0.4

func GetConn(config string) (conn *sql.DB, err error)

func GetFileByPath added in v1.1.0

func GetFileByPath(path string) string

func GetIpByEth added in v1.1.3

func GetIpByEth(eth string) (string, error)

func GetMacByEth added in v1.0.5

func GetMacByEth(eth string) (string, error)

使用eth获取Mac地址

func GetRandMac added in v1.0.8

func GetRandMac() (mac string, err error)

获取随机MAC地址

func GetRandomString added in v1.0.8

func GetRandomString(l int) string

func GetUsablePpp added in v1.4.2

func GetUsablePpp() string

获取可用的PPP

func GetUsefulPort added in v1.1.9

func GetUsefulPort(ip string, startPort int, endPort int) int

获取一个 指定范围内的可用端口

func HasDb added in v1.0.4

func HasDb(conn *sql.DB, dbName string) error

func InSlice added in v1.0.6

func InSlice(slice []interface{}, value interface{}) bool

func KillPid

func KillPid(pid string) error

func Rand added in v1.0.8

func Rand() string

func RemoveRepeated added in v1.3.8

func RemoveRepeated(arr *[]string)

效率更高的去重函数 用法:RemoveRepeated(&noPassAccount)

func RemoveRepeatedElement added in v1.0.8

func RemoveRepeatedElement(arr []string) (newArr []string)

func RunCmd added in v1.2.3

func RunCmd(cmdString string, runFc RunFunc)

func STRUCToString added in v1.1.1

func STRUCToString(iFace interface{}) string

func SetBridgeAddr added in v1.0.5

func SetBridgeAddr(name string, ip string, tryTimes int) error

设置网桥地址并启用

func SetDeviceIP added in v1.0.5

func SetDeviceIP(name string, ip string) error

给设备或虚拟设备设置IP

func SetDeviceUP added in v1.0.5

func SetDeviceUP(devName string) error

启用设备

func SetPPPOE added in v1.0.5

func SetPPPOE(eth string, ruleTableID int) error

给PPPOE指定策略表

func SliceMap added in v1.0.5

func SliceMap(slice []interface{}, cb func(interface{}) interface{}) []interface{}

func Start

func Start(address string, debug string, route func(router *gin.Engine) gin.IRoutes)

func StartWatch added in v1.0.9

func StartWatch(path string, fs FsNotifyInterface)

func StopDaemon

func StopDaemon() error

结束守护进程

func StructureToString added in v1.0.5

func StructureToString(iFace interface{}) string

通过反射 结构体转字符串

func SyncDb added in v1.0.4

func SyncDb(conn *sql.DB, dbName string)

func Uuid added in v1.0.7

func Uuid() string

func WriteRtTable added in v1.0.5

func WriteRtTable(rtTables []RtTables) error

Types

type BlackListStructure added in v1.1.6

type BlackListStructure struct {
	ClientBlock string
}

type ConfFile added in v1.0.7

type ConfFile struct {
	FileName      string
	ConfFileArray []ConfFileMap
}

func (*ConfFile) BatchWriteAccount added in v1.0.7

func (c *ConfFile) BatchWriteAccount(account interface{}) bool

批量写入账户

func (*ConfFile) InitFile added in v1.0.7

func (c *ConfFile) InitFile(path string)

初始化并把配置文件读取到结构体内

func (*ConfFile) ReadAccount added in v1.0.7

func (c *ConfFile) ReadAccount(account string) map[string]string

读取某个指定账户

func (*ConfFile) WriteAccount added in v1.0.7

func (c *ConfFile) WriteAccount(account string, password string) bool

写入某个值到指定账户

type ConfFileMap added in v1.0.7

type ConfFileMap map[string]string

此包用于读取/设置宽带帐号密码 * demo myConfig := new(lib.ConfFile) myConfig.InitFile("./config.conf") account :=myConfig.ReadAccount("07557550897705@163.gd") myConfig.WriteAccount("07557550897705@163.gd","testPP") fmt.Println(account)

type Config

type Config struct {
	MyMap    map[string]string
	MyStr    string
	FileName string
}

func NewConfig

func NewConfig(fileName string) *Config

func (*Config) Get

func (c *Config) Get(data interface{}) error

func (*Config) InitConfig

func (c *Config) InitConfig(path string)

func (Config) Read

func (c Config) Read(node, key string) string

func (Config) ReadList

func (c Config) ReadList(node, key string) map[string]string

type DanteStructure added in v1.1.6

type DanteStructure struct {
	TemplatePath     string `description:模板路径`
	SavePath         string `description:设置的配置文件路径`
	Logoutput        string
	Privileged       string
	Unprivileged     string
	Interal          string
	Port             string
	External         string
	SocksMethod      string
	ClientMethod     string
	ClientPassSlice  []WhiteListStructure `description:白名单`
	ClientBlockSlice []BlackListStructure `description:黑名单`
}

func NewDante added in v1.1.6

func NewDante(templatePath ...string) *DanteStructure

初始化dante类,可以选择传递templatePath,也可以选择不传递

func (*DanteStructure) GetContent added in v1.1.6

func (d *DanteStructure) GetContent() (string, error)

返回配置文件的所有字符串

func (*DanteStructure) Save added in v1.1.6

func (d *DanteStructure) Save(account ...string) error

保存设置

func (*DanteStructure) SetBlackIp added in v1.1.6

func (d *DanteStructure) SetBlackIp(ip ...string) *DanteStructure

设置黑名单

func (*DanteStructure) SetBlackLimit added in v1.1.6

func (d *DanteStructure) SetBlackLimit(fromIp string, toIp string) *DanteStructure

限制用户访问特定的IP

func (*DanteStructure) SetClientMethod added in v1.1.6

func (d *DanteStructure) SetClientMethod(clientMethod string) *DanteStructure

设置客户端访问方法

func (*DanteStructure) SetExternal added in v1.1.6

func (d *DanteStructure) SetExternal(external string) *DanteStructure

设置外部IP或则对外的网卡

func (*DanteStructure) SetInteral added in v1.1.6

func (d *DanteStructure) SetInteral(interal string) *DanteStructure

设置拨号成功后的内部IP

func (*DanteStructure) SetLogoutput added in v1.1.6

func (d *DanteStructure) SetLogoutput(logoutput string) *DanteStructure

设置注销参数

func (*DanteStructure) SetPort added in v1.1.6

func (d *DanteStructure) SetPort(port string) *DanteStructure

设置拨号成功后的Port

func (*DanteStructure) SetPrivileged added in v1.1.6

func (d *DanteStructure) SetPrivileged(privileged string) *DanteStructure

设置特权账户,如:root

func (*DanteStructure) SetSavePath added in v1.1.6

func (d *DanteStructure) SetSavePath(path string) *DanteStructure

设置用户配置文件保存路径

func (*DanteStructure) SetSocksMethod added in v1.1.6

func (d *DanteStructure) SetSocksMethod(socksMethod string) *DanteStructure

设置socket对外访问限制方法

func (*DanteStructure) SetUnprivileged added in v1.1.6

func (d *DanteStructure) SetUnprivileged(unPrivileged string) *DanteStructure

设置没有特权的账户,如:nobody

func (*DanteStructure) SetWhiteIp added in v1.1.6

func (d *DanteStructure) SetWhiteIp(ip ...string) *DanteStructure

设置白名单

func (*DanteStructure) SetWhiteLimit added in v1.1.6

func (d *DanteStructure) SetWhiteLimit(fromIp string, toIp string) *DanteStructure

允许用户访问特定的IP

func (*DanteStructure) StartDante added in v1.1.6

func (d *DanteStructure) StartDante(
	danteConf string,
	host string,
	port int,
	userId int,
	mac string,
	times float64,
	fc func(host string, mac string, status string, resetUserId int) error,
	danteFc func(host string, port int, userId int, status string, macVLanMac string, pid string) error,
	reDialFc func(host string, macVLanOrMac string) (data struct {
		Pid         string
		MacVLan     string
		Ppp         string
		PppLocalIp  string
		PppRemoteIp string
		Dns1        string
		Dns2        string
		PppError    string
	}, err error)) *DanteStructure

启动dante服务

func (*DanteStructure) StopDante added in v1.1.6

func (d *DanteStructure) StopDante(host interface{}, mac interface{}) error

type FieldsAttr added in v1.0.4

type FieldsAttr struct {
	Type        string
	Json        string
	Auto        string
	Null        string
	Default     string
	Hidden      string
	UniqueIndex string
	Index       string
	Comment     string
}

数据迁移 字段属性

type FsNotifyInterface added in v1.0.9

type FsNotifyInterface interface {
	WriteEven(fileName string)
	CreateEven(fileName string)
	DeleteEven(fileName string)
	RenameEven(fileName string)
	ChmodEven(fileName string)
}

type Index added in v1.0.4

type Index struct {
	Name  string
	Index []string
}

普通索引

type MigrateStructure added in v1.0.4

type MigrateStructure struct {
	Field string
	FieldsAttr
}

数据迁移 数据行结构体

type MysqlStructure added in v1.0.4

type MysqlStructure struct {
	*sql.DB
	Host         string
	Port         string
	User         string
	Password     string
	Database     string
	SqlString    string
	Param        []interface{}
	Rows         *sql.Rows
	Err          error
	Transaction  *sql.Tx
	Fields       MigrateStructure
	TableAttr    TableAttr
	PrimaryIndex string
	UniqueIndex  []UniqueIndex
	Index        []Index
	Migrate      []MigrateStructure
}
var Mysql *MysqlStructure

func NewMysql added in v1.0.4

func NewMysql(host string, port string, user string, password string, db string) *MysqlStructure

func (*MysqlStructure) AutoMigrate added in v1.0.4

func (mysql *MysqlStructure) AutoMigrate(data ...interface{}) error

批量迁移数据表

func (*MysqlStructure) Begin added in v1.0.4

func (mysql *MysqlStructure) Begin() (err error)

开启事务

func (*MysqlStructure) ClearData added in v1.0.6

func (mysql *MysqlStructure) ClearData()

func (*MysqlStructure) Commit added in v1.0.4

func (mysql *MysqlStructure) Commit() error

提交事务

func (*MysqlStructure) Delete added in v1.0.4

func (mysql *MysqlStructure) Delete() (affected int64, err error)

func (*MysqlStructure) Exec added in v1.0.6

func (mysql *MysqlStructure) Exec() (result int64, err error)

func (*MysqlStructure) Find added in v1.0.4

func (mysql *MysqlStructure) Find(data interface{}) error

func (*MysqlStructure) GetIndexMap added in v1.0.6

func (mysql *MysqlStructure) GetIndexMap() map[string][]string

获取索引MAP

func (*MysqlStructure) GetStructureFields added in v1.0.4

func (mysql *MysqlStructure) GetStructureFields(data interface{}) error

处理结构体的字段 属性 TAG

func (*MysqlStructure) GetUniqueIndexMap added in v1.0.6

func (mysql *MysqlStructure) GetUniqueIndexMap() map[string][]string

获取索引MAP

func (*MysqlStructure) Insert added in v1.0.4

func (mysql *MysqlStructure) Insert() (lastId int64, err error)

func (*MysqlStructure) MigrateOne added in v1.0.6

func (mysql *MysqlStructure) MigrateOne(data interface{}) error

迁移单个数据表

func (*MysqlStructure) RollBack added in v1.0.4

func (mysql *MysqlStructure) RollBack() error

回滚事务

func (*MysqlStructure) SaveAll added in v1.0.6

func (mysql *MysqlStructure) SaveAll(data interface{}, fields ...interface{}) error

func (*MysqlStructure) Select added in v1.0.4

func (mysql *MysqlStructure) Select(data interface{}) error

func (*MysqlStructure) Sql added in v1.0.4

func (mysql *MysqlStructure) Sql(sql string, param ...interface{}) *MysqlStructure

func (*MysqlStructure) Update added in v1.0.4

func (mysql *MysqlStructure) Update() (affected int64, err error)

type PppLogInfo added in v1.1.0

type PppLogInfo struct {
	PppError string
	Ppp      string
	Local    string
	Remote   string
	Dns1     string
	Dns2     string
}

func GetLogIp added in v1.1.0

func GetLogIp(path string) (result PppLogInfo, err error)

func GetLogIp2 added in v1.2.4

func GetLogIp2(f string) (result PppLogInfo, err error)

type RtTables added in v1.1.1

type RtTables struct {
	TableId   string
	TableName string
}

func DeleteRtTableItem added in v1.1.1

func DeleteRtTableItem(tableName ...string) ([]RtTables, error)

func GetRtTableAll added in v1.1.1

func GetRtTableAll() ([]RtTables, error)

func SynRtTableItem added in v1.1.1

func SynRtTableItem(tableName ...string) ([]RtTables, map[string]int, error)

同步RT TABLE设置 存在则更新,不存在则新增

type RunFunc added in v1.2.3

type RunFunc func(pid int, content string)

type TableAttr added in v1.0.4

type TableAttr struct {
	ENGINE         string
	AUTO_INCREMENT string
	DEFAULT        string
}

数据迁移 表属性

type UniqueIndex added in v1.0.4

type UniqueIndex struct {
	Name  string
	Index []string
}

唯一索引

type WhiteListStructure added in v1.1.6

type WhiteListStructure struct {
	ClientPass string
}

Jump to

Keyboard shortcuts

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