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 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 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 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 ErrorMsg
- type ErrorResponse
- type ImpersonateTokens
- type MailRequest
- type MailSettings
- type Request
- type Response
- type SuccessResponse
- 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 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 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 ErrorResponse ¶
type ErrorResponse struct { Success int `json:"success"` Error []ErrorMsg `json:"error"` Session map[string]interface{} `json:"session"` TimeStamp int `json:"timestamp"` Language string `json:"lang"` }
Error response struct
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 Request ¶
type Request struct { Module string Param string ParamID string Action string Args map[string]interface{} `json:"args"` Token string Path string TokenType string TimeStamp int `json:"timestamp"` Language string `json:"lang"` APIVersion string Method string UID string IsAdmin int SessionEnd int Completed int Readonly int FileName string Chunk []byte FileSize uint32 }
Request struct
type SuccessResponse ¶
type SuccessResponse struct { Success int `json:"success"` Data map[string]interface{} `json:"data"` Session map[string]interface{} `json:"session"` TimeStamp int `json:"timestamp"` Language string `json:"lang"` }
Succsess response struct
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'"` }