Documentation ¶
Overview ¶
Copyright 2020 Alexey Yanchenko <mail@yanchenko.me>
This file is part of the Gufo library.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func AnsDef(i int)
- func AnsNo()
- func AskForConfigFile(i int)
- func CheckConfig()
- func CheckDBStructure()
- func CheckForFlags()
- func CheckForSign()
- func ConfigString(conf string) string
- func ConvertAnyToInterface(anyValue *anypb.Any) (interface{}, error)
- func ConvertInterfaceToAny(v interface{}) (*anypb.Any, error)
- func CreateConfig()
- func DBCheck() bool
- func DecryptConfigPasswords(pwd string) string
- func DelSession(sessionToken string)
- func DerefString(s *string) string
- func EncryptConfigPassword(pwd string) (string, error)
- func ErrorReturn(t *pb.Request, httpcode int, code string, message string) (response *pb.Response)
- func GRPCDelete(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCGen(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCGet(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCPatch(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCPost(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCPut(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCReq(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GRPCTrace(misroservice string, param string, paramid string, args map[string]interface{}, ...) map[string]interface{}
- func GenString(n int, alphanum string) string
- func GetLogDir() string
- func GetPass(conf string) string
- func HashConfigPasswords()
- func Hashgen(n int) string
- func InitCache()
- func Int32(v int) *int32
- func Interfacetoresponse(request *pb.Request, answer map[string]interface{}) (response *pb.Response)
- func JsonGet(url string, args map[string]interface{}, token string, tokentype string, ...) ([]byte, error)
- func JsonReq(url string, args map[string]interface{}, token string, tokentype string, ...) ([]byte, error)
- func Numgen(n int) string
- func Pad(src []byte) []byte
- func RandomString(l int) string
- func ReadUserIP(r *http.Request) string
- func SendHTMLEmail(to string, title string, link []string, subject string, templ string, ...)
- func SetErrorLog(value string)
- func SetLog(value string)
- func SetSession(name string, isAdmin int, completed int, readonly int) (sessionToken string, exptime int, err error)
- func Stringen(n int) string
- func ToMapStringAny(v map[string]interface{}) map[string]*anypb.Any
- func ToMapStringInterface(v map[string]*anypb.Any) map[string]interface{}
- func Unpad(src []byte) ([]byte, error)
- func UpdateSession(sessionToken string) map[string]interface{}
- func WriteLog(value string, p string)
- func WriteTokenInRedis(sessionToken string, uid string, isadmin int, completed int, exptime int, ...)
- type APITokens
- type DBv2
- type Entrypoint
- type ImpersonateTokens
- type MailRequest
- type MailSettings
- type Response
- type TimeHash
- type Users
Constants ¶
This section is empty.
Variables ¶
var AesKey = []byte("H4fnCsMf4vbE60nK")
AesKey is salt for pasword hash
var Configpath string = "/var/gufo/config/"
var DBConnectionv2 = &DBv2{}
Connection instance
Functions ¶
func AskForConfigFile ¶
func AskForConfigFile(i int)
func CheckConfig ¶
func CheckConfig()
CheckConfig() Check configuration file and stop app if config file mot foud or has errors
func CheckDBStructure ¶
func CheckDBStructure()
func CheckForFlags ¶
func CheckForFlags()
func CheckForSign ¶ added in v1.11.5
func CheckForSign()
CheckForSign - check Gufo Sign and if it missing, generate a sign. Sign need to connect to micoservices. By this Sign Microservices understand that requests are from one system
func ConfigString ¶
func ConvertAnyToInterface ¶
func ConvertInterfaceToAny ¶
func CreateConfig ¶
func CreateConfig()
func DecryptConfigPasswords ¶
DecryptConfigPasswords - Decrypt Hashed password in settings file to real password
func DelSession ¶
func DelSession(sessionToken string)
func DerefString ¶
func EncryptConfigPassword ¶
func ErrorReturn ¶ added in v1.11.5
func GRPCDelete ¶ added in v1.12.2
func HashConfigPasswords ¶
func HashConfigPasswords()
HashConfigPasswords - Change password in settings file to hash
func Interfacetoresponse ¶
func RandomString ¶
func ReadUserIP ¶
requestGetRemoteAddress returns ip address of the client making the request, taking into account http proxies
func SendHTMLEmail ¶
func SetErrorLog ¶
func SetErrorLog(value string)
func SetSession ¶
func ToMapStringInterface ¶
func UpdateSession ¶
Types ¶
type APITokens ¶
type APITokens struct { gorm.Model TokenId string `gorm:"column:tokenid;type:varchar(60);UNIQUE;NOT NULL;"` Token string `gorm:"column:token;type:varchar(254);UNIQUE;NOT NULL;"` TokenName string `gorm:"column:tokenname;type:varchar(60);DEFAULT '';"` UID string `gorm:"column:uid;type:varchar(60);NOT NULL;"` Created int `gorm:"column:created;type:int;DEFAULT '0'"` Expiration int `gorm:"column:expiration;type:int;DEFAULT '0'"` //if 0 - no expiration time Status bool `gorm:"column:status;type:bool;DEFAULT 'true'"` // if true - active, if false - deactivated IsAdmin bool `gorm:"column:is_admin;type:bool;DEFAULT 'false'"` //only if generated by admin Readonly bool `gorm:"column:readonly;type:bool;DEFAULT 'false'"` Comment string `gorm:"column:comment;type:varchar(60);DEFAULT '';"` }
type DBv2 ¶
func DBConnectv2 ¶
type Entrypoint ¶
type ImpersonateTokens ¶
type ImpersonateTokens struct { gorm.Model TokenId string `gorm:"column:tokenid;type:varchar(60);UNIQUE;NOT NULL;"` Token string `gorm:"column:token;type:varchar(254);UNIQUE;NOT NULL;"` UID string `gorm:"column:uid;type:varchar(60);NOT NULL;"` Created int `gorm:"column:created;type:int;DEFAULT '0'"` CreatedBy string `gorm:"column:createdby;type:varchar(254);DEFAULT '';"` }
type MailRequest ¶
type MailRequest struct {
// contains filtered or unexported fields
}
Request struct
func NewRequest ¶
func NewRequest(to []string, subject, body string, attach []string) *MailRequest
func (*MailRequest) ParseTemplate ¶
func (r *MailRequest) ParseTemplate(templateFileName string, data interface{}) error
func (*MailRequest) SendEmail ¶
func (r *MailRequest) SendEmail(ms *MailSettings) (bool, error)
type MailSettings ¶
type TimeHash ¶
type TimeHash struct { gorm.Model UID string `gorm:"column:uid;type:varchar(60);NOT NULL;"` Mail string `gorm:"column:mail;type:varchar(254);DEFAULT '';"` Hash string `gorm:"column:hash;type:varchar(254);DEFAULT '';"` Param string `gorm:"column:param;type:varchar(254);DEFAULT '';"` Created int `gorm:"column:created;type:int;DEFAULT '0'"` Livetime int `gorm:"column:livetime;type:int;DEFAULT '0'"` }
type Roles struct { gorm.Model UID string `gorm:"type:varchar(60);UNIQUE;NOT NULL;"` Admin bool `gorm:"type:double;DEFAULT 'false'"` }
type Settings struct { gorm.Model Email_Confirmation bool `gorm:"type:double;DEFAULT 'false'"` Registration bool `gorm:"type:double;DEFAULT 'false'"` }
Timehash table structure: Uid - users hash email - users email hash - 64 hash param - Which function create this record. We need confirm email in signup and change current password created - Where does record was created livetime - hash life time
type Users ¶
type Users struct { gorm.Model UID string `gorm:"column:uid;type:varchar(60);UNIQUE;NOT NULL;"` Name string `gorm:"column:name;type:varchar(60);NOT NULL;DEFAULT '';UNIQUE"` Pass string `gorm:"column:pass;type:varchar(128);NOT NULL;DEFAULT ''"` Mail string `gorm:"column:mail;type:varchar(254);DEFAULT '';UNIQUE"` Mailsent int `gorm:"column:mailsent;type:int;DEFAULT '0'"` Mailconfirmed int `gorm:"column:mailconfirmed;:int;DEFAULT '0'"` Created int `gorm:"column:created;type:int;DEFAULT '0'"` Access int `gorm:"column:access;type:int;DEFAULT '0'"` Login int `gorm:"column:login;type:int;DEFAULT '0'"` Status bool `gorm:"column:status;type:bool;DEFAULT 'false'"` Completed bool `gorm:"column:completed;type:bool;DEFAULT 'false'"` IsAdmin bool `gorm:"column:is_admin;type:bool;DEFAULT 'false'"` Readonly bool `gorm:"column:readonly;type:bool;DEFAULT 'false'"` }