platform: github.com/xormplus/platform/utils Index | Files

package utils

import "github.com/xormplus/platform/utils"

Index

Package Files

apns.go config.go lru.go mail.go random.go textgeneration.go

Constants

const (
    MODE_DEV  = "dev"
    MODE_BETA = "beta"
    MODE_PROD = "prod"
)
const (
    ALPHANUMERIC = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
    LOWERCASE    = "abcdefghijklmnopqrstuvwxyz"
)
const GIBBERISH_TEXT = "" /* 9070 byte string literal not displayed */

Lovely giberish for all to use

Variables

var FUZZY_STRINGS_EMAILS = []string{
    "sue@thatmightbe",
    "sue@thatmightbe.",
    "sue@thatmightbe.c",
    "sue@thatmightbe.co",
    "su+san@thatmightbe.com",
    "a@b.中国",
    "1@2.am",
    "a@b.co.uk",
    "a@b.cancerresearch",
    "su+s+an@thatmightbe.com",
    "per.iod@thatmightbe.com",
    "per..iods@thatmightbe.com",
}

Strings that should pass as acceptable emails

var FUZZY_STRINGS_NAMES = []string{
    "*",
    "?",
    ".",
    "}{][)(><",
    "{}[]()<>",

    "qahwah ( قهوة)",
    "שָׁלוֹם עֲלֵיכֶם",
    "Ramen チャーシュー chāshū",
    "言而无信",
    "Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒",
    "&amp; &lt; &qu",

    "' or '1'='1' -- ",
    "' or '1'='1' ({ ",
    "' or '1'='1' /* ",
    "1;DROP TABLE users",

    "<b><i><u><strong><em>",

    "sue@thatmightbe",
    "sue@thatmightbe.",
    "sue@thatmightbe.c",
    "sue@thatmightbe.co",
    "sue @ thatmightbe.com",
    "apos'trophe@thatmightbe.com",
    "apos''''trophe@thatmightbe.com",
    "su+san@thatmightbe.com",
    "su+s+an@thatmightbe.com",
    "per.iod@thatmightbe.com",
    "per..iods@thatmightbe.com",
    ".period@thatmightbe.com",
    "tom(comment)@thatmightbe.com",
    "(comment)tom@thatmightbe.com",
    "\"quotes\"@thatmightbe.com",
    "\"\\\"(),:;<>@[\\]\"@thatmightbe.com",
    "a!#$%&'*+-/=?^_`{|}~b@thatmightbe.com",
    "local@[127.0.0.1]",
    "jill@(comment)example.com",
    "jill@example.com(comment)",
    "a@b.中国",
    "1@2.am",
    "a@b.co.uk",
    "a@b.cancerresearch",

    "<a href=\"//www.google.com\">Teh Googles</a>",
    "<img src=\"//upload.wikimedia.org/wikipelogo-v2_2x.png\" />",
    "<b><i><u><strong><em>",
    "&amp; &lt; &quot; &apos;",

    ";alert('Well this is awkward.');",
    "<script type='text/javascript'>alert('yay puppies');</script>",

    "Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒nͧ̍̓̃͋v",
    "H҉̵̞̟̠̖̗̘Ȅ̐̐̑̒̚OMI҉̵̞̟̠",
}

Strings that should pass as acceptable team names

var FUZZY_STRINGS_POSTS = []string{
    "*", "?", ".", "}{][)(><", "{}[]()<>",

    "qahwah ( قهوة)",
    "שָׁלוֹם עֲלֵיכֶם",
    "Ramen チャーシュー chāshū",
    "言而无信",
    "Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒",
    "&amp; &lt; &qu",

    "' or '1'='1' -- ",
    "' or '1'='1' ({ ",
    "' or '1'='1' /* ",
    "1;DROP TABLE users",

    "<b><i><u><strong><em>",

    "sue@thatmightbe",
    "sue@thatmightbe.",
    "sue@thatmightbe.c",
    "sue@thatmightbe.co",
    "su+san@thatmightbe.com",
    "a@b.中国",
    "1@2.am",
    "a@b.co.uk",
    "a@b.cancerresearch",
    "local@[127.0.0.1]",

    "!@$%^&:*.,/|;'\"+=?`~#",
    "'\"/\\\"\"''\\/",
    "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
    "" /* 1026 byte string literal not displayed */,
    "ą ć ę ł ń ó ś ź ż č ď ě ň ř š ť ž ă î ø å æ á é í ó ú Ç Ğ İ Ö Ş Ü",
    "abcdefghijklmnopqrstuvwrxyz0123456789 -_",
    "" /* 329 byte string literal not displayed */,
    "" /* 254 byte string literal not displayed */,

    "<a href=\"//www.google.com\">Teh Googles</a>",
    "<img src=\"//upload.wikimedia.org/wikipedia/meta/b/be/Wikipedia-logo-v2_2x.png\" />",
    "&amp; &lt; &quot; &apos;",
    "" /* 149 byte string literal not displayed */,

    ";alert('Well this is awkward.');",
    "<script type='text/javascript'>alert('yay puppies');</script>",

    "" /* 163 byte string literal not displayed */,

    "apos'trophe@thatmightbe.com",
    "apos''''trophe@thatmightbe.com",
    "su+s+an@thatmightbe.com",
    "per.iod@thatmightbe.com",
    "per..iods@thatmightbe.com",
    ".period@thatmightbe.com",
    "tom(comment)@thatmightbe.com",
    "(comment)tom@thatmightbe.com",
    "\"quotes\"@thatmightbe.com",
    "\"\\\"(),:;<>@[\\]\"@thatmightbe.com",
    "a!#$%&'*+-/=?^_`{|}~b@thatmightbe.com",
    "jill@(comment)example.com",
    "jill@example.com(comment)",
    "ben@ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg.com",
    "" /* 137 byte string literal not displayed */,
    "" /* 325 byte string literal not displayed */,
}

Strings that should pass as acceptable posts

var SanitizeOptions map[string]bool = map[string]bool{}

func CheckMailSettings Uses

func CheckMailSettings() *model.AppError

func FindDir Uses

func FindDir(dir string) string

func FireAndForgetSendAppleNotify Uses

func FireAndForgetSendAppleNotify(deviceId string, message string, badge int)

func FuzzEmail Uses

func FuzzEmail() string

func FuzzName Uses

func FuzzName() string

func FuzzPost Uses

func FuzzPost() string

func IsS3Configured Uses

func IsS3Configured() bool

func LoadConfig Uses

func LoadConfig(fileName string)

LoadConfig will try to search around for the corresponding config file. It will search /tmp/fileName then attempt ./config/fileName, then ../config/fileName and last it will look at fileName

func RandIntFromRange Uses

func RandIntFromRange(r Range) int

func RandString Uses

func RandString(l int, charset string) string

func RandomEmail Uses

func RandomEmail(length Range, charset string) string

func RandomName Uses

func RandomName(length Range, charset string) string

func RandomText Uses

func RandomText(length Range, hashtags Range, mentions Range, users []string) string

Random selection of text for post

func SendAppleNotify Uses

func SendAppleNotify(deviceId string, message string, badge int) *model.AppError

func SendMail Uses

func SendMail(to, subject, body string) *model.AppError

type AWSSettings Uses

type AWSSettings struct {
    S3AccessKeyId          string
    S3SecretAccessKey      string
    S3Bucket               string
    S3Region               string
    Route53AccessKeyId     string
    Route53SecretAccessKey string
    Route53ZoneId          string
    Route53Region          string
}

type Cache Uses

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

Cache is a thread-safe fixed size LRU cache.

func NewLru Uses

func NewLru(size int) *Cache

New creates an LRU of the given size

func NewLruWithEvict Uses

func NewLruWithEvict(size int, onEvicted func(key interface{}, value interface{})) (*Cache, error)

func (*Cache) Add Uses

func (c *Cache) Add(key, value interface{}) bool

func (*Cache) AddWithExpiresInSecs Uses

func (c *Cache) AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64) bool

Add adds a value to the cache. Returns true if an eviction occured.

func (*Cache) Get Uses

func (c *Cache) Get(key interface{}) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Keys Uses

func (c *Cache) Keys() []interface{}

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*Cache) Len Uses

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Purge Uses

func (c *Cache) Purge()

Purge is used to completely clear the cache

func (*Cache) Remove Uses

func (c *Cache) Remove(key interface{})

Remove removes the provided key from the cache.

func (*Cache) RemoveOldest Uses

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

type Config Uses

type Config struct {
    LogSettings     LogSettings
    ServiceSettings ServiceSettings
    SqlSettings     SqlSettings
    RedisSettings   RedisSettings
    AWSSettings     AWSSettings
    ImageSettings   ImageSettings
    EmailSettings   EmailSettings
    PrivacySettings PrivacySettings
    TeamSettings    TeamSettings
}
var Cfg *Config = &Config{}

func (*Config) ToJson Uses

func (o *Config) ToJson() string

type EmailSettings Uses

type EmailSettings struct {
    SMTPUsername         string
    SMTPPassword         string
    SMTPServer           string
    UseTLS               bool
    FeedbackEmail        string
    FeedbackName         string
    ApplePushServer      string
    ApplePushCertPublic  string
    ApplePushCertPrivate string
}

type ImageSettings Uses

type ImageSettings struct {
    ThumbnailWidth  uint
    ThumbnailHeight uint
    PreviewWidth    uint
    PreviewHeight   uint
    ProfileWidth    uint
    ProfileHeight   uint
}

type LogSettings Uses

type LogSettings struct {
    ConsoleEnable bool
    ConsoleLevel  string
    FileEnable    bool
    FileLevel     string
    FileFormat    string
    FileLocation  string
}

type PrivacySettings Uses

type PrivacySettings struct {
    ShowEmailAddress bool
    ShowPhoneNumber  bool
    ShowSkypeId      bool
    ShowFullName     bool
}

type Range Uses

type Range struct {
    Begin int
    End   int
}

type RedisSettings Uses

type RedisSettings struct {
    DataSource   string
    MaxOpenConns int
}

type ServiceSettings Uses

type ServiceSettings struct {
    SiteName       string
    Domain         string
    Mode           string
    AllowTesting   bool
    UseSSL         bool
    Port           string
    Version        string
    Shards         map[string]string
    InviteSalt     string
    PublicLinkSalt string
    ResetSalt      string
    AnalyticsUrl   string
}

type SqlSettings Uses

type SqlSettings struct {
    DriverName         string
    DataSource         string
    DataSourceReplicas []string
    MaxIdleConns       int
    MaxOpenConns       int
    Trace              bool
    AtRestEncryptKey   string
}

type TeamSettings Uses

type TeamSettings struct {
    MaxUsersPerTeam   int
    AllowPublicLink   bool
    AllowValetDefault bool
    TermsLink         string
    PrivacyLink       string
    AboutLink         string
    HelpLink          string
    ReportProblemLink string
    TourLink          string
    DefaultThemeColor string
}

Package utils imports 18 packages (graph). Updated 2018-05-16. Refresh now. Tools for package owners.