Commit Graph

34 Commits

Author SHA1 Message Date
Zorglube
7c33ba91d1 Factorize runPath() 2020-10-20 00:45:18 +02:00
Zorglube
99f48694ac Log file directory 2020-10-20 00:45:18 +02:00
brosilio
84f3fc5761 Changed settings.go to allow disabling the ratelimits.
Before, the settings parser would automatically reset the ratelimit
times to the default if you set them to zero. You could get around
this by setting the ratelimits to -1, but then the parser would
immediately set them to zero and write to disk. On next launch,
the parser would read the zeros and then reset the values to
default, so you would have to modify your ratelimits every
launch.
2020-08-09 19:36:22 -04:00
Zorchenhimer
630abfe474 Add option to change the RTMP listen address
A new setting has been added to change the address and port that the
RTMP server listens on.  `RtmpListenAddress` in the settings json and
`-r` on the command line.  Both options use the same format:
`host:port`.
2020-06-12 23:58:45 -04:00
Alex Dunn
391db3f0bf emotes: send OAuth secret token to Twitch when fetching emotes
As of last month, requests made to the Twitch Helix API require an OAuth token
as well as the Client ID: https://discuss.dev.twitch.tv/t/requiring-oauth-for-helix-twitch-api-endpoints/23916
2020-06-04 00:32:01 -07:00
Alex Dunn
9b85475fe4 add new setting to suppress join/leave announcements 2020-06-03 19:47:57 -07:00
Alex Dunn
d28d6e7635 sort settings.json 2020-06-03 19:45:54 -07:00
Alex Dunn
677a9fd9cb allow customization of <title> 2020-06-03 12:24:07 -07:00
Zorchenhimer
fab56e39ea Rework emote parsing to properly handle wrapped emotes
Reworked the emote parsing to properly handle "wrapped" emotes.  A
wrapped emote is one that is wrapped in colons or square braces (eg,
:Kappa: or [Kappa]).  This allows emotes to be input without a space
between them, like is required with non-wrapped emotes.

A new configuration setting has been added to only allow parsing of
wrapped emotes: "WrappedEmotesOnly".  This defaults to False as to not
break current configurations.

The emote autocompletion will only insert non-wrapped emotes.  Setting
"WrappedEmotesOnly" configuration value to True will not change this.

Lastly, made the bare-word emote parsing a bit cleaner by removing a for
loop in favor of a map lookup with a check.  This should in theory be
more efficient.

This change is in response to #111.  The issue should not be considered
resolved until the autocompletion handles the new setting correctly.
2020-04-19 12:26:27 -04:00
Zorchenhimer
ce2150f719 Add ability to set admin password at startup
The -a flag has been added to allow specifying a new admin password on
the command line.  This password will only be used for the current
session and will not be written to the configuration file.  If the
password contains spaces, wrap it in quotes on the command line.  The
quotes should be omitted with the /auth command.

Eg, starting the server with:
    ./MovieNight -a "the admin password"
the auth command in chat would be:
    /auth the admin password
2020-04-18 16:02:41 -04:00
Zorchenhimer
c32838def6 Rework settings mutex and saving settings
- Move mutex into Settings struct
- Replace sync.Mutex with a sync.RWMutex
- Move adding approved emotes into a Settings method
- Save settings after adding emotes
- Wrap saving in a lock
2020-01-30 14:32:46 -05:00
joeyak
7962fad02e commiting so zorch can do my work 2019-06-01 19:41:28 -04:00
Zorchenhimer
b41c93d19d Add option to generate new pin on start
Added "NewPin" to the settings to regenarate and save a new pin to the
settings file on server start.
2019-04-15 11:22:53 -04:00
Zorchenhimer
635b4f75c0 Unbreak settings
Don't try and use the global 'settings' variable when it should be
using the local *Settings variable.
2019-03-30 17:46:31 -04:00
Zorchenhimer
4e35418a79 Merge branch 'master' into room-access-restrictions
# Conflicts:
#	common/chatcommands.go
#	main.go
#	settings.go
2019-03-30 16:04:06 -04:00
Zorchenhimer
67b3143893 Add rate limiting
This should fix #65, although it may be expanded in the future.

Default settings for limits can be changed or disabled in the settings.
Default values:
- Chat: 1 second
- Duplicate chat: 30 seconds
- /nick: 5 minutes
- /auth: 5 seconds
- /color: 1 minute

Creation of the chat Client object has been moved from ChatRoom.Join()
to NewClient().  This function also handles setting the initial name.
2019-03-30 15:40:37 -04:00
Zorchenhimer
e7cfcd8688 Move logging setup to LoadSettings() 2019-03-30 15:14:30 -04:00
Zorchenhimer
0a817eff87 Add a NoCache setting
Added this to the settings so it can be configured at runtime.  If set
to true, a Cache-Control header will be sent with the wasm file as well
as the index html.
2019-03-30 15:14:30 -04:00
Zorchenhimer
6f865b7a53 Start adding support to download twitch emotes
The code has been transferred over from the utility, and should work,
but it hasn't been tested nor has it been linked to the command.
2019-03-28 16:22:08 -04:00
Zorchenhimer
857974aef3 Merge branch 'master' into room-access-restrictions
# Conflicts:
#	main.go
#	settings.go
2019-03-26 12:06:25 -04:00
joeyak
f60bd33011 Remove inits since it is startup code 2019-03-24 23:54:24 -04:00
joeyak
86207ecd48 Added spoilers in chat
If a user clicks the spoiler, it will change color and the background will revert.
closes #62
2019-03-24 23:43:30 -04:00
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
44e8947329 Print the new modes and pins to the console
- When the access mode changes, print the new mode (and pin, if
  applicable) to the server console.
- Don't return an HTTP error when getting a session fails, just make a
  new session.
- Save pins to the settings
2019-03-23 18:08:22 -04:00
Zorchenhimer
82149cda0c Start adding room access restrictions
So far only PIN and Open modes are implemented.  It uses a session
cookie to store the validity of the pin/password.

The "Enter pin" page has some unreadable messages on it right now, but
it kinda works.
2019-03-22 21:39:55 -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
b30202441a Add a limit to the title length
Added a limit to how long the title can be when set from the /playing
command.  The default value is 50 if it is not in the settings file or
if the value in the settings is below zero.

Resolves #43
2019-03-16 21:06:16 -04:00
joeyak
6a2cb3f906 Fix some linting errors with error messages 2019-03-14 15:19:36 -04:00
Zorchenhimer
1cd490b04a Add single-use mod passwords
Single-use moderator passwords can only be generated by an admin with
the /modpass command.  To redeem the password and gain moderator
privileges, a user just needs to call /auth with the password.

The passwords are generated using the same function as the admin
password.  Additionally, generating passwords now uses crypto/rand
instead of math/rand.

Resolves #15
2019-03-13 16:51:07 -04:00
joeyak
d77078edc3 divs in #messages are removed after set count maxes out. Default is 300
closes #20
2019-03-13 00:02:36 -04:00
Zorchenhimer
1a217775ff Fix stream key loading
Somehow I broke this without noticing.  Also, If a stream key is
provided as a command line flag, load it but do not save it to
settings.json.
2019-03-11 23:45:23 -04:00
Zorchenhimer
2879ab2c95 Add stream key and listen address to settings.json
This resolves #14.  If the stream key or address are passed on the
command line, those values take precedence over whatever is in the
settings file.
2019-03-11 23:05:01 -04:00
Zorchenhimer
3276295421 Initial commit
So far things work.  Needs lots of improvements.
2019-03-10 11:42:12 -04:00