libstar

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRINT = 0x00
	DEUBG = 0x01
	INFO  = 0x02
	WARN  = 0x03
	ERROR = 0x04
	FATAL = 0xff
)

Variables

View Source
var (
	Version string
	Date    string
	Commit  string
)
View Source
var DIR = Dir{}
View Source
var JSON = jsonUtils{}
View Source
var Log = Logger{
	Level:    INFO,
	FileName: ".log.error",
	Errors:   list.New(),
}
View Source
var XML = xmlUtils{}

Functions

func BasicAuth

func BasicAuth(username, password string) string

func Catch

func Catch(name string)

func Close

func Close()

func Debug

func Debug(format string, v ...interface{})

func Error

func Error(format string, v ...interface{})

func Fatal

func Fatal(format string, v ...interface{})

func FunName

func FunName(i interface{}) string

func GenEthAddr

func GenEthAddr(n int) []byte

func GenToken

func GenToken(n int) string

func GenUUID

func GenUUID() string

func GetJSON

func GetJSON(r io.ReadCloser, v interface{}) error

func GetLocalTime added in v0.9.1

func GetLocalTime(layout, value string) (time.Time, error)

func H2D16

func H2D16(h string) uint16

func H2D8

func H2D8(h string) uint8

func IP4Network2Range

func IP4Network2Range(addr, mask net.IP) (net.IP, net.IP)

func IP4Network2RangeN

func IP4Network2RangeN(addr, mask net.IP, n uint32) (net.IP, net.IP)

func Info

func Info(format string, v ...interface{})

func Init

func Init(file string, level int)

func IsDigit

func IsDigit(s string) bool

func Netmask2Len

func Netmask2Len(s string) int

func ParseIP4Netmask

func ParseIP4Netmask(addr, prefix string) (net.IP, net.IP)

func PreNotify

func PreNotify()

func PrettyBytes

func PrettyBytes(b uint64) string

func PrettyDrive

func PrettyDrive(ctl, bus, tgt, unit uint16) string

func PrettyKBytes

func PrettyKBytes(k uint64) string

func PrettyPCI

func PrettyPCI(dom, bus, slot, fun uint16) string

func PrettySecs

func PrettySecs(t uint64) string

func Print

func Print(format string, v ...interface{})

func SavePID

func SavePID(file string) error

func SdNotify

func SdNotify()

func SetLog

func SetLog(level int)

func ToBytes

func ToBytes(v, u string) uint64

func ToKiB

func ToKiB(v, u string) uint64

func Wait

func Wait()

func Warn

func Warn(format string, v ...interface{})

Types

type Auth

type Auth struct {
	Type     string
	Username string
	Password string
}

type Dir

type Dir struct {
}

func (Dir) ListDirs

func (d Dir) ListDirs(dirPth string) (dirs []string, err error)

func (Dir) ListFiles

func (d Dir) ListFiles(dirPth string, suffix string) (files []string, err error)

type Err

type Err struct {
	Code    int
	Message string
}

func NewErr

func NewErr(message string, v ...interface{}) (e *Err)

func (*Err) Error

func (e *Err) Error() string

func (*Err) String

func (e *Err) String() string

type HttpClient

type HttpClient struct {
	Method    string
	Url       string
	Payload   io.Reader
	Auth      Auth
	TlsConfig *tls.Config
	Client    *http.Client
}

func (*HttpClient) Close

func (cl *HttpClient) Close()

func (*HttpClient) Do

func (cl *HttpClient) Do() (*http.Response, error)

type Logger

type Logger struct {
	Level    int
	FileName string
	FileLog  *log.Logger
	Lock     sync.Mutex
	Errors   *list.List
}

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

func (*Logger) List

func (l *Logger) List() <-chan *Message

func (*Logger) Print

func (l *Logger) Print(format string, v ...interface{})

func (*Logger) SaveError

func (l *Logger) SaveError(level string, format string, v ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(format string, v ...interface{})

type Message

type Message struct {
	Level   string `json:"level"`
	Date    string `json:"date"`
	Message string `json:"message"`
}

type PProf

type PProf struct {
	Listen string
}

func (*PProf) Start

func (p *PProf) Start()

type Proxy

type Proxy struct {
	Auth      Auth
	Prefix    string
	Server    string
	Url       *url.URL
	TlsConfig *tls.Config
}

func (*Proxy) GetPath

func (pri *Proxy) GetPath(req *http.Request) string

func (*Proxy) Initialize

func (pri *Proxy) Initialize()

type ProxyUrl

type ProxyUrl struct {
	Proxy
	Transport *http.Transport
	Filter    func(*http.Response, http.ResponseWriter, interface{}) bool
	Data      interface{}
}

func (*ProxyUrl) Handler

func (pri *ProxyUrl) Handler(w http.ResponseWriter, req *http.Request)

func (*ProxyUrl) Initialize

func (pri *ProxyUrl) Initialize()

func (*ProxyUrl) ServeHttp

func (pri *ProxyUrl) ServeHttp(w http.ResponseWriter, r *http.Request)

type ProxyWs

type ProxyWs struct {
	Proxy
}

func (*ProxyWs) Dial

func (pri *ProxyWs) Dial(url_, protocol, origin string) (ws *websocket.Conn, err error)

func (*ProxyWs) Socket

func (pri *ProxyWs) Socket(ws *websocket.Conn)

type WaitOne

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

func NewWaitOne

func NewWaitOne(n int) *WaitOne

func (*WaitOne) Done

func (w *WaitOne) Done()

func (*WaitOne) Wait

func (w *WaitOne) Wait()

Jump to

Keyboard shortcuts

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