route

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 17 Imported by: 0

README

route

Route Represents the routing and listening to connections. This module takes care of the communication links to users and clients. They will forward commands to data driven modules in /data. The Listener module makes sure to listen to connections over TCP and HTTP (maybe Websocket too later.) We also have the parser which uses the policy directives to break apart the user payloads into understandable commands. Secure takes care of any encryption necessary over the wire.

Documentation

Overview

Route Represents the routing and listening to connections. This module takes care of the communication links to users and clients. They will forward commands to data driven modules in `/data`. The Listener module makes sure to listen to connections over TCP and HTTP (maybe Websocket too later.) We also have the parser which uses the policy directives to break apart the user payloads into understandable commands. Secure takes care of any encryption necessary over the wire.

Index

Constants

View Source
const CommandBytes = 3

Size of Packet Header for TCP commands Byte 1 :: Metadata/Parsing info Byte 2 :: More Significant byte for Command Byte 3 :: Lesser Significant byte for Command

View Source
const CrtLocation string = "./tlscert.crt"

TLS Certificate File Location from root of the project

View Source
const HttpHost string = "127.0.0.1"

HTTP Listening Host IP

View Source
const HttpPort string = ":80"

HTTP Host Listening Port Number

View Source
const IoDeadline time.Duration = 5 * time.Second

Time spent waiting for incomming connections before checking for control signals/shutoff/etc

View Source
const KeyLocation string = "./tlskey.key"

TLS Key File Location from root of the project

View Source
const ListeningSSLPortNumber string = ":26006"

SSL Port Number to Listen for connections on

View Source
const ListeningTCPIpAddress string = "127.0.0.1"

TCP IP Mask to listen for connections on

View Source
const ListeningTCPPortNumber string = ":26005"

TCP Port number to listen for connections on

View Source
const NumberOfSSLThreads = 5

Limit of Goroutines used for listening on SSL. 5 is a good number for testing, but a better number would be much higher.

View Source
const NumberOfTCPThreads = 10

Limit of Goroutines used for listening on TCP. 5 is a good number for testing, but a better number would be much higher.

View Source
const ShutdownDuration time.Duration = 10 * time.Second

Time for shutdown. Quitting Mid Handle is really bad. This should be longer than any duration

Variables

View Source
var MalformedDataMsg []byte = []byte("{\"success\": false, \"error\": \"Data Was Malformed!\"}")

Constant byte string of JSON representing a data malformed error May be moved to Policy

View Source
var MalformedDataMsgLen int = len([]byte("{\"success\": false, \"error\": \"Data Was Malformed!\"}"))

Constant integer length of a JSON byte string representing a data malformed error May be moved to Policy

View Source
var SecureConnectionMsg []byte = []byte("{\"success\": true, \"message\": \"SECURED!\"}")

Constant byte string of JSON representing a Secured Connection May be moved to Policy

View Source
var SecureConnectionMsgLen int = len([]byte("{\"success\": true, \"message\": \"SECURED!\"}"))

Constant integer length of a JSON byte string representing a Secured Connection May be moved to Policy

Functions

func NeedsSecurity

func NeedsSecurity(cmd policy.ClientCmd) bool

returns if the given command needs an encrypted connection or not

see "secureMap"

func ParseCommand

func ParseCommand(mostSignificant byte, leastSignificant byte) (policy.ClientCmd, error)

Parse Command takes a two byte code and returns the associated command or an error if it doesn't exist. Used mainly in TCP Request Parsing

func SigVerification

func SigVerification(authID string, signature string, content *[]byte) error

Typical Verification of users for authentication. Used in most other endpoints as SigVerify in RequestBodyFactories

Takes the authID, Signature (hash of token and content), and content to see if the user can indeed make the request (they are who they say they are).

returns an error if they are not who they say they are.

func StartEncryption

func StartEncryption() (func(), error)

ServerTask Startup Function for Encryption. Takes care of initialization. Loads Certificates and Keys from files and configures TLS.

func StartListener

func StartListener() (func(), error)

ServerTask Startup Function for Conneciton Listening. Takes care of initialization.

func TestHelperGenSig added in v0.0.3

func TestHelperGenSig(token *[]byte, content string, counter int) string

Types

type TCPClientConn

type TCPClientConn struct {
	// contains filtered or unexported fields
}

Wrapper Structure with boolean fields for a TCP Connection. used to easily differentiate between secure and insecure connections. It also helps in deciding if the TCP connection needs to parse more requests (HTTP requests close connections after one requests, but TCP connections do not.)

type TCPRequestPrefix

type TCPRequestPrefix struct {
	IsBase64Enc bool // First Most Sig Bit
	IsJSON      bool // Second Most Sig Bit
}

First byte of a TCP request. This is a struct of booleans about how the request is structured over TCP.

Jump to

Keyboard shortcuts

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