Documentation ¶
Overview ¶
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later (depends on Go generics, available since go 1.18 but real stable since go 1.19)
Index ¶
- Constants
- Variables
- func AddCSlashes(s string, c string) string
- func AppGetNamespace() (string, error)
- func AppGetRunInBackground() bool
- func AppSetNamespace(ns string) bool
- func AppSetRunInBackground() bool
- func ArrMapKeyExists[E comparable](v E, arr map[E]E) bool
- func Auth2FACookieIsEnabled() bool
- func Auth2FACookieNameGet() string
- func Auth2FACookieNameSet(cookieName string) bool
- func AuthBasicIsEnabled() bool
- func AuthBasicModeSet(mode bool) bool
- func AuthBearerIsEnabled() bool
- func AuthBearerModeSet(mode bool) bool
- func AuthCookieIsEnabled() bool
- func AuthCookieNameGet() string
- func AuthCookieNameSet(cookieName string) bool
- func Base64Decode(data string) string
- func Base64Encode(data string) string
- func Base64ToBase64s(data string) string
- func Base64sDecode(data string) string
- func Base64sEncode(data string) string
- func Base64sToBase64(data string) string
- func BaseDecode(data string, fromBase string) []byte
- func BaseEncode(data []byte, toBase string) string
- func Bin2Hex(str string) string
- func BlowfishDecryptCBC(str string, key string) string
- func BlowfishEncryptCBC(str string, key string) string
- func CipherDecryptCBC(algo string, str string, key string, iv string, tweak string) (string, error)
- func CipherEncryptCBC(algo string, str string, key string, iv string, tweak string) (string, error)
- func ClearPrintTerminal()
- func ConvertFloat32ToStr(f float32) string
- func ConvertFloat64ToStr(f float64) string
- func ConvertInt16ToStr(i int16) string
- func ConvertInt32ToStr(i int32) string
- func ConvertInt64ToStr(i int64) string
- func ConvertInt8ToStr(i int8) string
- func ConvertIntToStr(i int) string
- func ConvertJsonNumberToStr(data interface{}) string
- func ConvertUInt16ToStr(i uint16) string
- func ConvertUInt32ToStr(i uint32) string
- func ConvertUInt64ToStr(i uint64) string
- func ConvertUInt8ToStr(i uint8) string
- func ConvertUIntToStr(i uint) string
- func Crc32b(str string) string
- func Crc32bB36(str string) string
- func CryptoGetSecurityKey() (string, error)
- func CryptoSetSecurityKey(key string) bool
- func CurrentFunctionName() string
- func DataArchive(str string) string
- func DataRRot13(s string) string
- func DataRot13(s string) string
- func DataUnArchive(str string) string
- func DateNowIsoLocal() string
- func DateNowIsoUtc() string
- func DateNowLocal() string
- func DateNowUtc() string
- func DateTimeGetLocation() string
- func DateTimeSetLocation(loc string) bool
- func DateTimeStructLocal(dateIsoStr string) uxmDateTimeStruct
- func DateTimeStructUtc(dateIsoStr string) uxmDateTimeStruct
- func EscapeCss(s string) string
- func EscapeHtml(s string) string
- func EscapeJs(in string) string
- func EscapeUrl(s string) string
- func EscapeXml(s string) string
- func ExecCmd(captureStdout string, captureStderr string, additionalEnv string, ...) (isSuccess bool, outStd string, errStd string)
- func ExecTimedCmd(stopTimeout uint, captureStdout string, captureStderr string, ...) (isSuccess bool, outStd string, errStd string)
- func Explode(delimiter string, text string) []string
- func ExplodeWithLimit(delimiter string, text string, limit int) []string
- func FatalError(logMessages ...any)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(n int) (string, error)
- func GenerateSSHKeyPairEd25519(comment string, password string) (error, string, string)
- func GetBaseDomainFromDomain(domain string) (string, error)
- func GetCookieDefaultDomain() string
- func GetCookieDefaultSameSitePolicy() string
- func GetHttpBrowserPathFromRequest(r *http.Request) (path string)
- func GetHttpDomainAndPortFromRequest(r *http.Request) (domain string, portNum string, err error)
- func GetHttpPathFromRequest(r *http.Request) (path string)
- func GetHttpProtocolFromRequest(r *http.Request) (proto string)
- func GetHttpProxyBasePath() string
- func GetHttpProxyRealClientIpHeaderKey() string
- func GetHttpProxyRealServerHostPortHeaderKey() string
- func GetHttpProxyRealServerProtoHeaderKey() string
- func GetHttpQueryStringFromRequest(r *http.Request) (query string)
- func GetHttpRealClientIpFromRequestHeaders(r *http.Request) (isOk bool, clientRealIp string, rawVal string, headerKey string)
- func GetHttpRemoteAddrIpAndPortFromRequest(r *http.Request) (ipAddr string, portNum string)
- func GetHttpUserAgentFromRequest(r *http.Request) (ua string)
- func GzDecode(str string) string
- func GzDeflate(str string, level int) string
- func GzEncode(str string, level int) string
- func GzInflate(str string) string
- func HTMLCodeFixSanitize(htmlCode string) (string, error)
- func HTMLCodeFixValidate(htmlCode string) (string, error)
- func HandleAbortCtrlC(delay uint32)
- func HashHmac(algo string, key string, str string, b64 bool) (string, error)
- func Hex2Bin(str string) string
- func HttpSessionUUIDCookieIsEnabled() bool
- func HttpSessionUUIDCookieNameGet() string
- func HttpSessionUUIDCookieNameSet(cookieName string) bool
- func Implode(glue string, pieces []string) string
- func InListArr[E comparable](v E, arr []E) bool
- func IniContentParse(iniContent string, iniKeys []string) (iniMap map[string]string, errMsg error)
- func IsNetValidHostName(s string) bool
- func IsNetValidIpAddr(s string) bool
- func IsNetValidPortNum(p int64) bool
- func IsNetValidPortStr(s string) bool
- func IsPathAlikeWithSafeFixedPath(path string, fixTrailingSlashes bool) bool
- func IsValidHttpHeaderKey(hdrKey string) bool
- func JsonArrDecode(data string) ([]interface{}, error)
- func JsonEncode(data interface{}, prettyprint bool, htmlsafe bool) (string, error)
- func JsonGetValueByKeyPath(json string, path string) gjson.Result
- func JsonNoErrChkEncode(data interface{}, prettyprint bool, htmlsafe bool) string
- func JsonObjDecode(data string) (map[string]interface{}, error)
- func JsonScalarDecodeToStr(data string) (string, error)
- func JsonStrDecode(data string) (string, error)
- func LogToConsole(level string, withColorsOnConsole bool)
- func LogToFile(level string, pathForLogs string, theFormat string, alsoOnConsole bool, ...)
- func LogToStdErr(level string)
- func LogUseLocalTime()
- func LogUseUtcTime()
- func MarkdownToHTMLRender(mkdwDoc string) (string, error)
- func MarkersTplEscapeSyntaxContent(tpl string, isMainHtml bool) string
- func MarkersTplEscapeTpl(template string) string
- func MarkersTplPrepareNosyntaxContent(tpl string) string
- func MarkersTplPrepareNosyntaxHtml(tpl string, isMainHtml bool) string
- func MarkersTplRender(template string, arrobj map[string]string, isEncoded bool, revertSyntax bool, ...) string
- func MarkersTplRevertNosyntaxContent(tpl string) string
- func Md5(str string) string
- func Md5B64(str string) string
- func MimeTypeByFileExtension(fext string) string
- func MimeTypeByFilePath(path string) string
- func NewError(err string) error
- func NullableStrFromStr(s string) *string
- func NullableStrToStr(s *string) string
- func PanicHandler()
- func ParseBoolStrAsBool(s string) bool
- func ParseBoolStrAsStdBoolStr(s string) string
- func ParseFloatStrAsDecimalStr(s string, d uint8) string
- func ParseStrAsFloat64(s string) float64
- func ParseStrAsFloat64StrFixedPrecision(s string) string
- func ParseStrAsInt64(s string) int64
- func ParseStrAsUInt64(s string) uint64
- func PathAddDirLastSlash(dirPath string) string
- func PathBaseExtension(filePath string) string
- func PathBaseName(filePath string) string
- func PathBaseNoExtName(filePath string) string
- func PathDirName(filePath string) string
- func PathExists(thePath string) bool
- func PathGetAbsoluteFromRelative(thePath string) string
- func PathGetCurrentExecutableDir() string
- func PathGetCurrentExecutableName() string
- func PathGetCurrentExecutablePathAndName() string
- func PathIsAbsolute(filePath string) bool
- func PathIsBackwardUnsafe(filePath string) bool
- func PathIsDir(thePath string) bool
- func PathIsEmptyOrRoot(filePath string) bool
- func PathIsFile(thePath string) bool
- func PathIsSafeValidFileName(fileName string) bool
- func PathIsSafeValidPath(filePath string) bool
- func PathIsSafeValidSafeFileName(fileName string) bool
- func PathIsSafeValidSafePath(filePath string) bool
- func Pbkdf2DerivedKey(algo string, key string, salt string, klen uint16, iterations uint16, b92 bool) (string, error)
- func Pbkdf2PreDerivedKey(key string) (string, error)
- func PlaceholdersTplRender(template string, arrpobj map[string]string, isEncoded bool, revertSyntax bool) string
- func Poly1305(key string, str string, b64 bool) (string, error)
- func PrettyPrintBytes(b int64) string
- func RawUrlDecode(s string) string
- func RawUrlEncode(s string) string
- func RenderMainHtmlMarkersTpl(template string, arrobj map[string]string, arrpobj map[string]string) string
- func RenderMarkersTpl(template string, arrobj map[string]string) string
- func SafeChecksumHashSmart(plainTextData string, customSalt string) string
- func SafePassHashSmart(plainPass string, theSalt string, useArgon2id bool) string
- func SafePathDirCreate(dirPath string, allowRecursive bool, allowAbsolutePath bool) (isSuccess bool, errMsg error)
- func SafePathDirDelete(dirPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)
- func SafePathDirRename(dirPath string, dirNewPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)
- func SafePathDirScan(dirPath string, recursive bool, allowAbsolutePath bool) (isSuccess bool, errMsg error, arrDirs []string, arrFiles []string)
- func SafePathEmbedDirScan(efs *embed.FS, dirPath string, recursive bool) (isSuccess bool, err error, arrDirs []string, arrFiles []string)
- func SafePathFileCopy(filePath string, fileNewPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)
- func SafePathFileDelete(filePath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)
- func SafePathFileGetSize(filePath string, allowAbsolutePath bool) (fileSize int64, errMsg error)
- func SafePathFileMd5(filePath string, allowAbsolutePath bool) (hashSum string, errMsg error)
- func SafePathFileRead(filePath string, allowAbsolutePath bool) (fileContent string, errMsg error)
- func SafePathFileRename(filePath string, fileNewPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)
- func SafePathFileSha(mode string, filePath string, allowAbsolutePath bool) (hashSum string, errMsg error)
- func SafePathFileWrite(filePath string, wrMode string, allowAbsolutePath bool, fileContent string) (isSuccess bool, errMsg error)
- func SafePathFixClean(p string) string
- func SafePathFixSeparator(p string) string
- func SafePathGetMTime(thePath string, allowAbsolutePath bool) (mTime int64, errMsg error)
- func SafePathIniFileReadAndParse(iniFilePath string, allowAbsolutePath bool, iniKeys []string) (iniMap map[string]string, errMsg error)
- func SafePathYamlFileReadAndParse(yamlFilePath string, allowAbsolutePath bool) (yamlMap map[string]interface{}, errMsg error)
- func SetCookieDefaultDomain(domain string) bool
- func SetCookieDefaultSameSitePolicy(policy string) bool
- func SetHttpProxyBasePath(pfx string) bool
- func SetHttpProxyRealClientIpHeaderKey(hdrKey string) bool
- func SetHttpProxyRealServerHostPortHeaderKey(hdrKey string) bool
- func SetHttpProxyRealServerProtoHeaderKey(hdrKey string) bool
- func Sh3a224(str string) string
- func Sh3a224B64(str string) string
- func Sh3a256(str string) string
- func Sh3a256B64(str string) string
- func Sh3a384(str string) string
- func Sh3a384B64(str string) string
- func Sh3a512(str string) string
- func Sh3a512B64(str string) string
- func Sha1(str string) string
- func Sha1B64(str string) string
- func Sha224(str string) string
- func Sha224B64(str string) string
- func Sha256(str string) string
- func Sha256B64(str string) string
- func Sha384(str string) string
- func Sha384B64(str string) string
- func Sha512(str string) string
- func Sha512B64(str string) string
- func StrChunkSplit(body string, chunklen uint, end string) string
- func StrContains(str string, part string) bool
- func StrCreateHtmId(s string) string
- func StrCreateJsVarName(s string) string
- func StrCreateSlug(s string) string
- func StrDeaccent(s string) string
- func StrEndsWith(str string, part string) bool
- func StrIContains(str string, part string) bool
- func StrIEndsWith(str string, part string) bool
- func StrIPos(haystack, needle string) int
- func StrIReplaceAll(s string, part string, replacement string) string
- func StrIReplaceWithLimit(s, part, replacement string, limit int) string
- func StrIStartsWith(str string, part string) bool
- func StrLen(str string) int
- func StrMBSubstr(s string, start int, stop int) string
- func StrNl2Br(s string) string
- func StrNormalizeSpaces(s string) string
- func StrPad2LenLeft(s string, padStr string, overallLen int) string
- func StrPad2LenRight(s string, padStr string, overallLen int) string
- func StrPos(haystack string, needle string) int
- func StrRIPos(haystack, needle string) int
- func StrRPos(haystack string, needle string) int
- func StrRegex2FindAllStringMatches(mode string, rexp string, s string, maxRecursion uint32, maxTimeOut uint8) (rx *regexp2.Regexp, mh []string)
- func StrRegexMatchString(rexpr string, s string) bool
- func StrRegexReplaceAll(rexpr string, s string, repl string) string
- func StrReplaceAll(s string, part string, replacement string) string
- func StrReplaceWithLimit(s string, part string, replacement string, limit int) string
- func StrRev(s string) string
- func StrStartsWith(str string, part string) bool
- func StrSubstr(s string, start int, stop int) string
- func StrToLower(str string) string
- func StrToUpper(str string) string
- func StrTrim(s string, cutset string) string
- func StrTrimLeft(s string, cutset string) string
- func StrTrimLeftWhitespaces(s string) string
- func StrTrimRight(s string, cutset string) string
- func StrTrimRightWhitespaces(s string) string
- func StrTrimWhitespaces(s string) string
- func StrUcFirst(s string) string
- func StrUcWords(s string) string
- func StrUnicodeLen(str string) int
- func StrWordCount(str string) []string
- func TextCutByLimit(s string, length int) string
- func ThreefishDecryptCBC(str string, key string, useArgon2id bool) string
- func ThreefishDecryptTwofishBlowfishCBC(str string, key string, useArgon2id bool) string
- func ThreefishEncryptCBC(str string, key string, useArgon2id bool) string
- func ThreefishEncryptTwofishBlowfishCBC(str string, key string, useArgon2id bool) string
- func TimeNowLocal() int64
- func TimeNowUtc() int64
- func TimeUnixNanoMathRandHandler() *mrand.Rand
- func TwofishDecryptBlowfishCBC(str string, key string) string
- func TwofishDecryptCBC(str string, key string) string
- func TwofishEncryptBlowfishCBC(str string, key string) string
- func TwofishEncryptCBC(str string, key string) string
- func UInt64ToHex(num uint64) string
- func UnEscapeHtml(s string) string
- func ValidateCookieName(cookieName string) bool
- func XmlConvertToJson(xmlData string) (string, error)
- func YamlDataParse(yamlData string) (yamlMap map[string]interface{}, errMsg error)
- type AuthDataStruct
- func AuthCookieDefaultCheck(authRealm string, authMode uint8, clientIP string, cookies map[string]string) (bool, AuthDataStruct)
- func AuthDataGet(ok bool, errMsg string, method uint8, area string, realm string, userID string, ...) AuthDataStruct
- func AuthTokenDefaultCheck(authRealm string, authMode uint8, clientIP string, token string, ...) (bool, AuthDataStruct)
- func AuthUserPassDefaultCheck(authRealm string, authMode uint8, user string, pass string, ...) (bool, AuthDataStruct)
Constants ¶
const ( SEPARATOR_SFZ_CHECKSUM_V1 string = "#CHECKSUM-SHA1#" // compatibility, v1 SEPARATOR_SFZ_CHECKSUM_V2 string = "#CKSUM256#" // compatibility, v2 SEPARATOR_SFZ_CHECKSUM_V3 string = "#CKSUM384V3#" // current, v3 SIGNATURE_SFZ_DATA_ARCH_V1 string = "PHP.SF.151129/B64.ZLibRaw.HEX" // compatibility, v1, unarchive only SIGNATURE_SFZ_DATA_ARCH_V2 string = "SFZ.20210818/B64.ZLibRaw.hex" // compatibility, v2, unarchive only SIGNATURE_SFZ_DATA_ARCH_V3 string = "[SFZ.20231031/B64.ZLibRaw.hex]" // current, v3 ; archive + unarchive )
const ( ALGO_PASS_SMART_SAFE_PASS uint8 = 0 ALGO_PASS_SMART_SAFE_ARGON_PASS uint8 = 1 HTTP_AUTH_MODE_NONE uint8 = 0 HTTP_AUTH_MODE_BASIC uint8 = 1 HTTP_AUTH_MODE_BEARER uint8 = 2 HTTP_AUTH_MODE_COOKIE uint8 = 3 HTTP_AUTH_MODE_TOKEN uint8 = 4 REGEX_SAFE_HTTP_USER_NAME string = `^[a-z0-9\.]+$` // Safe UserName Regex )
const ( SEPARATOR_CRYPTO_CHECKSUM_V1 string = "#CHECKSUM-SHA1#" // compatibility, v1 ; blowfish only SEPARATOR_CRYPTO_CHECKSUM_V2 string = "#CKSUM256#" // compatibility, v2 ; blowfish only SEPARATOR_CRYPTO_CHECKSUM_V3 string = "#CKSUM512V3#" // current, v3 ; threefish, twofish, blowfish SIGNATURE_BFISH_V1 string = "bf384.v1!" // compatibility, v1 ; decrypt only SIGNATURE_BFISH_V2 string = "bf448.v2!" // compatibility, v2 ; decrypt only SIGNATURE_BFISH_V3 string = "bf448.v3!" // current, v3 ; encrypt + decrypt SIGNATURE_2FISH_V1_DEFAULT string = "2f256.v1!" // current, v1 (default) ; encrypt + decrypt SIGNATURE_2FISH_V1_BF_DEFAULT string = "2fb88.v1!" // current, v1 (default+blowfish) ; encrypt + decrypt ; Blowfish 56 (448) + TwoFish 32 (256) = 88 (704) SIGNATURE_3FISH_1K_V1_DEFAULT string = "3f1kD.v1!" // current, v1 1024 (default) ; encrypt + decrypt SIGNATURE_3FISH_1K_V1_ARGON2ID string = "3f1kA.v1!" // current, v1 1024 (argon2id) ; encrypt + decrypt SIGNATURE_3FISH_1K_V1_2FBF_D string = "3ffb2kD.v1!" // current, v1 1024 (default+twofish/256+blowfish/448) ; encrypt + decrypt SIGNATURE_3FISH_1K_V1_2FBF_A string = "3ffb2kA.v1!" // current, v1 1024 (argon2id+twofish/256+blowfish/448) ; encrypt + decrypt SALT_PREFIX string = "Smart Framework" // fixed salt prefix SALT_SEPARATOR string = "#" // fixed salt separator SALT_SUFFIX string = "スマート フレームワーク" // fixed salt suffix DERIVE_MIN_KLEN uint16 = 3 // Key Derive Min Length DERIVE_MAX_KLEN uint16 = 4096 // Key Derive Min Length DERIVE_PREKEY_LEN uint16 = 80 // Key Derive Pre-Key Length DERIVE_CENTITER_EK uint16 = 87 // Key Derive EK Iterations DERIVE_CENTITER_EV uint16 = 78 // Key Derive EV Iterations DERIVE_CENTITER_PW uint16 = 77 // Key Derive PW Iterations PASSWORD_PLAIN_MIN_LENGTH uint8 = 7 // Password Plain Min Lentgth PASSWORD_PLAIN_MAX_LENGTH uint8 = 55 // Password Plain Max Lentgth PASSWORD_HASH_LENGTH uint8 = 128 // fixed length ; {{{SYNC-AUTHADM-PASS-LENGTH}}} ; if lower then padd to right with * ; {{{SYNC-AUTHADM-PASS-PADD}}} PASSWORD_PREFIX_VERSION string = "$fPv3.7!" // {{{SYNC-AUTHADM-PASS-PREFIX}}} PASSWORD_PREFIX_A2ID_VERSION string = "a2idP37!" // go lang only (no PHP), curent v3, argon2id password ; must be the same length as PASSWORD_PREFIX_VERSION )
const ( //-- FIXED DATE CONSTANTS REFERENCE VALUES ... SYNCED WITH GO DATE STANDARDS ! DATE_TIME_DEFAULT_LOCAL_TIMEZONE string = "UTC" DATE_TIME_FMT_ISO_NOTIME_GO_EPOCH string = "2006-01-02" // GO EPOCH: NO TIME, NO TZ OFFSET DATE_TIME_FMT_ISO_STD_GO_EPOCH string = "2006-01-02 15:04:05" // GO EPOCH: WITH TIME, NO TZ OFFSET DATE_TIME_FMT_ISO_TZOFS_GO_EPOCH string = "2006-01-02 15:04:05 -0700" // GO EPOCH: WITH TIME, WITH TZ OFFSET DATE_TIME_FMT_RFC1123_GO_EPOCH string = "Mon, 02 Jan 2006 15:04:05" // GO EPOCH: RFC1123 )
const ( CHOWN_DIRS os.FileMode = 0755 CHOWN_FILES os.FileMode = 0644 //-- Cross Platform Safe Paths ; The following are disallowed in Windows paths: `< > : " / \ | ? *` ; also disallow SPACE because of the web context REGEX_SAFE_PATH_NAME string = `^[_a-zA-Z0-9\-\.@#\/` + "`" + `~\!\$%&\(\)\^\{\}'` + `\[\],;+` + `]+$` // SAFETY: SAFE Cross Platform Character Set for FileSystems: Smart + MsDOS + Linux/Unix + Windows (intersect) REGEX_SAFE_FILE_NAME string = `^[_a-zA-Z0-9\-\.@#` + "`" + `~\!\$%&\(\)\^\{\}'` + `\[\],;+` + `]+$` // SAFETY: SAFE Cross Platform Character Set for FileSystems: Smart + MsDOS + Linux/Unix + Windows (intersect) ; like above, just missing slash / //-- Web Ultra-Safe Paths (Smart) REGEX_SMART_SAFE_PATH_NAME string = `^[_a-zA-Z0-9\-\.@#\/]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN FILE SYSTEM PATHS ... REGEX_SMART_SAFE_FILE_NAME string = `^[_a-zA-Z0-9\-\.@#]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN FILE SYSTEM FILE AND DIR NAMES ... ; like above, just missing slash / INVALID_ABSOLUTE_PATH string = "/tmp/err-absolute-path/invalid-path/" )
const ( REGEX_SMART_SAFE_BASE_PATH string = `^[_a-z0-9\-\/]+$` // CONFORMANCE: SUPPORT ONLY THESE CHARACTERS IN HTML BASE PATHS REGEX_SMART_SAFE_NET_HOSTNAME string = `^[_a-z0-9\-\.]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN NET HOST NAMES AS RFC ; if a hostname have upper characters must be converted to all lower characters ; if a hostname have unicode characters must be converted using punnycode ... REGEX_SMART_SAFE_HTTP_HEADER_KEY string = `^[A-Za-z0-9\-]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN HEADER KEY VALUES HTTP_PROTO_PREFIX_HTTP string = "http://" HTTP_PROTO_PREFIX_HTTPS string = "https://" DEFAULT_FAKE_IP_CLIENT string = "0.0.0.0" DEFAULT_FAKE_HOSTPORT_SERVER string = "256.256.256.256:65535" )
const ( SPECIAL_TRIM string = "\n\r\x00\x0B" UNDEF_VAR_NAME string = "Undef____V_a_r" )
const ( VERSION string = "v.20240603.2102" NAME string = "SmartGo" DESCRIPTION string = "Smart.Framework.Go" COPYRIGHT string = "(c) 2021-2024 unix-world.org" CHARSET string = "UTF-8" // don't change !! REGEX_SAFE_APP_NAMESPACE string = `^[_a-z0-9\-\.]+$` // Safe App Namespace Regex REGEX_SMART_SAFE_NUMBER_FLOAT string = `^[0-9\-\.]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN SAFE FLOAT (ex: JSON) REGEX_SAFE_VAR_NAME string = `^[_a-zA-Z0-9]+$` // Safe VarName Regex REGEXP2_DEFAULT_MAX_RECURSION uint32 = 800000 // Default REGEXP2 Recursion Limit: 800K REGEXP2_DEFAULT_MAX_TIMEOUT uint8 = 1 // Default REGEXP2 Max Timeout 1 Second(s) TRIM_WHITESPACES string = " \t\n\r\x00\x0B" // PHP COMPATIBILITY NULL_BYTE string = "\x00" // THE NULL BYTE character \x00 or \000 BACK_SPACE string = "\b" // The Backspace Character \b ASCII_BELL string = "\a" // The ASCII Bell Character \a FORM_FEED string = "\f" // The Form Feed Character \f or \x0C VERTICAL_TAB string = "\v" // The Vertical Tab character \v or \x0B HORIZONTAL_TAB string = "\t" // The Horizontal Tab character \t LINE_FEED string = "\n" // The Line Feed character \n CARRIAGE_RETURN string = "\r" // The Carriage Return character \r SIZE_BYTES_16M uint64 = 16777216 // Reference Unit )
const (
CMD_EXEC_HAMMER_SIGNATURE string = "[»»»»»»»[SmartGo:{!HAMMER!}:Abort:(Exit):KILL.SIGNAL]«««««««]" // INTERNAL FLAG FOR CMD FORCE EXIT HAMMER
)
Variables ¶
var (
DEBUG bool = false
)
Functions ¶
func AddCSlashes ¶
func AppGetNamespace ¶
func AppGetRunInBackground ¶
func AppGetRunInBackground() bool
func AppSetNamespace ¶
func AppSetRunInBackground ¶
func AppSetRunInBackground() bool
func ArrMapKeyExists ¶
func ArrMapKeyExists[E comparable](v E, arr map[E]E) bool
func Auth2FACookieIsEnabled ¶
func Auth2FACookieIsEnabled() bool
func Auth2FACookieNameGet ¶
func Auth2FACookieNameGet() string
func Auth2FACookieNameSet ¶
func AuthBasicIsEnabled ¶
func AuthBasicIsEnabled() bool
func AuthBasicModeSet ¶
func AuthBearerIsEnabled ¶
func AuthBearerIsEnabled() bool
func AuthBearerModeSet ¶
func AuthCookieIsEnabled ¶
func AuthCookieIsEnabled() bool
func AuthCookieNameGet ¶
func AuthCookieNameGet() string
func AuthCookieNameSet ¶
func Base64Decode ¶
func Base64Encode ¶
func Base64ToBase64s ¶
func Base64sDecode ¶
func Base64sEncode ¶
func Base64sToBase64 ¶
func BaseDecode ¶
func BaseEncode ¶
func BlowfishDecryptCBC ¶
func BlowfishEncryptCBC ¶
func CipherDecryptCBC ¶
IMPORTANT: the output must be trimmed for the padding added when encrypted ; expects B64 data, so trim is OK !
func CipherEncryptCBC ¶
IMPORTANT: the input will be padded ; expects B64 data !
func ClearPrintTerminal ¶
func ClearPrintTerminal()
set terminal theme Dark (bg:black ; fg:white) : print("\033[0;37;40m")
func ConvertFloat32ToStr ¶
func ConvertFloat64ToStr ¶
func ConvertInt16ToStr ¶
func ConvertInt32ToStr ¶
func ConvertInt64ToStr ¶
func ConvertInt8ToStr ¶
func ConvertIntToStr ¶
func ConvertJsonNumberToStr ¶
func ConvertJsonNumberToStr(data interface{}) string
func ConvertUInt16ToStr ¶
func ConvertUInt32ToStr ¶
func ConvertUInt64ToStr ¶
func ConvertUInt8ToStr ¶
func ConvertUIntToStr ¶
func CryptoGetSecurityKey ¶
func CryptoSetSecurityKey ¶
func CurrentFunctionName ¶
func CurrentFunctionName() string
func DataArchive ¶
func DataRRot13 ¶
func DataUnArchive ¶
func DateNowIsoLocal ¶
func DateNowIsoLocal() string
func DateNowIsoUtc ¶
func DateNowIsoUtc() string
func DateNowLocal ¶
func DateNowLocal() string
func DateNowUtc ¶
func DateNowUtc() string
func DateTimeGetLocation ¶
func DateTimeGetLocation() string
func DateTimeSetLocation ¶
func DateTimeStructLocal ¶
func DateTimeStructLocal(dateIsoStr string) uxmDateTimeStruct
func DateTimeStructUtc ¶
func DateTimeStructUtc(dateIsoStr string) uxmDateTimeStruct
func EscapeHtml ¶
func ExecTimedCmd ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateSSHKeyPairEd25519 ¶
return: err, pubKeyPEM, privKeyPEM
func GetBaseDomainFromDomain ¶
func GetCookieDefaultDomain ¶
func GetCookieDefaultDomain() string
func GetCookieDefaultSameSitePolicy ¶
func GetCookieDefaultSameSitePolicy() string
func GetHttpDomainAndPortFromRequest ¶
domain can be: domain or IPv4 / IPv6
func GetHttpPathFromRequest ¶
returns: `/` or `/path/extra` or `/path/extra/`
func GetHttpProtocolFromRequest ¶
returns: `http://` or `https://`
func GetHttpProxyBasePath ¶
func GetHttpProxyBasePath() string
func GetHttpProxyRealClientIpHeaderKey ¶
func GetHttpProxyRealClientIpHeaderKey() string
func GetHttpProxyRealServerHostPortHeaderKey ¶
func GetHttpProxyRealServerHostPortHeaderKey() string
func GetHttpProxyRealServerProtoHeaderKey ¶
func GetHttpProxyRealServerProtoHeaderKey() string
func GetHttpQueryStringFromRequest ¶
returns: “ or `?` or `?a` or `?a=` or `?a=b` or `?a=b&` or `?a=b&c` or `?a=b&c=` or `?a=b&c=d`
func HTMLCodeFixSanitize ¶
func HTMLCodeFixValidate ¶
func HandleAbortCtrlC ¶
func HandleAbortCtrlC(delay uint32)
func HttpSessionUUIDCookieIsEnabled ¶
func HttpSessionUUIDCookieIsEnabled() bool
func HttpSessionUUIDCookieNameGet ¶
func HttpSessionUUIDCookieNameGet() string
func InListArr ¶
func InListArr[E comparable](v E, arr []E) bool
func IniContentParse ¶
func IsNetValidHostName ¶
func IsNetValidIpAddr ¶
func IsNetValidPortNum ¶
func IsNetValidPortStr ¶
func IsValidHttpHeaderKey ¶
func JsonArrDecode ¶
func JsonEncode ¶
func JsonNoErrChkEncode ¶
func JsonObjDecode ¶
func JsonScalarDecodeToStr ¶
func JsonStrDecode ¶
func LogToConsole ¶
func LogToStdErr ¶
func LogToStdErr(level string)
func LogUseLocalTime ¶
func LogUseLocalTime()
func LogUseUtcTime ¶
func LogUseUtcTime()
func MarkdownToHTMLRender ¶
func MarkersTplEscapeTpl ¶
func MarkersTplRender ¶
func MimeTypeByFileExtension ¶
func MimeTypeByFilePath ¶
func NullableStrFromStr ¶
func NullableStrToStr ¶
func ParseBoolStrAsBool ¶
func ParseStrAsFloat64 ¶
func ParseStrAsInt64 ¶
func ParseStrAsUInt64 ¶
func PathAddDirLastSlash ¶
func PathBaseExtension ¶
func PathBaseName ¶
func PathBaseNoExtName ¶
func PathDirName ¶
func PathExists ¶
func PathGetCurrentExecutableDir ¶
func PathGetCurrentExecutableDir() string
func PathGetCurrentExecutableName ¶
func PathGetCurrentExecutableName() string
func PathGetCurrentExecutablePathAndName ¶
func PathGetCurrentExecutablePathAndName() string
func PathIsAbsolute ¶
func PathIsBackwardUnsafe ¶
func PathIsEmptyOrRoot ¶
func PathIsFile ¶
func PathIsSafeValidFileName ¶
func PathIsSafeValidPath ¶
func PathIsSafeValidSafePath ¶
func Pbkdf2DerivedKey ¶
func Pbkdf2PreDerivedKey ¶
func PlaceholdersTplRender ¶
func PrettyPrintBytes ¶
func RawUrlDecode ¶
func RawUrlEncode ¶
func SafeChecksumHashSmart ¶
func SafePassHashSmart ¶
func SafePathDirCreate ¶
func SafePathDirDelete ¶
func SafePathDirRename ¶
func SafePathDirScan ¶
func SafePathEmbedDirScan ¶
func SafePathEmbedDirScan(efs *embed.FS, dirPath string, recursive bool) (isSuccess bool, err error, arrDirs []string, arrFiles []string)
ex call (req. go ambed fs assets): SafePathEmbedDirScan(&assets, "assets/", true)
func SafePathFileCopy ¶
func SafePathFileDelete ¶
func SafePathFileGetSize ¶
func SafePathFileMd5 ¶
func SafePathFileRead ¶
func SafePathFileRename ¶
func SafePathFileSha ¶
func SafePathFileWrite ¶
func SafePathFixClean ¶
func SafePathFixSeparator ¶
this is a safer replacement for filepath.ToSlash(p), because is not OS Context Aware
func SafePathGetMTime ¶
func SetCookieDefaultDomain ¶
func SetHttpProxyBasePath ¶
func Sh3a224B64 ¶
func Sh3a256B64 ¶
func Sh3a384B64 ¶
func Sh3a512B64 ¶
func StrChunkSplit ¶
ChunkSplit chunk_split()
func StrContains ¶
func StrCreateHtmId ¶
func StrCreateJsVarName ¶
func StrCreateSlug ¶
func StrDeaccent ¶
func StrEndsWith ¶
func StrIContains ¶
func StrIEndsWith ¶
func StrIPos ¶
case insensitive, find position of first occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack
func StrIReplaceAll ¶
case insensitive replacer
func StrIReplaceWithLimit ¶
case insensitive replacer
func StrIStartsWith ¶
func StrNormalizeSpaces ¶
func StrPos ¶
case sensitive, find position of first occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack
func StrRIPos ¶
case insensitive, find position of last occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack
func StrRPos ¶
case sensitive, find position of last occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack
func StrRegexMatchString ¶
func StrReplaceAll ¶
case sensitive replacer
func StrReplaceWithLimit ¶
case sensitive replacer
func StrStartsWith ¶
func StrToLower ¶
func StrToUpper ¶
func StrTrimLeft ¶
func StrTrimLeftWhitespaces ¶
func StrTrimRight ¶
func StrTrimRightWhitespaces ¶
func StrTrimWhitespaces ¶
func StrUcFirst ¶
func StrUcWords ¶
func TextCutByLimit ¶
func ThreefishDecryptCBC ¶
func ThreefishEncryptCBC ¶
func TimeNowLocal ¶
func TimeNowLocal() int64
func TimeNowUtc ¶
func TimeNowUtc() int64
func TwofishDecryptCBC ¶
func TwofishEncryptCBC ¶
func UInt64ToHex ¶
func ValidateCookieName ¶
func XmlConvertToJson ¶
func YamlDataParse ¶
Types ¶
type AuthDataStruct ¶
type AuthDataStruct struct { OK bool // TRUE | FALSE ErrMsg string // error message (if any) or empty string Method uint8 // see: HTTP_AUTH_MODE_* Area string // Auth Area Realm string // Auth Realm UserID string // User ID (if no specific ID can be the same as User Name) UserName string // User Name PassHash string // Password Hash PassAlgo uint8 // Password Hash Algo ; 0 for SafePassHashSmart ; 1..255 for the rest EmailAddr string // User Email Address FullName string // Full Name Privileges string // Privileges: <priv1>,<priv2>,... Restrictions string // Restrictions: <restr1>,<restr2>,... PrivKey string // Private Key Quota uint64 // Quota MetaData map[string]string // MetaData ... Associative Array {"key1":"Val1", "key2":"Val2", ...} }
PRIVATE
func AuthCookieDefaultCheck ¶
func AuthDataGet ¶
func AuthTokenDefaultCheck ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
colorstring
module
|
|
crypto
|
|
blowfish
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
|
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm. |
dhkx
REQUIRE: go 1.16 or later
|
REQUIRE: go 1.16 or later |
pbkdf2
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
|
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. |
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
|
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202. |
threefish
Package threefish implements the Threefish tweakable block cipher.
|
Package threefish implements the Threefish tweakable block cipher. |
twofish
Package twofish implements Bruce Schneier's Twofish encryption algorithm.
|
Package twofish implements Bruce Schneier's Twofish encryption algorithm. |
data-structs
|
|
fastjson
Package fastjson provides fast JSON parsing.
|
Package fastjson provides fast JSON parsing. |
tidwall/gjson
Package gjson provides searching for json strings.
|
Package gjson provides searching for json strings. |
tidwall/match
Package match provides a simple pattern matcher with unicode support.
|
Package match provides a simple pattern matcher with unicode support. |
tidwall/secret
Package secret provides simple utilities for encrypting and decrypting data.
|
Package secret provides simple utilities for encrypting and decrypting data. |
tidwall/sjson
Package sjson provides setting json values.
|
Package sjson provides setting json values. |
yaml
Package yaml implements YAML support for the Go language.
|
Package yaml implements YAML support for the Go language. |
REQUIRE: go 1.19 or later
|
REQUIRE: go 1.19 or later |
lib-pq
Package pq is a pure Go Postgres driver for the database/sql package.
|
Package pq is a pure Go Postgres driver for the database/sql package. |
lib-pq/oid
Package oid contains OID constants as defined by the Postgres server.
|
Package oid contains OID constants as defined by the Postgres server. |
lib-pq/scram
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
|
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802. |
mysql
Package mysql provides a MySQL driver for Go's database/sql package.
|
Package mysql provides a MySQL driver for Go's database/sql package. |
redcon-srv
Package redcon implements a Redis compatible server framework
|
Package redcon implements a Redis compatible server framework |
redigo/redis
Package redis is a client for the Redis database.
|
Package redis is a client for the Redis database. |
redigo/redisx
Package redisx contains experimental features for Redigo.
|
Package redisx contains experimental features for Redigo. |
dynamic-struct
module
|
|
fastjson
module
|
|
gui
|
|
logutils
module
|
|
markup
|
|
markdown
Package markdown implements markdown parser and HTML renderer.
|
Package markdown implements markdown parser and HTML renderer. |
markdown/ast
Package ast defines tree representation of a parsed markdown document.
|
Package ast defines tree representation of a parsed markdown document. |
markdown/html
Package html implements HTML renderer of parsed markdown document.
|
Package html implements HTML renderer of parsed markdown document. |
markdown/parser
Package parser implements parser for markdown text that generates AST (abstract syntax tree).
|
Package parser implements parser for markdown text that generates AST (abstract syntax tree). |
svg-qrcode
Package qrcode implements a QR Code encoder.
|
Package qrcode implements a QR Code encoder. |
svg-qrcode/bitset
Package bitset implements an append only bit array.
|
Package bitset implements an append only bit array. |
svg-qrcode/reedsolomon
Package reedsolomon provides error correction encoding for QR Code 2005.
|
Package reedsolomon provides error correction encoding for QR Code 2005. |
regexp2
module
|
|
textproc
|
|
difflib
Package difflib is a partial port of Python difflib module.
|
Package difflib is a partial port of Python difflib module. |
regexp2
Package regexp2 is a regexp package that has an interface similar to Go's framework regexp engine but uses a more feature full regex engine behind the scenes.
|
Package regexp2 is a regexp package that has an interface similar to Go's framework regexp engine but uses a more feature full regex engine behind the scenes. |
threefish
module
|
|
ui
|
|
utils
|
|
log-utils
Package logutils augments the standard log package with levels
|
Package logutils augments the standard log package with levels |
uuid
module
|
|
web
|
|
assets/srv-assets
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
|
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower) |
assets/web-assets
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower versions)
|
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower versions) |
httputils
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
|
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower) |
jsonschema
Package jsonschema provides json-schema compilation and validation.
|
Package jsonschema provides json-schema compilation and validation. |
jsonschema/httploader
Package httploader implements loader.Loader for http/https url.
|
Package httploader implements loader.Loader for http/https url. |
jwt
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
|
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html |
webdav
Package webdav provides a WebDAV server implementation.
|
Package webdav provides a WebDAV server implementation. |
webdav/internal/xml
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
|
Package xml implements a simple XML 1.0 parser that understands XML name spaces. |
websrv
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
|
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower) |
web-socket
|
|
websocket
Package websocket implements the WebSocket protocol defined in RFC 6455.
|
Package websocket implements the WebSocket protocol defined in RFC 6455. |
websocket/examples/autobahn
Command server is a test server for the Autobahn WebSockets Test Suite.
|
Command server is a test server for the Autobahn WebSockets Test Suite. |
ws-msgpak-srv-cli
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
|
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower) |
webview
module
|
|
webview2
module
|