common

package
v0.0.0-...-3812866 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Salt = 11
)

Variables

This section is empty.

Functions

func AccessAuth

func AccessAuth(c iris.Context)

func FtpListAll

func FtpListAll(cfg *Config, folder string) (interface{}, error)

func FtpWriteImage

func FtpWriteImage(cfg *Config, folder string, data string) (string, error)

func FtpWriteText

func FtpWriteText(cfg *Config, folder string, data string) (string, error)

func GenRSA

func GenRSA(bits int) (*rsa.PrivateKey, error)

GenRSA method

func GenerateSmartID

func GenerateSmartID(systemCode int, nodeCode int, size int) (id uint64, err error)

GenerateSmartID function Generate an account id base in Luhn algorithm

func Hash

func Hash(password string, salt int) (string, error)

Hash method

func LuhnValidate

func LuhnValidate(luhnString string) bool

LuhnValidate function to check luhn string

func PasswordCompare

func PasswordCompare(rawPassword string, passwordHash string, salt int) bool

PasswordCompare method

func PreFlight

func PreFlight(c iris.Context)

func ReadPrivateKey

func ReadPrivateKey(file string) (*rsa.PrivateKey, error)

func ReadPublicKey

func ReadPublicKey(file string) (*rsa.PublicKey, error)

func ReadTemplate

func ReadTemplate(file string) (string, error)

func RsaConfigSetup

func RsaConfigSetup(rsaPrivateKeyLocation, rsaPrivateKeyPassword string, rsaPublicKeyLocation string) (*rsa.PrivateKey, error)

RsaConfigSetup method

func ValidateUsername

func ValidateUsername(username string) (int, error)

Types

type Auth

type Auth struct {
	Token  string
	IsAuth bool
}

func (*Auth) Check

func (a *Auth) Check() bool

type CfgDb

type CfgDb struct {
	Postgre *CfgPg  `yaml:"Postgre"`
	Redis   *CfgRd  `yaml:"Redis"`
	Mongo   *CfgMg  `yaml:"Mongo"`
	FTP     *CfgFTP `yaml:"FTP"`
}

type CfgFTP

type CfgFTP struct {
	Host     string `yaml:"Host"`
	Port     int    `yaml:"Port"`
	Volume   string `yaml:"Volume"`
	Username string `yaml:"Username"`
	Password string `yaml:"Password"`
}

type CfgMg

type CfgMg struct {
	Host     string `yaml:"Host"`
	Port     int    `yaml:"Port"`
	Database string `yaml:"Database"`
	Username string `yaml:"Username"`
	Password string `yaml:"Password"`
	Auth     string `yaml:"Auth"`
}

type CfgPg

type CfgPg struct {
	Host     string `yaml:"Host"`
	Port     int    `yaml:"Port"`
	Username string `yaml:"Username"`
	Password string `yaml:"Password"`
	DbName   string `yaml:"DbName"`
	Schema   string `yaml:"Schema"`
}

type CfgRd

type CfgRd struct {
	Host     string `yaml:"Host"`
	Port     int    `yaml:"Port"`
	Database string `yaml:"Database"`
	Password string `yaml:"Password"`
}

type Config

type Config struct {
	Database *CfgDb   `yaml:"Database"`
	Service  *Service `yaml:"Service"`
	Option   *Option  `yaml:"Option"`
	SmsIris  IRIS     `yaml:"SmsIris"`
}

func LoadConfig

func LoadConfig(cfgPath string) (*Config, error)

type Context

type Context struct {
	Ctx    iris.Context
	Secure bool
}

Context struct for Route

func (*Context) BeginRequest

func (c *Context) BeginRequest(ctx iris.Context)

BeginRequest method

func (*Context) EndRequest

func (c *Context) EndRequest(ctx iris.Context)

func (*Context) Request

func (c *Context) Request(cnt iris.Context)

Request before

func (*Context) Response

func (c *Context) Response(code int, msg string, d interface{})

Response method

type IRIS

type IRIS struct {
	Host         string `yaml:"Host"`
	SignInRoute  string `yaml:"SignInRoute"`
	SendSmsRoute string `yaml:"SendSmsRoute"`
	Username     string `yaml:"Username"`
	Password     string `yaml:"Password"`
	Brandname    string `yaml:"Brandname"`
}

type MailSender

type MailSender struct {
	Server   string `yaml:"Server"`
	Port     int    `yaml:"Port"`
	Email    string `yaml:"Email"`
	Password string `yaml:"Password"`
}

type Option

type Option struct {
	SmsUrl           string      `yaml:"SmsUrl"`
	SmsApiToken      string      `yaml:"SmsApiToken"`
	FireBaseUrl      string      `yaml:"FireBaseUrl"`
	FireBaseToken    string      `yaml:"FireBaseToken"`
	EmailSender      *MailSender `yaml:"EmailSender"`
	ActivateURL      string      `yaml:"ActivateURL"`
	UpdateContactURL string      `yaml:"UpdateContactURL"`
}

type OtpModel

type OtpModel struct {
	ID     string        `json:"id"`
	Mobile string        `json:"mobile"`
	TTL    time.Duration `json:"ttl"`
}

func GenerateOTP

func GenerateOTP(mobile string, size int, ttl time.Duration) *OtpModel

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request struct

func NewRequest

func NewRequest(to []string, subject, body string, host string, sender string, auth smtp.Auth) *Request

func (*Request) ParseTemplate

func (r *Request) ParseTemplate(templateFileName string, data interface{}) error

func (*Request) SendEmail

func (r *Request) SendEmail() (bool, error)

type Result

type Result struct {
	System      string      `json:"system"`
	Version     string      `json:"version"`
	RequestTime int64       `json:"request_time"`
	Code        int         `json:"result_code"`
	Message     string      `json:"message"`
	Data        interface{} `json:"data"`
}

Result Struct for return

type Service

type Service struct {
	Host       string `yaml:"Host"`
	Port       int    `yaml:"Port"`
	SSL        bool   `yaml:"SSL"`
	PrivateKey string `yaml:"PrivateKey"`
	PublicKey  string `yaml:"PublicKey"`
}

type TokenClaims

type TokenClaims struct {
	Usr string        `json:"usr"`
	Iss string        `json:"iss"`
	Act string        `json:"act"`
	Sid uint64        `json:"sid"`
	Jit string        `json:"jit"`
	Iat time.Duration `json:"iat"`
	Exp time.Duration `json:"exp"`
	Sys string        `json:"sys"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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