Documentation ¶
Index ¶
- Variables
- func BigEndianUint64(n uint64) []byte
- func BreakBaseURL(rawurl string) (scheme, ipaddr, port string, err error)
- func ByteSlice2String(bs []byte) string
- func CheckPasswordHash(password, hash string) bool
- func CombineMonthYear(month, year int) int
- func ContainsDotDot(v string) bool
- func Copy(src string, dst string) error
- func Debug(keyvals ...interface{})
- func DecrIP(ip net.IP, inc uint) net.IP
- func DirEmpty(dirname string) (b bool)
- func DirExists(dirname string) bool
- func DiskUsage(path string) (all, free, used uint64, err error)
- func DumpCookie(cks [][]*http.Cookie) []string
- func EqualDomain(d1, d2 string) bool
- func Error(keyvals ...interface{})
- func ExtractRootDomain(domain string) (string, error)
- func Fatal(keyvals ...interface{})
- func FileExists(filename string) bool
- func ForceIPHTTPClient(ip, port string) *http.Client
- func ForceIPWebsocketDialer(ip, port string) *websocket.Dialer
- func FormatHelloServerName(servername string) (string, error)
- func GetLocalPrivateIP() (net.IP, error)
- func GetLocalPublicIP() (net.IP, error)
- func GetMonthYear(n time.Time) int
- func GuessImageFormat(r io.Reader) (format string, err error)
- func HashPassword(password string) (string, error)
- func IPUint(ip net.IP) uint32
- func IPUintSl(ip []byte) uint32
- func IncrIP(ip net.IP, inc uint) net.IP
- func Info(keyvals ...interface{})
- func InitLogging(level string)
- func IsAlphaNumHyphen(s string) bool
- func IsIPPrivateRFC1918(ipuint uint32) bool
- func IsMultipart(r *http.Request) bool
- func IsPowerOf2(x int) bool
- func IsSlashRune(r rune) bool
- func IsValidEmail(email string) error
- func IsValidPassword(pass string) error
- func IsWebSocketRequest(req *http.Request) bool
- func JSONMarshal(t interface{}) ([]byte, error)
- func Max[T constraints.Ordered](x, y T) T
- func MimetypeFromFileExtension(path string) (mt string)
- func Min[T constraints.Ordered](x, y T) T
- func NextHighestPowerOf2(x uint32) uint32
- func PathExists(path string) (bool, os.FileInfo)
- func ReadCookies(h http.Header) [][]*http.Cookie
- func ReadSetCookies(h http.Header) [][]*http.Cookie
- func Redirect2HTTPS(w http.ResponseWriter, req *http.Request)
- func SecureToken32() (string, error)
- func SendError(w http.ResponseWriter, message, code string, statusCode int)
- func SendErrorAndLog(w http.ResponseWriter, message, code string, statusCode int, origin string, ...)
- func SendInternalError(w http.ResponseWriter, origin string, err error)
- func SendSuccess(w http.ResponseWriter, resp interface{})
- func SetKeepaliveParameters(conn *net.TCPConn) error
- func SplitHostPort(hostport string) (string, string)
- func SplitSlash(url string) []string
- func String2ByteSlice(str string) []byte
- func StripPort(hostport string) string
- func UintIP(v uint32) net.IP
- func UniqueSecureID120() (string, error)
- func UniqueSecureID36() (string, error)
- func UniqueSecureID60() (string, error)
- func UploadEmbedFolderMultipart(client *http.Client, url, method string, relfilepaths []string, ...) (*http.Response, error)
- func UploadFileMultipart(client *http.Client, url string, path string) (*http.Response, error)
- func UploadFolderMultipart(client *http.Client, url, method string, folder string, fields ...string) (*http.Response, error)
- func Varint(n int64) []byte
- func VerifyTXT(domain, token string) (bool, error)
- func Warn(keyvals ...interface{})
- type CertificateAuthority
- type JSONErr
- type LimitedBuffer
- type ProxyReader
- type TeeWriter
Constants ¶
This section is empty.
Variables ¶
var GoogleResolver = &net.Resolver{ PreferGo: true, Dial: func(ctx context.Context, network, address string) (net.Conn, error) { d := net.Dialer{ Timeout: time.Millisecond * time.Duration(10000), } return d.DialContext(ctx, network, "8.8.8.8:53") }, }
var LoopbackIPUint uint32
var PrivateCIDRUint = []uint32{167772160, 184549375, 2886729728, 2887778303, 3232235520, 3232301055} // 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
var R interface { LookupAddr(ctx context.Context, addr string) ([]string, error) LookupCNAME(ctx context.Context, host string) (string, error) LookupHost(ctx context.Context, host string) (addrs []string, err error) // LookupIP(ctx context.Context, network, host string) ([]net.IP, error) LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error) LookupMX(ctx context.Context, name string) ([]*net.MX, error) LookupNS(ctx context.Context, name string) ([]*net.NS, error) LookupPort(ctx context.Context, network, service string) (port int, err error) LookupSRV(ctx context.Context, service, proto, name string) (string, []*net.SRV, error) LookupTXT(ctx context.Context, name string) ([]string, error) } = GoogleResolver
Functions ¶
func BigEndianUint64 ¶
func BreakBaseURL ¶
func ByteSlice2String ¶
Do not apply it after a String2ByteSlice was applied
func CheckPasswordHash ¶
func CombineMonthYear ¶
func ContainsDotDot ¶
func DumpCookie ¶
func EqualDomain ¶
func ExtractRootDomain ¶
ExtractRootDomain extracts the EffectiveTLDPlusOne, see https://godoc.org/golang.org/x/net/publicsuffix#EffectiveTLDPlusOne for more explanations
func FileExists ¶
func ForceIPHTTPClient ¶
func ForceIPWebsocketDialer ¶
func FormatHelloServerName ¶
func GetLocalPrivateIP ¶
func GetLocalPublicIP ¶
func GetMonthYear ¶
func GuessImageFormat ¶
Guess image format from gif/jpeg/png/webp
func HashPassword ¶
func InitLogging ¶
func InitLogging(level string)
func IsAlphaNumHyphen ¶
func IsIPPrivateRFC1918 ¶
IsIPPrivateRFC1918 -> See https://tools.ietf.org/html/rfc1918
func IsMultipart ¶
IsMultipart returns true if the given request is multipart forrm
func IsPowerOf2 ¶
func IsSlashRune ¶
func IsValidEmail ¶
func IsValidPassword ¶
func IsWebSocketRequest ¶
func Max ¶
func Max[T constraints.Ordered](x, y T) T
func Min ¶
func Min[T constraints.Ordered](x, y T) T
func NextHighestPowerOf2 ¶
func ReadSetCookies ¶
from response header Set-Cookie
func Redirect2HTTPS ¶
func Redirect2HTTPS(w http.ResponseWriter, req *http.Request)
func SecureToken32 ¶
func SendErrorAndLog ¶
func SendInternalError ¶
func SendInternalError(w http.ResponseWriter, origin string, err error)
func SendSuccess ¶
func SendSuccess(w http.ResponseWriter, resp interface{})
func SetKeepaliveParameters ¶
Sets additional keepalive parameters. Uses new interfaces introduced in Go1.11, which let us get connection's file descriptor, without blocking, and therefore without uncontrolled spawning of threads (not goroutines, actual threads).
func SplitHostPort ¶
func SplitSlash ¶
func String2ByteSlice ¶
Do not apply it after a ByteSlice2String was applied
func UniqueSecureID120 ¶
func UniqueSecureID36 ¶
func UniqueSecureID60 ¶
func UploadFileMultipart ¶
func UploadFolderMultipart ¶
Types ¶
type CertificateAuthority ¶
type CertificateAuthority struct {
// contains filtered or unexported fields
}
func NewCertificateAuthority ¶
func NewCertificateAuthority(organization pkix.Name) (*CertificateAuthority, error)
func UnmarshalCertificateAuthority ¶
func UnmarshalCertificateAuthority(b []byte) (*CertificateAuthority, error)
func (*CertificateAuthority) CertificateBytes ¶
func (ca *CertificateAuthority) CertificateBytes() []byte
func (*CertificateAuthority) CreateDNSRSACertificate ¶
func (ca *CertificateAuthority) CreateDNSRSACertificate(dnsNames []string) (tls.Certificate, error)
func (*CertificateAuthority) Marshal ¶
func (ca *CertificateAuthority) Marshal() ([]byte, error)
type JSONErr ¶
type JSONErr struct { Success bool `json:"success"` Message string `json:"message,omitempty"` Code string `json:"code,omitempty"` }
func UnmarshalJSONErr ¶
type LimitedBuffer ¶
LimitedBuffer is like a bytes.Buffer but dumps everything that exceeds maxLen
func NewLimitedBuffer ¶
func NewLimitedBuffer(maxLen int) *LimitedBuffer
NewLimitedBuffer returns a new Limitedbuffer with a defined maxLen
func (*LimitedBuffer) Bytes ¶
func (b *LimitedBuffer) Bytes() []byte
func (*LimitedBuffer) CopyBytes ¶
func (b *LimitedBuffer) CopyBytes() []byte
func (*LimitedBuffer) String ¶
func (b *LimitedBuffer) String() string
type ProxyReader ¶
type ProxyReader struct {
// contains filtered or unexported fields
}
func NewProxyReader ¶
func NewProxyReader(underlying io.Reader, progress chan int) *ProxyReader