common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: GPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	WhitelabelName    = "reVisit server"
	WhitelabelVersion = "0.7"

	CodeLength     = 64 //длина code
	PasswordLength = 14

	VNCFileList = "vnc.json"

	MaxLengthIDLog        = 6
	MaxLengthIDNode       = 8
	LengthSalt            = 16
	LengthToken           = 32
	WebSessionTimeoutHour = 2
	PredefinedPass        = "0000"
	UriServiceIpIFY       = "https://api.ipify.org/"
	UriYandexMap          = "https://api.lbs.yandex.net/geolocation"
	ReqYandexMap          = `{"common": {"version": "1.0","api_key": "%s"},"ip": {"address_v4": "%s"}}`

	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 = "options.json"

	ModeRegular = 0
	ModeMaster  = 1
	ModeNode    = 2

	CountersFilename = "counters.json"
	LogName          = "log.txt"

	WaitCount        = 50
	WaitIdle         = 500
	WaitAfterConnect = 250
	WaitHelperCycle  = 5
	WaitPing         = 10
	WaitIdleAgent    = 2
	WaitConnection   = 30
	WriteTimeout     = 13

	ProfilesFilename = "profiles.json"
)

Variables

View Source
var (
	Options = options{
		MainServerPort:                "65471",
		DataServerPort:                "65475",
		HttpServerEnabled:             true,
		HttpServerPort:                "8090",
		HttpsServerEnabled:            false,
		HttpsServerPort:               "8091",
		HttpsCertPath:                 "cert.pem",
		HttpsKeyPath:                  "key.pem",
		SizeBuff:                      16000,
		AdminLogin:                    "admin",
		AdminPass:                     "admin",
		Mode:                          ModeRegular,
		MyCoordinates:                 [2]float64{0, 0},
		MasterServer:                  "data.rvisit.net",
		MasterPort:                    "65470",
		MasterPassword:                "master",
		LogLevel:                      log.DebugLevel,
		IpCoordinateCacheTimeoutHours: 48,
	}
)

Functions

func AddCounter

func AddCounter(bytes uint64)

func CleanOldCacheCoordinates

func CleanOldCacheCoordinates()

func CleanPid

func CleanPid(pid string) string

func CloseLogFile

func CloseLogFile()

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 LoadFile

func LoadFile(name string, data interface{}) error

func LoadOptions

func LoadOptions()

func RandInt

func RandInt(min int, max int) int

func RandomString

func RandomString(l int) string

func ReOpenLogFile

func ReOpenLogFile()

func RotateLogFiles

func RotateLogFiles()

func SaveCounters

func SaveCounters()

func SaveFile

func SaveFile(name string, data interface{}) error

func SaveOptions

func SaveOptions()

func SendEmail

func SendEmail(to, subject, 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
}

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

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