Documentation ¶
Index ¶
- Constants
- Variables
- func Authenticate(rq *Request, resp *Response) error
- func Base64ToBytes(s string) []byte
- func Base64ToKey(s string) *[32]byte
- func BytesToBase64(b []byte) string
- func Colorize(level int, msg string) string
- func Decrypt(ciphertext []byte, key *[32]byte) (plaintext []byte, err error)
- func DecryptString(s string, key *[32]byte) (string, error)
- func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) []byte
- func Encrypt(plaintext []byte, key *[32]byte) (ciphertext []byte, err error)
- func EncryptString(s string, key *[32]byte) (string, error)
- func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) []byte
- func ExportPrivate_PEM_Key(key *rsa.PrivateKey, filename string)
- func ExportPublic_PEM_Key(key *rsa.PublicKey, filename string)
- func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
- func GetMACAddr() (string, error)
- func ImportPrivate_PEM_Key(filename string) *rsa.PrivateKey
- func ImportPublic_PEM_Key(filename string) *rsa.PublicKey
- func KeyToBase64(key *[32]byte) string
- func LogMiddleware(rq *Request, resp *Response)
- func NewEncryptionKey() *[32]byte
- func PadStr(s string, l int) string
- func PrivKeySTR_to_PrivKey(privkeystr string) *rsa.PrivateKey
- func PubKeySTR_to_PubKey(pubkeystr string) *rsa.PublicKey
- func TransferCookies(rq *Request, resp *Response)
- func TransferValues(rq *Request, resp *Response)
- func TrimExtraSpaces(s string) string
- func UnpadStr(s string) string
- func WrapTime(t string, msg string) string
- type Client
- func (c *Client) Addr() string
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) ParseResponse(rq *Request, header map[string]string, recv_data []byte) (*Response, error)
- func (c *Client) Send(rq *Request) (*Response, error)
- func (c *Client) UpdateCookies(remember map[string]string, forget []string)
- func (c *Client) Vault(key string, value string) error
- type Config
- type Cookie
- type Cookies
- type FileData
- type Logger
- type Middleware
- type Request
- func (rq *Request) AddCookie(key string, value string)
- func (rq *Request) AddFile(filename string, file []byte, boundary string)
- func (rq *Request) AddHeader(key string, value string)
- func (rq *Request) ContentLength() int
- func (rq *Request) DecryptVault() map[string]string
- func (rq *Request) Generate() ([]byte, error)
- func (rq *Request) MacAddr() string
- func (rq *Request) ParseFile() error
- func (rq *Request) ParseFileData() ([]byte, error)
- func (rq *Request) SysInfo() *SysInfo
- type Response
- func (resp *Response) AddError(err string)
- func (resp *Response) AddFile(filename string, file []byte, boundary string)
- func (resp *Response) Bytes() []byte
- func (resp *Response) ContentLength() int
- func (resp *Response) DecodeHeaders(headers map[string]string) (map[string]string, []string, error)
- func (resp *Response) Forget(key string) *Response
- func (resp *Response) ForgetVault(key string)
- func (resp *Response) GenHeader() string
- func (resp *Response) Generate() []byte
- func (resp *Response) GetVault(key string) (string, bool)
- func (resp *Response) Lock(key string, value string) *Response
- func (resp *Response) ParseFile() error
- func (resp *Response) ParseFileData() ([]byte, error)
- func (resp *Response) Remember(k string, v string) *Response
- type Server
- func (s *Server) AddCallback(key string, callback func(rq *Request, resp *Response))
- func (s *Server) AddMiddlewareAfterResp(middleware func(rq *Request, resp *Response))
- func (s *Server) AddMiddlewareBeforeResp(middleware func(rq *Request, resp *Response))
- func (s *Server) Addr() string
- func (s *Server) DecryptClientVault(rq *Request) error
- func (s *Server) ExecCallback(rq *Request, resp *Response) error
- func (s *Server) MiddlewareAfterResponse(rq *Request, resp *Response)
- func (s *Server) MiddlewareBeforeResponse(rq *Request, resp *Response)
- func (s *Server) ParseConnection(conn net.Conn) (*Request, *Response, error)
- func (s *Server) Send(conn net.Conn, resp *Response) error
- func (s *Server) Serve() error
- func (s *Server) Start() error
- type SysInfo
- type User
Constants ¶
const ( DISABLED = 0 KILOBYTE = 1024 MEGABYTE = 1024 * KILOBYTE GIGABYTE = 1024 * MEGABYTE TEN_GIGABYTE = 10 * GIGABYTE )
Variables ¶
var CONF = InitConfig("SECRET_KEY", "DEBUG", 2048, DISABLED, true, true, PEM, Authenticate)
var PEM embed.FS
Functions ¶
func Authenticate ¶
func Base64ToBytes ¶
func Base64ToKey ¶
func BytesToBase64 ¶
func Decrypt ¶
Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.
func DecryptWithPrivateKey ¶
func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) []byte
DecryptWithPrivateKey decrypts data with private key
func Encrypt ¶
Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.
func EncryptWithPublicKey ¶
EncryptWithPublicKey encrypts data with public key
func ExportPrivate_PEM_Key ¶
func ExportPrivate_PEM_Key(key *rsa.PrivateKey, filename string)
func ExportPublic_PEM_Key ¶
func GenerateKeyPair ¶
func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
func GetMACAddr ¶
func ImportPrivate_PEM_Key ¶
func ImportPrivate_PEM_Key(filename string) *rsa.PrivateKey
func ImportPublic_PEM_Key ¶
func KeyToBase64 ¶
func LogMiddleware ¶
func NewEncryptionKey ¶
func NewEncryptionKey() *[32]byte
NewEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt(). It panics if the source of randomness fails.
func PrivKeySTR_to_PrivKey ¶
func PrivKeySTR_to_PrivKey(privkeystr string) *rsa.PrivateKey
func PubKeySTR_to_PubKey ¶
func TransferCookies ¶ added in v1.6.8
func TransferValues ¶
func TrimExtraSpaces ¶
Types ¶
type Client ¶
type Client struct { IP string Port int Conn net.Conn Cookies map[string]*Cookie ClientVault map[string]string PUBKEY *rsa.PublicKey }
func (*Client) ParseResponse ¶
func (*Client) UpdateCookies ¶
type Config ¶
type Config struct { SecretKey string LOGGER *Logger BUFF_SIZE int Default_Auth func(rq *Request, resp *Response) error Include_Sysinfo bool Use_Crypto bool MAX_CONTENT_LENGTH int MAX_HEADER_SIZE int FS fs.FS }
func InitConfig ¶
type Cookie ¶
func InitCookie ¶
type Cookies ¶
type Cookies struct {
// contains filtered or unexported fields
}
func InitCookies ¶
func InitCookies() *Cookies
type Middleware ¶
type Request ¶
type Request struct { Headers map[string]string Vault map[string]string Content []byte File *FileData Data map[string]string User *User Conn net.Conn // contains filtered or unexported fields }
func InitRequest ¶
func (*Request) ContentLength ¶
func (*Request) DecryptVault ¶
func (*Request) ParseFileData ¶
type Response ¶
type Response struct { Headers map[string]string SetValues map[string]string DelValues []string Vault map[string]string Content []byte File *FileData Error []error }
func InitResponse ¶
func (*Response) ContentLength ¶
func (*Response) DecodeHeaders ¶
func (*Response) ForgetVault ¶
func (*Response) ParseFileData ¶
type Server ¶
type Server struct { IP string Config *Config Port int Callbacks map[string]func(rq *Request, resp *Response) Middleware []*Middleware PRIVKEY *rsa.PrivateKey // contains filtered or unexported fields }
func (*Server) AddCallback ¶
Add a COMMAND callback to the server
func (*Server) AddMiddlewareAfterResp ¶
Middleware to be used after the response is created
func (*Server) AddMiddlewareBeforeResp ¶
Middleware to be used before the response is created
func (*Server) DecryptClientVault ¶
func (*Server) ExecCallback ¶
Execute the callback for the given request
func (*Server) MiddlewareAfterResponse ¶
Execute middleware after the response is created
func (*Server) MiddlewareBeforeResponse ¶
Execute middleware before the response is created
func (*Server) ParseConnection ¶
type SysInfo ¶
type SysInfo struct { Hostname string `json:"hostname"` Platform string `json:"platform"` CPU string `json:"cpu"` RAM uint64 `json:"ram"` Disk uint64 `json:"disk"` MacAddr string `json:"macaddr"` }
SysInfo saves the basic system information
func GetSysInfo ¶
func GetSysInfo() *SysInfo