Documentation ¶
Index ¶
- func KeyGenN(prefix string, keylen, size int) ([]string, error)
- func NormalizeKey(key string) (string, bool)
- func SetLogger(l Logger)
- type KeyInfo
- type Logger
- type Pack
- type PackInfo
- type Server
- func (s *Server) AddPack(name string, prefix string, keylen, packsize int, note string) error
- func (s *Server) DisablePack(name string, msg string) error
- func (s *Server) EnablePack(name string) error
- func (s *Server) HTTPServeMux() *http.ServeMux
- func (s *Server) ListKeys(packName string) ([]KeyInfo, error)
- func (s *Server) ListPacks() []PackInfo
- func (s *Server) RemovePack(name string) error
- func (s *Server) Stop()
- func (s *Server) UseKey(packName, key string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyGenN ¶
KeyGenN generates a set of CDKEYs, which guaranteed to be unique and sorted.
It returns error if 1) `prefix` is not valid base32 format; 2)
32^(keylen-len(prefix)) < size * 100,
which means a randomly generated key has a chance more than 1% to be valid.
func NormalizeKey ¶
NormalizeKey transforms a key to base32 format.
All lowercase letters will be converted to uppercase, 'O'/'o' will be replaced by '0', 'L'/'l' and 'I'/'i' will be replaced by '1'.
If the given key contains any non-digital non-alphbetic character or 'U'/'u', it returns an empty string and false.
Types ¶
type Logger ¶
type Logger interface { Info(v ...interface{}) Error(v ...interface{}) }
Logger is a simple interface contains 2 log levels. The cdkey lib user is responsable for implementing Logger methods.
type Pack ¶
type Pack struct { Name string // contains filtered or unexported fields }
func CreatePack ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) EnablePack ¶
func (*Server) HTTPServeMux ¶
func (*Server) RemovePack ¶
Click to show internal directories.
Click to hide internal directories.