scat

package
v0.0.0-...-6696603 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Abills

type Abills struct {
	DB *sqlx.DB
}

type AbillsTariff

type AbillsTariff struct {
	ID       int    `db:"tp_id"`
	InSpeed  int    `db:"in_speed"`
	OutSpeed int    `db:"out_speed"`
	Name     string `db:"name"`
}

type AbillsUser

type AbillsUser struct {
	UID      string          `db:"uid"`
	TPID     int             `db:"tp_id"`
	IP       string          `db:"ip"`
	SpeedIn  int             `db:"in_speed"`
	SpeedOut int             `db:"out_speed"`
	Deposit  float32         `db:"deposit"`
	CCredit  sql.NullFloat64 `db:"ccredit"`
	UCredit  float64         `db:"ucredit"`
	CID      string          `db:"cid"`
	CalcInet bool            `db:"-"`
}

type App

type App struct {
	Abills *Abills
	Nases  []*Nas
}

App is the main application struct

func NewApp

func NewApp(conf Config) (*App, error)

func (*App) AddTariff

func (a *App) AddTariff(in, out int)

func (*App) GetTarifsFromAbills

func (a *App) GetTarifsFromAbills() (tarifs []TariffProfile, err error)

func (App) GetUserList

func (a App) GetUserList() ([]AbillsUser, error)

type Config

type Config struct {
	AbillsDB      string      `toml:"db"`
	AbillsBDNames string      `toml:"dbnames"`
	NasKeyFile    string      `toml:"keyfile"`
	DaemonMode    bool        `toml:"daemon"`
	Nases         []ConfigNas `toml:"nases"`
	SyncSpeed     bool        `toml:"-" flag:"syncspeed"`
}

type ConfigNas

type ConfigNas struct {
	Host string   `toml:"host"`
	User string   `toml:"user"`
	Nets []string `toml:"nets"`
	Key  string   `toml:"keyfile"`
}

type Nas

type Nas struct {
	Host string
	SSH  *ssh.Client
}

func NewNas

func NewNas(host, user string, key []byte) (*Nas, error)

func (*Nas) GetUserCGNat

func (n *Nas) GetUserCGNat() (users map[string]bool, err error)

GetUserCGNat fdpi_ctrl list all --policing показывает список пользователей и их скорости

func (*Nas) GetUserList

func (n *Nas) GetUserList() (users []ShortScatUser, err error)

GetUserList returns a list of users from the NAS

func (*Nas) GetUserProfilesList

func (n *Nas) GetUserProfilesList() (users []ScatUser, err error)

GetUserProfilesList fdpi_ctrl list all --policing показывает список пользователей и их скорости

func (*Nas) Run

func (n *Nas) Run(cmd string) (string, error)

func (*Nas) SetTariffProfile

func (n *Nas) SetTariffProfile(tp []TariffProfile) error

type ScatUser

type ScatUser struct {
	ID     string
	IP     string
	TPID   string
	TPName string
	KV     map[string]string
}

type ShortScatUser

type ShortScatUser struct {
	ID string
	IP string
}

type TariffProfile

type TariffProfile struct {
	Name     string         `json:"-"`
	Type     string         `json:"type"`
	Outbound TariffSubClass `json:"outbound"`
	Inbound  TariffSubClass `json:"inbound"`
}

TariffProfile is a struct that represents a tariff profile

type TariffRootClass

type TariffRootClass struct {
	Class int    `json:"class"`
	Rate  string `json:"rate"`
	Ceil  string `json:"ceil"`
}

TariffRootClass is a struct that represents a root class of a tariff

type TariffSubClass

type TariffSubClass struct {
	RootRate string            `json:"root_rate"`
	RootCeil string            `json:"root_ceil"`
	Classes  []TariffRootClass `json:"classes"`
}

TariffSubClass is a struct that represents a subclass of a tariff

Jump to

Keyboard shortcuts

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