Commit Graph

7 Commits

Author SHA1 Message Date
Zorchenhimer
fdbf39f00c Add some logging
Functions added:
- LogErrorf()
- LogErrorln()
- LogChatf()
- LogChatln()
- LogInfof()
- LogInfoln()
- LogDebugf()
- LogDebugln()
- LogDevf()
- LogDevln()

New settings configure the logging: LogLevel and LogFile.  LogLevel can
be set to one of: error, chat, info, or debug and will default to
error.  LogFile is an optional file to write to.  Providing a file will
not prevent output in the console.

LogDevf() and LogDevln() only compile when the "dev" flag passed to
build.  This will cause Travis-CI to fail the build if it finds any
calls to either function.
2019-03-24 18:58:59 -04:00
Zorchenhimer
6ef0d6f1a5 Add some debugging info to the client connection 2019-03-23 16:10:04 -04:00
Zorchenhimer
c0d3731b84 Write correct IP in WriteData() error
Return the correct IP address on error during
chatConnection.WirteData().  If the server is behind a reverse proxy,
the connection object will have "127.0.0.1" as the remote address.
2019-03-23 14:53:41 -04:00
Zorchenhimer
62afc2eef9 Fixup ChatRoom.Broadcast()
Use an RW Mutex for chatConnection and use some goroutines when sending
data to clients in Broadcast().  This should prevent blocking on
unresponsive clients.
2019-03-23 14:50:47 -04:00
joeyak
fac6e285bd Add stream stats, minor changes in main, and adding ctrl+c handling
Stream statistics will now print when enabled in settings.json. There is messages in, messages out,
and total time running. The main function was changed so the server setups for the main and rtmp
are in separate functions, and both are started with their own goroutine. OS Interrupt catching was added,
and if stream stats is true, the stats will be printed.
2019-03-21 16:20:50 -04:00
Zorchenhimer
f7b362519d Parse X-Forwarded-For header if provided
Parse the X-Forwarded-For header if it exists in the connection.  This
will allow bans to work if the server is sitting behind an Nginx
reverse proxy (that has been configured to add the header).

Also added a safe-guard to disallow bans for localhost so you cannot
accidentally ban everybody from connecting if the server is behind a
reverse proxy.

This should resolve #49
2019-03-20 16:57:29 -04:00
Zorchenhimer
f18b790c4d Wrap connection reads and writes with a mutex
Wrapping the connection with a mutex prevents the "concurrent write to
websocket connection" panic.  The new functions are ReadData() and
WriteData so as to not collide with ReadJSON() and WriteJSON().
2019-03-16 13:44:18 -04:00