Documentation ¶
Overview ¶
Package tcpserver contains the tcp server logic
Index ¶
- type CallBackFunc
- type ContextType
- type Options
- type Rule
- type RulesConfiguration
- type TCPServer
- func (t *TCPServer) AddRule(rule Rule) error
- func (t *TCPServer) BuildResponse(data []byte) ([]byte, error)
- func (t *TCPServer) BuildResponseWithContext(ctx context.Context, data []byte) ([]byte, error)
- func (t *TCPServer) BuildRuleResponse(ctx context.Context, data []byte) ([]byte, error)
- func (t *TCPServer) Close() error
- func (t *TCPServer) ListenAndServe() error
- func (t *TCPServer) ListenAndServeTLS() error
- func (t *TCPServer) LoadTemplate(templatePath string) error
- func (t *TCPServer) MatchRule(data []byte) (rule Rule, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallBackFunc ¶ added in v0.0.5
CallBackFunc handles what is send back to the client, based on the incomming question
type ContextType ¶ added in v0.0.5
type ContextType string
ContextType is the key type stored in ctx
var ( // Addr is the contextKey where the net.Addr is stored Addr ContextType = "addr" )
type Options ¶
type Options struct { Listen string TLS bool Certificate string Key string Domain string Verbose bool // contains filtered or unexported fields }
Options of the tcp server
type Rule ¶
type Rule struct { Name string `yaml:"name,omitempty"` Match string `yaml:"match,omitempty"` MatchContains string `yaml:"match-contains,omitempty"` Response string `yaml:"response,omitempty"` // contains filtered or unexported fields }
Rule to apply to various requests
func NewLiteralRule ¶ added in v0.0.5
NewLiteralRule returns a new literal-match Rule
func NewRegexRule ¶ added in v0.0.5
NewRegexRule returns a new regex-match Rule
func NewRuleFromTemplate ¶ added in v0.0.5
NewRuleFromTemplate "copies" a new Rule
func (*Rule) MatchInput ¶ added in v0.0.5
MatchInput returns if the input was matches with one of the matchers
type RulesConfiguration ¶
type RulesConfiguration struct {
Rules []Rule `yaml:"rules"`
}
RulesConfiguration from yaml
type TCPServer ¶
type TCPServer struct { // Callbacks to retrieve information about the system HandleMessageFnc CallBackFunc // contains filtered or unexported fields }
TCPServer instance
func (*TCPServer) BuildResponse ¶
BuildResponse according to rules
func (*TCPServer) BuildResponseWithContext ¶ added in v0.0.5
BuildResponseWithContext is a wrapper with context
func (*TCPServer) BuildRuleResponse ¶ added in v0.0.5
BuildResponseWithContext is a wrapper with context
func (*TCPServer) ListenAndServe ¶
ListenAndServe requests
func (*TCPServer) ListenAndServeTLS ¶
ListenAndServeTLS requests over tls
func (*TCPServer) LoadTemplate ¶
LoadTemplate from yaml