Documentation ¶
Index ¶
- Constants
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type BinFileStorage
- type ClientMessage
- type ConfigManager
- type CtrlChanMsg
- type FileStorage
- type LogMessage
- type MsgHandler
- type MsgRouter
- type Server
- type ServerConfig
- type ServerManager
- type Storage
- type TCPServer
- type UDPServer
- type WSClientMessage
- type WebChanMsg
- type WebClientMgr
- func (wcm *WebClientMgr) ReconnectSession(chanID int) (chan LogMessage, chan CtrlChanMsg)
- func (wcm *WebClientMgr) StartServer(client string, config *ServerConfig) (chan LogMessage, chan CtrlChanMsg)
- func (wcm *WebClientMgr) StartSession(w http.ResponseWriter, r *http.Request)
- func (wcm *WebClientMgr) StartWSSession(w http.ResponseWriter, r *http.Request, conn *websocket.Conn) (string, []chan LogMessage, []chan CtrlChanMsg)
- func (wcm *WebClientMgr) StopSession(id string)
- type WebServer
Constants ¶
const ( //BadMsg represents bad messages BadMsg = -1 //InitMsg Initialization Message InitMsg = 0 //DataMsg Data Message DataMsg = 1 //ReqMsg New request Message ReqMsg = 2 //ErrMsg Error Message ErrMsg = 3 //CtrlMsg Control Message CtrlMsg = 4 //RestartMsg Restart Message RestartMsg = 5 //StartMsg Start Message StartMsg = 100 //AckStartMsg acknowledge start Message AckStartMsg = 101 //StopMsg Stop Message StopMsg = 255 )
const (
//CookieName the cookie key that represents the session
CookieName = "lbid"
)
const (
//MaxReadBuffer Max mempory allocated to a server socket for listening
MaxReadBuffer = 1048576
)
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func RestoreAsset ¶
Restore an asset under the given directory
func RestoreAssets ¶
Restore assets under the given directory recursively
Types ¶
type BinFileStorage ¶
type BinFileStorage struct { Location *url.URL //location of the storage file MsgChan chan LogMessage //Channel to recieve messages from LogFile *os.File //File the file being used }
BinFileStorage Store logs in a binary format
func NewBinFileStorage ¶
func NewBinFileStorage(loc *url.URL) *BinFileStorage
NewBinFileStorage Create an initialized NewBinFileStorage
func (*BinFileStorage) Close ¶
func (s *BinFileStorage) Close() error
Close Close the file for writing
func (*BinFileStorage) Read ¶
func (s *BinFileStorage) Read(data ...[]byte) error
Read Reads data from the
func (*BinFileStorage) SetDest ¶
func (s *BinFileStorage) SetDest(dest string) error
SetDest Set the destination URL for writing
func (*BinFileStorage) Write ¶
func (s *BinFileStorage) Write(data ...LogMessage) error
Write Write data to the destination file
type ClientMessage ¶
type ClientMessage struct { Type int `json:"type"` //Type Message type Channel int `json:"channel"` // channel to listen on ServerConfig ServerConfig `json:"serverconfig"` //ServerConfig configuration of requested server }
ClientMessage Messages sent from the websocket client
type ConfigManager ¶
type ConfigManager struct { }
ConfigManager manages loading a configuration file for logbuddy
type CtrlChanMsg ¶
type CtrlChanMsg struct { Type int //Type message type Message []byte //Message string message to include with msg }
CtrlChanMsg control channel message format
func (*CtrlChanMsg) MarshalJSON ¶
func (c *CtrlChanMsg) MarshalJSON() ([]byte, error)
MarshalJSON returns json []byte of CtrlChanMsg
func (*CtrlChanMsg) String ¶
func (c *CtrlChanMsg) String() string
String return string format of message
type FileStorage ¶
type FileStorage struct { Location *url.URL //location of the storage file MsgChan chan LogMessage //Channel to recieve messages from LogFile *os.File //File the file being used }
FileStorage Allows data to be written to a file
func NewFileStorage ¶
func NewFileStorage(loc *url.URL) *FileStorage
NewFileStorage Create an initialized NewFileStorage
func (*FileStorage) Read ¶
func (s *FileStorage) Read(data ...[]byte) error
Read Reads data from the
func (*FileStorage) SetDest ¶
func (s *FileStorage) SetDest(dest string) error
SetDest Set the destination URL for writing
func (*FileStorage) Write ¶
func (s *FileStorage) Write(data ...LogMessage) error
Write Write data to the destination file
type LogMessage ¶
type LogMessage struct { Message []byte `json:"Message"` //Message SrcIP net.IP `json:"srcip"` //Src IP of Message SrcPort int `json:"srcport"` //Src Port of Message DstIP net.IP `json:"destip"` //Dst IP of Message DstPort int `json:"destport"` //Dest Port of Message Network string `json:"network"` //Network type of Message tcp,tcp4,tcp6,udp,udp4,udp6 }
LogMessage A message containing a log
func (*LogMessage) MarshalJSON ¶
func (m *LogMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns json []byte of LogMessage
func (*LogMessage) String ¶
func (m *LogMessage) String() string
String returns string value of LogMessage
type MsgHandler ¶
type MsgHandler struct { Sender chan interface{} Receivers []chan interface{} }
type MsgRouter ¶
type MsgRouter struct {
Handlers map[int]*MsgHandler
}
func (*MsgRouter) RegisterReceivers ¶
func (*MsgRouter) RegisterSender ¶
Register
type Server ¶
type Server interface { Listen() // contains filtered or unexported methods }
Server interface defining the behaviors of a server
type ServerConfig ¶
type ServerConfig struct { ID int `json:"id"` //ID ID of running server, assigned by the server manager Type string `json:"type"` // udp,udp4,udp6,tcp,tcp4,tcp6 IP string `json:"ip"` // IP Address in string format Port int `json:"port"` // Port to listen in, < 1024 requires root permission }
ServerConfig Specifies the network configuration of the server
func (*ServerConfig) MarshalJSON ¶
func (sc *ServerConfig) MarshalJSON() ([]byte, error)
MarshalJSON Returns json marshalled LogMessage
type ServerManager ¶
type ServerManager struct { ServerConfigs map[int]*ServerConfig CtrlChans map[int]chan CtrlChanMsg MsgChans map[int]chan LogMessage ErrChans map[int]chan error // contains filtered or unexported fields }
ServerManager Manages listening servers
func NewServerManager ¶
func NewServerManager() *ServerManager
NewServerManager Creates a new server manager with an initalized CtrlChans map
func (*ServerManager) Register ¶
func (s *ServerManager) Register(id int) (chan LogMessage, chan CtrlChanMsg)
Register Returns the LogMessage channel of an associated server
func (*ServerManager) StartServer ¶
func (s *ServerManager) StartServer(config *ServerConfig) (id int, err error)
StartServer Start a new server with a server config
func (*ServerManager) StopServer ¶
func (s *ServerManager) StopServer(id int) error
StopServer Stop a server specified by IP
type Storage ¶
type Storage interface { Write(...LogMessage) error Read() error //Read data from the SetDest(string) error Open() error //Opens the storage location for writing Close() error //Closes the storage location }
Storage an interface for all storage types
type TCPServer ¶
type TCPServer struct { Config *ServerConfig // contains filtered or unexported fields }
TCPServer A server to listen for TCP messages
func NewTCPServer ¶
func NewTCPServer(errChan chan error, ctrlChan chan CtrlChanMsg, msgChan chan LogMessage, config *ServerConfig) *TCPServer
NewTCPServer Creates a new initialized TCPServer
type UDPServer ¶
type UDPServer struct { Config *ServerConfig // contains filtered or unexported fields }
UDPServer A server to listen for UDP messages
func NewUDPServer ¶
func NewUDPServer(errChan chan error, ctrlChan chan CtrlChanMsg, msgChan chan LogMessage, config *ServerConfig) *UDPServer
NewUDPServer creates a new initialized UDP server
type WSClientMessage ¶
type WSClientMessage struct { Type int `json:"type"` //Type of Message ID int `json:"id"` //ID associated with message Data []byte `json:"data"` //Payload of Message }
WSClientMessage A universal message to send to web socket clients
func (*WSClientMessage) AddDataPayload ¶
func (wscm *WSClientMessage) AddDataPayload(data []byte) error
AddDataPayload adds a []byte payload to Data
func (*WSClientMessage) MarshalJSON ¶
func (wscm *WSClientMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns a JSON version of WSClientMessage
type WebChanMsg ¶
type WebClientMgr ¶
type WebClientMgr struct { Clients map[string]*http.Cookie //maps clients based upon cookies ClientServers map[string][]int // contains filtered or unexported fields }
WebClientMgr manages web clients to ensure persistance across sessions
func NewWebClientMgr ¶
func NewWebClientMgr() *WebClientMgr
NewWebClientMgr Returns an initalized web client manager
func (*WebClientMgr) ReconnectSession ¶
func (wcm *WebClientMgr) ReconnectSession(chanID int) (chan LogMessage, chan CtrlChanMsg)
ReconnectSession Returns an existing Message channel based on chanID
func (*WebClientMgr) StartServer ¶
func (wcm *WebClientMgr) StartServer(client string, config *ServerConfig) (chan LogMessage, chan CtrlChanMsg)
StartServer starts a new server for a web client
func (*WebClientMgr) StartSession ¶
func (wcm *WebClientMgr) StartSession(w http.ResponseWriter, r *http.Request)
StartSession generates a new cookie for clients and adds the session to the WebClientMgr
func (*WebClientMgr) StartWSSession ¶
func (wcm *WebClientMgr) StartWSSession(w http.ResponseWriter, r *http.Request, conn *websocket.Conn) (string, []chan LogMessage, []chan CtrlChanMsg)
StartWSSession Starts a websocket session with the WebClientMgr allows it to setup existing session information
func (*WebClientMgr) StopSession ¶
func (wcm *WebClientMgr) StopSession(id string)
StopSession stops an existing session for a client. Also stops all existing servers.
type WebServer ¶
type WebServer struct { Address string //Address the address to listen on ClientMgr *WebClientMgr //Client manager manages the state of clients // contains filtered or unexported fields }
WebServer Serves the user front end and APIs
func (*WebServer) HomeHandler ¶
func (ws *WebServer) HomeHandler(w http.ResponseWriter, r *http.Request)
func (*WebServer) RegisterLogger ¶
func (ws *WebServer) RegisterLogger(id int) (msgChan chan LogMessage, err error)
RegisterLogger Registers a logger to be sent to the connection
func (*WebServer) ServeStatic ¶
func (ws *WebServer) ServeStatic(w http.ResponseWriter, r *http.Request)
ServeStatic Serves static content
Source Files ¶
- binfile_storage.go
- configmanager.go
- file_storage.go
- jobmanager.go
- logbuddy_bindata.go
- main.go
- messages.go
- messages_ctrl.go
- messages_wsclient.go
- mongodb_storage.go
- msgrouter.go
- server.go
- servermanager.go
- storage.go
- tcpserver.go
- udpserver.go
- webchan.go
- webclientmgr.go
- webserver.go
- webserver_static.go
- webserver_views.go
- webserver_websocket.go