controlserver

package
v0.5.0-beta Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2015 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package server implements a server following its own custom protocol. The protocol works as follows.

  1. A client connects and sends an object in JSON format matching the structure of the Request type.

  2. The server returns a single character. "t" means that the request is valid. "f" means that the request is invalid (either an attack or an error).

  3. The client disconnects or goes again from step 1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Direction string
	Value     interface{}
}

Request is a struct that follows the format that is expected for requests.

func ReadRequest

func ReadRequest(r io.Reader) (*Request, error)

ReadRequest reads a request from a Reader.

type Server

type Server struct {
	HandleFunc      func(*Request) bool
	AcceptedSources map[string]bool
	// contains filtered or unexported fields
}

Server is a server that interprets requests according to the protocol.

func New

func New() *Server

func (*Server) Close

func (s *Server) Close()

Close stops the server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(typ, addr string) error

Blocks and listens for requests.

Jump to

Keyboard shortcuts

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