runtelchat

package module
v0.0.0-...-9bb782d Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Unlicense Imports: 11 Imported by: 0

README

runtelchat

runtelchat is a chat server made for a coding exersize. This is a TCP chat server that will accept tcp connections on the configured port and relay messages between multiple tcp clients.

runtelhat is a play on words of the telnet client meant to be used as a redumentory client

The main entry point is in /cmd/runtelchat.

Getting Started

Once you either clone this repository or download the .zip file, navigate to {project root}/cmd/runtelchat and perform go build. Then you may execute ./runtelchat

Prerequisites

Only requires Go and a configured GOPATH

Configuration

A default configuration file is provided, if no configuration file exists, then a configuration identical to this default file will be used. The config file should be named config.json and be in the same directory as the compiled application. This app uses a .json configuration file.

Configuration Items
  • host - IP or Hostname of the machine to accept connections on
  • port - port to use
  • logFilePath - location of the log file

Running the tests

This is a normal Go project so tests are in the root directory and you make execute them with "go test". I'll admit the test suite is pretty thin at this point.

Dependencies and Third Party Code

Right now all dependencies are vendored into the vendor folder, so no action should be needed for them.

Lumberjack

This lib is used for rolling logging, simplifing logging GoDoc

pkg/errors

The errors package is used to provide error wrapping GoDoc

Known issues

  • Unit Tests need to be expanded

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(config Config) error

ListenAndServe opens tcp listeners for the given the specified configuration

Types

type ChatServer

type ChatServer struct {
	Errors chan error

	sync.RWMutex
	// contains filtered or unexported fields
}

ChatServer is a TCP chat server capable of running on multiple ports

func NewChatServer

func NewChatServer() *ChatServer

NewChatServer instatiates a new chat server

func (*ChatServer) Listen

func (server *ChatServer) Listen(listener net.Listener)

Listen will accept connections on a the listener

func (*ChatServer) Serve

func (server *ChatServer) Serve() error

Serve blocks and coordinates between listeners the server

type Config

type Config struct {
	Port        string `json:"port"`
	Host        string `json:"host"`
	LogFilePath string `json:"logFilePath"`
}

Config represents the configuration of the chat server

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig loads the config file from the current directory or the default config if no config file exists

type Message

type Message struct {
	Text      string
	From      string
	Address   string
	TimeStamp time.Time
	// contains filtered or unexported fields
}

Message represents a chat message

func (Message) String

func (m Message) String() string

String is the stringer interface

Directories

Path Synopsis
cmd
runtelchat command

Jump to

Keyboard shortcuts

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