common

package
v0.0.0-...-96cea24 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ReVisitVersion - версия сервера или ноды, пока не используется
	ReVisitVersion = "0.7"

	//общие константы
	CodeLength     = 64 //длина code
	PasswordLength = 14

	VNCFileList = "/opt/vnc.list"

	MaxLengthIDLog        = 6 //длина идентификатора потока для логов
	MaxLengthIDNode       = 8
	LengthSalt            = 16
	LengthToken           = 32
	WebSessionTimeoutHour = 2
	PredefinedPass        = "0000"
	UriServiceIpIFY       = "https://api.ipify.org/"
	UriYandexMap          = "http://api.lbs.yandex.net/geolocation"
	ReqYandexMap          = `` /* 326-byte string literal not displayed */

	//константы ограничений
	MinimalVersionForNodes       = 0.97
	MinimalVersionForStaticAlert = 0.98

	//статические сообщения
	StaticMessageEmpty         = 0
	StaticMessageNetworkError  = 1
	StaticMessageProxyError    = 2
	StaticMessageAuthError     = 3
	StaticMessageVncError      = 4
	StaticMessageTimeoutError  = 5
	StaticMessageAbsentError   = 6
	StaticMessageTypeError     = 7
	StaticMessageAuthFail      = 8
	StaticMessageRegFail       = 9
	StaticMessageRegMail       = 10
	StaticMessageRegSuccessful = 11

	FileOptions = "/opt/options.cfg"

	ModeRegular = 0
	ModeMaster  = 1
	ModeNode    = 2

	//виды сообщений логов
	MessError  = 1
	MessInfo   = 2
	MessDetail = 3
	MessFull   = 4

	CountersFilename = "/opt/counters.json"
	LogFilename      = "/opt/log.txt"
	LogSize          = 20 * 1024 * 1024 //20MB

	//константы ожидания
	WaitCount        = 50
	WaitIdle         = 500
	WaitAfterConnect = 250
	WaitHelperCycle  = 5
	WaitPing         = 10
	WaitIdleAgent    = 2
	WaitConnection   = 30

	ProfilesFilename = "/opt/profiles.list"
)

Variables

View Source
var (
	//опции по-умолчанию
	Options = options{
		MainServerPort:  "65471",
		DataServerPort:  "65475",
		HttpServerPort:  "8090",
		HttpsServerPort: "8091",
		HttpsCertPath:   "/opt/cert.pem",
		HttpsKeyPath:    "/opt/key.pem",
		SizeBuff:        16000,
		AdminLogin:      "admin",
		AdminPass:       "admin",
		Mode:            ModeRegular,
		MyCoordinates:   [2]float64{0, 0},
		DebugFlag:       true,
		MasterServer:    "localhost",
		MasterPort:      "65470",
		MasterPassword:  "master",
		LogLevel:        MessFull,
	}
)

Functions

func AddCounter

func AddCounter(bytes uint64)

func CleanPid

func CleanPid(pid string) string

func ClearLog

func ClearLog()

func GetCoordinatesByYandex

func GetCoordinatesByYandex(addr string) [2]float64

func GetCounterDay

func GetCounterDay() []string

func GetCounterDayWeek

func GetCounterDayWeek() []string

func GetCounterDayYear

func GetCounterDayYear() []string

func GetCounterHour

func GetCounterHour() []string

func GetCounterMonth

func GetCounterMonth() []string

func GetMyIp

func GetMyIp() string

func GetMyIpByExternalApi

func GetMyIpByExternalApi() string

func GetPid

func GetPid(serial string) string

func GetSHA256

func GetSHA256(str string) string

func LoadCounters

func LoadCounters()

func LoadOptions

func LoadOptions()

func LogAdd

func LogAdd(TMessage int, Messages string)

func RandInt

func RandInt(min int, max int) int

func RandomString

func RandomString(l int) string

func SaveCounters

func SaveCounters()

func SaveOptions

func SaveOptions()

func SendEmail

func SendEmail(to string, body string) (bool, error)

func SwiftCounter

func SwiftCounter()

func UpdateCounterClient

func UpdateCounterClient(adding bool)

Types

type VNC

type VNC struct {
	FileServer string
	FileClient string

	//это команды используем для старта под админскими правами(обычно это создание сервиса)
	CmdStartServer   string
	CmdStopServer    string
	CmdInstallServer string
	CmdRemoveServer  string
	CmdConfigServer  string
	CmdManageServer  string

	//это комнады используем для старта без админских прав
	CmdStartServerUser   string
	CmdStopServerUser    string
	CmdInstallServerUser string
	CmdRemoveServerUser  string
	CmdConfigServerUser  string
	CmdManageServerUser  string

	//комнды для vnc клиента
	CmdStartClient   string
	CmdStopClient    string
	CmdInstallClient string
	CmdRemoveClient  string
	CmdConfigClient  string
	CmdManageClient  string

	PortServerVNC string
	Link          string
	Name          string
	Version       string
	Description   string
}

информация о внц и основные команды для управления им

type YandexBody

type YandexBody struct {
	Latitude          float64 `json:"latitude"`
	Longitude         float64 `json:"longitude"`
	Altitude          float64 `json:"altitude"`
	Precision         float32 `json:"precision"`
	AltitudePrecision float32 `json:"altitude_precision"`
	Type              string  `json:"type"`
}

type YandexResp

type YandexResp struct {
	Position YandexBody `json:"position"`
}

Jump to

Keyboard shortcuts

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