From 745bb322a3210b72a91baa584f4a9cacb3e4f5e1 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 001/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- .gitignore | 2 + Makefile | 7 +- readme.md | 349 +++++++++++++++++++++++++++-------------------------- 3 files changed, 184 insertions(+), 174 deletions(-) diff --git a/.gitignore b/.gitignore index d996f8d..7e1383f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ tags # channel and emote list from twitch subscribers.json +/.settings/ +/.project diff --git a/Makefile b/Makefile index e7fa083..f693306 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,13 @@ # For info on installing extra versions, see this page: # https://golang.org/doc/install#extra_versions +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + TAGS= # Windows needs the .exe extension. -ifeq ($(OS),Windows_NT) +ifeq ($(TARGET),windows) EXT=.exe endif @@ -21,7 +24,7 @@ server: ServerMovieNight static/main.wasm # Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") diff --git a/readme.md b/readme.md index 7a95a42..c1ce743 100644 --- a/readme.md +++ b/readme.md @@ -1,172 +1,177 @@ - -**Table of Contents** - -- [MovieNight stream server](#movienight-stream-server) - - [Build requirements](#build-requirements) - - [Older Go Versions](#older-go-versions) - - [Compile and install](#compile-and-install) - - [Docker build](#docker-build) - - [Building the Container](#building-the-container) - - [Running the Container](#running-the-container) - - [docker-compose](#docker-compose) - - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) - - [Usage](#usage) - - [Configuration](#configuration) - - -# MovieNight stream server - -[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) - -This is a single-instance streaming server with chat. Originally written to -replace Rabbit as the platform for watching movies with a group of people -online. - -## Build requirements - -- Go 1.13 or newer -- GNU Make - -### Older Go Versions - -You can install a newer version of Go alongside your OS's distribution by -following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) - -Once you have that setup add an enviromnent variable named `GO_VERSION` and -set it to the version you installed (eg, `1.14.1`). The Makefile will now use -the newer version. - -### Compile and install - -To just download and run: - -```bash -$ git clone https://github.com/zorchenhimer/MovieNight -$ cd MovieNight -$ make -$ ./MovieNight -``` - -### Docker build -MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. - -#### Building the Container -Install Docker, clone the repository and build: - -```shell -docker build -t movienight . -``` - -#### Running the Container -Run the image once it's built: - -```shell -docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight -``` - -Explanation: -- **-d** runs the container in the background. -- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. -- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. -- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] - -#### docker-compose -docker-compose will automatically build the image, no need to build it manually. - -Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: - -```shell -docker-compose up -d -``` - -This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. - -#### Notes for Running Using docker-compose -The container needs to be restarted to apply any changes you make to *settings.json*. - -## Usage - -Now you can use OBS to push a stream to the server. Set the stream URL to - -```text -rtmp://your.domain.host/live -``` - -and enter the stream key. - -Now you can view the stream at - -```text -http://your.domain.host:8089/ -``` - -There is a video only version at - -```text -http://your.domain.host:8089/video -``` - -and a chat only version at - -```text -http://your.domain.host:8089/chat -``` - -The default listen port is `:8089`. It can be changed by providing a new port -at startup: - -```text -Usage of .\MovieNight.exe: - -e bool - Whether or not to download approved emotes on startup (default "false") - -k string - Stream key, to protect your stream (default: "") - -l string - host:port of the MovieNight (default ":8089") - -r string - host:port of the RTMP server (default ":1935") -``` - -## Configuration - -MovieNight’s configuration is controlled by `settings.json`: - -- `AdminPassword`: users can enter `/auth ` into chat to grant themselves - admin privileges. This value is automatically regenerated unless - `RegenAdminPass` is false. -- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into - MovieNight. Using `/addemotes ` in chat will add to this list. -- `Bans`: list of banned users. -- `LetThemLurk`: if false, announces when a user enters and leaves chat. -- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. -- `LogFile`: the path of the MovieNight logfile, relative to the executable. -- `LogLevel`: the log level, defaults to `debug`. -- `MaxMessageCount`: the number of messages displayed in the chat window. -- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. -- `PageTitle`: The base string used in the `` element of the page. When - the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` -- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. -- `RoomAccess`: the access policy of the chat room; this is managed by the - application and should not be edited manually. -- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. -- `SessionKey`: key used for storing session data (cookies etc.) -- `StreamKey`: the key that OBS will use to connect to MovieNight. -- `StreamStats`: if true, prints statistics for the stream on server shutdown. -- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). -- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes -- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). -- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons - or brackets; e.g., `:PogChamp:` -- `RateLimitChat`: the number of seconds between each message a non-privileged - user can post in chat. -- `RateLimitNick`: the number of seconds before a user can change their nick again. -- `RakeLimitColor`: the number of seconds before a user can change their color again. -- `RateLimitAuth`: the number of seconds between each allowed auth attempt -- `RateLimitDuplicate`: the numeber of seconds before a user can post a - duplicate message. -- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP - header, to prevent caching responses. - -## License - -`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. +<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> +**Table of Contents** + +- [MovieNight stream server](#movienight-stream-server) + - [Build requirements](#build-requirements) + - [Older Go Versions](#older-go-versions) + - [Compile and install](#compile-and-install) + - [Docker build](#docker-build) + - [Building the Container](#building-the-container) + - [Running the Container](#running-the-container) + - [docker-compose](#docker-compose) + - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) + - [Usage](#usage) + - [Configuration](#configuration) + +<!-- markdown-toc end --> +# MovieNight stream server + +[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) + +This is a single-instance streaming server with chat. Originally written to +replace Rabbit as the platform for watching movies with a group of people +online. + +## Build requirements + +- Go 1.13 or newer +- GNU Make + +### Older Go Versions + +You can install a newer version of Go alongside your OS's distribution by +following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) + +Once you have that setup add an enviromnent variable named `GO_VERSION` and +set it to the version you installed (eg, `1.14.1`). The Makefile will now use +the newer version. + +### Compile and install +You have to : + - download ; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" + ; + - choose you `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + ; + - and run ; + +```bash +$ git clone https://github.com/zorchenhimer/MovieNight +$ cd MovieNight +$ make TARGET=windows ARCH=386 +$ ./MovieNight +``` + +### Docker build +MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. + +#### Building the Container +Install Docker, clone the repository and build: + +```shell +docker build -t movienight . +``` + +#### Running the Container +Run the image once it's built: + +```shell +docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight +``` + +Explanation: +- **-d** runs the container in the background. +- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. +- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. +- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] + +#### docker-compose +docker-compose will automatically build the image, no need to build it manually. + +Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: + +```shell +docker-compose up -d +``` + +This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. + +#### Notes for Running Using docker-compose +The container needs to be restarted to apply any changes you make to *settings.json*. + +## Usage + +Now you can use OBS to push a stream to the server. Set the stream URL to + +```text +rtmp://your.domain.host/live +``` + +and enter the stream key. + +Now you can view the stream at + +```text +http://your.domain.host:8089/ +``` + +There is a video only version at + +```text +http://your.domain.host:8089/video +``` + +and a chat only version at + +```text +http://your.domain.host:8089/chat +``` + +The default listen port is `:8089`. It can be changed by providing a new port +at startup: + +```text +Usage of .\MovieNight.exe: + -e bool + Whether or not to download approved emotes on startup (default "false") + -k string + Stream key, to protect your stream (default: "") + -l string + host:port of the MovieNight (default ":8089") + -r string + host:port of the RTMP server (default ":1935") +``` + +## Configuration + +MovieNight’s configuration is controlled by `settings.json`: + +- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves + admin privileges. This value is automatically regenerated unless + `RegenAdminPass` is false. +- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into + MovieNight. Using `/addemotes <username>` in chat will add to this list. +- `Bans`: list of banned users. +- `LetThemLurk`: if false, announces when a user enters and leaves chat. +- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. +- `LogFile`: the path of the MovieNight logfile, relative to the executable. +- `LogLevel`: the log level, defaults to `debug`. +- `MaxMessageCount`: the number of messages displayed in the chat window. +- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. +- `PageTitle`: The base string used in the `<title>` element of the page. When + the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` +- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. +- `RoomAccess`: the access policy of the chat room; this is managed by the + application and should not be edited manually. +- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. +- `SessionKey`: key used for storing session data (cookies etc.) +- `StreamKey`: the key that OBS will use to connect to MovieNight. +- `StreamStats`: if true, prints statistics for the stream on server shutdown. +- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). +- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes +- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). +- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons + or brackets; e.g., `:PogChamp:` +- `RateLimitChat`: the number of seconds between each message a non-privileged + user can post in chat. +- `RateLimitNick`: the number of seconds before a user can change their nick again. +- `RakeLimitColor`: the number of seconds before a user can change their color again. +- `RateLimitAuth`: the number of seconds between each allowed auth attempt +- `RateLimitDuplicate`: the numeber of seconds before a user can post a + duplicate message. +- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP + header, to prevent caching responses. + +## License + +`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. From bd3868bc1645e3ebf62aa6b34633d6285ea0b9eb Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 002/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- .gitignore | 2 + Makefile | 7 +- readme.md | 349 +++++++++++++++++++++++++++-------------------------- 3 files changed, 184 insertions(+), 174 deletions(-) diff --git a/.gitignore b/.gitignore index d996f8d..7e1383f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ tags # channel and emote list from twitch subscribers.json +/.settings/ +/.project diff --git a/Makefile b/Makefile index e7fa083..f693306 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,13 @@ # For info on installing extra versions, see this page: # https://golang.org/doc/install#extra_versions +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + TAGS= # Windows needs the .exe extension. -ifeq ($(OS),Windows_NT) +ifeq ($(TARGET),windows) EXT=.exe endif @@ -21,7 +24,7 @@ server: ServerMovieNight static/main.wasm # Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") diff --git a/readme.md b/readme.md index 7a95a42..8c4e75d 100644 --- a/readme.md +++ b/readme.md @@ -1,172 +1,177 @@ -<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> -**Table of Contents** - -- [MovieNight stream server](#movienight-stream-server) - - [Build requirements](#build-requirements) - - [Older Go Versions](#older-go-versions) - - [Compile and install](#compile-and-install) - - [Docker build](#docker-build) - - [Building the Container](#building-the-container) - - [Running the Container](#running-the-container) - - [docker-compose](#docker-compose) - - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) - - [Usage](#usage) - - [Configuration](#configuration) - -<!-- markdown-toc end --> -# MovieNight stream server - -[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) - -This is a single-instance streaming server with chat. Originally written to -replace Rabbit as the platform for watching movies with a group of people -online. - -## Build requirements - -- Go 1.13 or newer -- GNU Make - -### Older Go Versions - -You can install a newer version of Go alongside your OS's distribution by -following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) - -Once you have that setup add an enviromnent variable named `GO_VERSION` and -set it to the version you installed (eg, `1.14.1`). The Makefile will now use -the newer version. - -### Compile and install - -To just download and run: - -```bash -$ git clone https://github.com/zorchenhimer/MovieNight -$ cd MovieNight -$ make -$ ./MovieNight -``` - -### Docker build -MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. - -#### Building the Container -Install Docker, clone the repository and build: - -```shell -docker build -t movienight . -``` - -#### Running the Container -Run the image once it's built: - -```shell -docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight -``` - -Explanation: -- **-d** runs the container in the background. -- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. -- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. -- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] - -#### docker-compose -docker-compose will automatically build the image, no need to build it manually. - -Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: - -```shell -docker-compose up -d -``` - -This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. - -#### Notes for Running Using docker-compose -The container needs to be restarted to apply any changes you make to *settings.json*. - -## Usage - -Now you can use OBS to push a stream to the server. Set the stream URL to - -```text -rtmp://your.domain.host/live -``` - -and enter the stream key. - -Now you can view the stream at - -```text -http://your.domain.host:8089/ -``` - -There is a video only version at - -```text -http://your.domain.host:8089/video -``` - -and a chat only version at - -```text -http://your.domain.host:8089/chat -``` - -The default listen port is `:8089`. It can be changed by providing a new port -at startup: - -```text -Usage of .\MovieNight.exe: - -e bool - Whether or not to download approved emotes on startup (default "false") - -k string - Stream key, to protect your stream (default: "") - -l string - host:port of the MovieNight (default ":8089") - -r string - host:port of the RTMP server (default ":1935") -``` - -## Configuration - -MovieNight’s configuration is controlled by `settings.json`: - -- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves - admin privileges. This value is automatically regenerated unless - `RegenAdminPass` is false. -- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into - MovieNight. Using `/addemotes <username>` in chat will add to this list. -- `Bans`: list of banned users. -- `LetThemLurk`: if false, announces when a user enters and leaves chat. -- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. -- `LogFile`: the path of the MovieNight logfile, relative to the executable. -- `LogLevel`: the log level, defaults to `debug`. -- `MaxMessageCount`: the number of messages displayed in the chat window. -- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. -- `PageTitle`: The base string used in the `<title>` element of the page. When - the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` -- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. -- `RoomAccess`: the access policy of the chat room; this is managed by the - application and should not be edited manually. -- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. -- `SessionKey`: key used for storing session data (cookies etc.) -- `StreamKey`: the key that OBS will use to connect to MovieNight. -- `StreamStats`: if true, prints statistics for the stream on server shutdown. -- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). -- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes -- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). -- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons - or brackets; e.g., `:PogChamp:` -- `RateLimitChat`: the number of seconds between each message a non-privileged - user can post in chat. -- `RateLimitNick`: the number of seconds before a user can change their nick again. -- `RakeLimitColor`: the number of seconds before a user can change their color again. -- `RateLimitAuth`: the number of seconds between each allowed auth attempt -- `RateLimitDuplicate`: the numeber of seconds before a user can post a - duplicate message. -- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP - header, to prevent caching responses. - -## License - -`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. +<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> +**Table of Contents** + +- [MovieNight stream server](#movienight-stream-server) + - [Build requirements](#build-requirements) + - [Older Go Versions](#older-go-versions) + - [Compile and install](#compile-and-install) + - [Docker build](#docker-build) + - [Building the Container](#building-the-container) + - [Running the Container](#running-the-container) + - [docker-compose](#docker-compose) + - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) + - [Usage](#usage) + - [Configuration](#configuration) + +<!-- markdown-toc end --> +# MovieNight stream server + +[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) + +This is a single-instance streaming server with chat. Originally written to +replace Rabbit as the platform for watching movies with a group of people +online. + +## Build requirements + +- Go 1.13 or newer +- GNU Make + +### Older Go Versions + +You can install a newer version of Go alongside your OS's distribution by +following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) + +Once you have that setup add an enviromnent variable named `GO_VERSION` and +set it to the version you installed (eg, `1.14.1`). The Makefile will now use +the newer version. + +### Compile and install +You have to : + - download ; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" + ; + - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + ; + - and run ; + +```bash +$ git clone https://github.com/zorchenhimer/MovieNight +$ cd MovieNight +$ make TARGET=windows ARCH=386 +$ ./MovieNight +``` + +### Docker build +MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. + +#### Building the Container +Install Docker, clone the repository and build: + +```shell +docker build -t movienight . +``` + +#### Running the Container +Run the image once it's built: + +```shell +docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight +``` + +Explanation: +- **-d** runs the container in the background. +- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. +- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. +- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] + +#### docker-compose +docker-compose will automatically build the image, no need to build it manually. + +Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: + +```shell +docker-compose up -d +``` + +This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. + +#### Notes for Running Using docker-compose +The container needs to be restarted to apply any changes you make to *settings.json*. + +## Usage + +Now you can use OBS to push a stream to the server. Set the stream URL to + +```text +rtmp://your.domain.host/live +``` + +and enter the stream key. + +Now you can view the stream at + +```text +http://your.domain.host:8089/ +``` + +There is a video only version at + +```text +http://your.domain.host:8089/video +``` + +and a chat only version at + +```text +http://your.domain.host:8089/chat +``` + +The default listen port is `:8089`. It can be changed by providing a new port +at startup: + +```text +Usage of .\MovieNight.exe: + -e bool + Whether or not to download approved emotes on startup (default "false") + -k string + Stream key, to protect your stream (default: "") + -l string + host:port of the MovieNight (default ":8089") + -r string + host:port of the RTMP server (default ":1935") +``` + +## Configuration + +MovieNight’s configuration is controlled by `settings.json`: + +- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves + admin privileges. This value is automatically regenerated unless + `RegenAdminPass` is false. +- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into + MovieNight. Using `/addemotes <username>` in chat will add to this list. +- `Bans`: list of banned users. +- `LetThemLurk`: if false, announces when a user enters and leaves chat. +- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. +- `LogFile`: the path of the MovieNight logfile, relative to the executable. +- `LogLevel`: the log level, defaults to `debug`. +- `MaxMessageCount`: the number of messages displayed in the chat window. +- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. +- `PageTitle`: The base string used in the `<title>` element of the page. When + the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` +- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. +- `RoomAccess`: the access policy of the chat room; this is managed by the + application and should not be edited manually. +- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. +- `SessionKey`: key used for storing session data (cookies etc.) +- `StreamKey`: the key that OBS will use to connect to MovieNight. +- `StreamStats`: if true, prints statistics for the stream on server shutdown. +- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). +- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes +- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). +- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons + or brackets; e.g., `:PogChamp:` +- `RateLimitChat`: the number of seconds between each message a non-privileged + user can post in chat. +- `RateLimitNick`: the number of seconds before a user can change their nick again. +- `RakeLimitColor`: the number of seconds before a user can change their color again. +- `RateLimitAuth`: the number of seconds between each allowed auth attempt +- `RateLimitDuplicate`: the numeber of seconds before a user can post a + duplicate message. +- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP + header, to prevent caching responses. + +## License + +`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. From 23793f4b3c0b07eae8b4e51952dcb48ba82b1c53 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:20:45 +0200 Subject: [PATCH 003/101] CleverCloud deploy conf --- clevercloud/go.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 clevercloud/go.json diff --git a/clevercloud/go.json b/clevercloud/go.json new file mode 100644 index 0000000..aa93730 --- /dev/null +++ b/clevercloud/go.json @@ -0,0 +1,7 @@ +{ + "deploy": { + "appIsGoPath": false, + "main": "MovieNight", + "execDir": "./" + } +} From b75f9e6ca0431fdd6cf89bb449bd59c138165525 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:30:40 +0200 Subject: [PATCH 004/101] Clever Cloud : "appIsGoPath": true, --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From dcad017738eeadcaf8894a12fb9e1307ac59ae52 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:34:16 +0200 Subject: [PATCH 005/101] Clever Cloud : "appIsGoPath": false --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From 5d0786577e6dd5de07fab2a33dff7b0a2b3264e6 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:45:30 +0200 Subject: [PATCH 006/101] "appIsGoPath": true --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From 762d62b92afdc6ef3ab68c911c4f43081ee0afc7 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 007/101] Revert ""appIsGoPath": true" This reverts commit 5d0786577e6dd5de07fab2a33dff7b0a2b3264e6. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From fd6ad1900b7472b38a66ed1df93fde7d1a8b0387 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 008/101] Revert "Clever Cloud : "appIsGoPath": false" This reverts commit dcad017738eeadcaf8894a12fb9e1307ac59ae52. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From 222560faa3e9001e4e87d11521acb632021f0274 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 009/101] Revert "Clever Cloud : "appIsGoPath": true," This reverts commit b75f9e6ca0431fdd6cf89bb449bd59c138165525. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From 36bd14b933ef3e4a56741114a3d637bc052458a5 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 15:50:32 +0200 Subject: [PATCH 011/101] GitHub CI/CD --- .github/workflows/go.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..ae14b35 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight + + - name: Test + run: go test -v . From 2bf8279eeea12b7073947dfbd8b12d6121f0a01a Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:02:02 +0200 Subject: [PATCH 012/101] Release FreeBSD --- .github/workflows/go.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ae14b35..8c1493d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,8 @@ on: branches: [ master ] pull_request: branches: [ master ] + release: + types: [created] jobs: @@ -35,3 +37,15 @@ jobs: - name: Test run: go test -v . + + release-freebsd-amd64: + name: release freebsd/amd64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: wangyoucao577/go-release-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: FreeBSD + goarch: amd64 + From 01014bcb6c3ad55359b7b737fcd5a215d8dec863 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:04:49 +0200 Subject: [PATCH 013/101] Release update --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8c1493d..19e10fd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: wangyoucao577/go-release-action@master + - uses: zorglube/go-release-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: FreeBSD From 142fbf27b2d9fefa566e87c88295b19d83c1f341 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:07:36 +0200 Subject: [PATCH 014/101] Remove release --- .github/workflows/go.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 19e10fd..ae14b35 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,8 +5,6 @@ on: branches: [ master ] pull_request: branches: [ master ] - release: - types: [created] jobs: @@ -37,15 +35,3 @@ jobs: - name: Test run: go test -v . - - release-freebsd-amd64: - name: release freebsd/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: zorglube/go-release-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: FreeBSD - goarch: amd64 - From 63c8c25aadeb8d886411692a2c5c2299521e7170 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:09:25 +0200 Subject: [PATCH 015/101] Remove git workflow --- .github/workflows/go.yml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index ae14b35..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Go - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - - - name: Build - run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight - - - name: Test - run: go test -v . From 72c26f58c72e55dfde77cc30cfb2f38709c902ce Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 016/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- .gitignore | 2 + Makefile | 7 +- readme.md | 349 +++++++++++++++++++++++++++-------------------------- 3 files changed, 184 insertions(+), 174 deletions(-) diff --git a/.gitignore b/.gitignore index d996f8d..7e1383f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ tags # channel and emote list from twitch subscribers.json +/.settings/ +/.project diff --git a/Makefile b/Makefile index e7fa083..f693306 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,13 @@ # For info on installing extra versions, see this page: # https://golang.org/doc/install#extra_versions +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + TAGS= # Windows needs the .exe extension. -ifeq ($(OS),Windows_NT) +ifeq ($(TARGET),windows) EXT=.exe endif @@ -21,7 +24,7 @@ server: ServerMovieNight static/main.wasm # Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") diff --git a/readme.md b/readme.md index 7a95a42..8c4e75d 100644 --- a/readme.md +++ b/readme.md @@ -1,172 +1,177 @@ -<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> -**Table of Contents** - -- [MovieNight stream server](#movienight-stream-server) - - [Build requirements](#build-requirements) - - [Older Go Versions](#older-go-versions) - - [Compile and install](#compile-and-install) - - [Docker build](#docker-build) - - [Building the Container](#building-the-container) - - [Running the Container](#running-the-container) - - [docker-compose](#docker-compose) - - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) - - [Usage](#usage) - - [Configuration](#configuration) - -<!-- markdown-toc end --> -# MovieNight stream server - -[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) - -This is a single-instance streaming server with chat. Originally written to -replace Rabbit as the platform for watching movies with a group of people -online. - -## Build requirements - -- Go 1.13 or newer -- GNU Make - -### Older Go Versions - -You can install a newer version of Go alongside your OS's distribution by -following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) - -Once you have that setup add an enviromnent variable named `GO_VERSION` and -set it to the version you installed (eg, `1.14.1`). The Makefile will now use -the newer version. - -### Compile and install - -To just download and run: - -```bash -$ git clone https://github.com/zorchenhimer/MovieNight -$ cd MovieNight -$ make -$ ./MovieNight -``` - -### Docker build -MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. - -#### Building the Container -Install Docker, clone the repository and build: - -```shell -docker build -t movienight . -``` - -#### Running the Container -Run the image once it's built: - -```shell -docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight -``` - -Explanation: -- **-d** runs the container in the background. -- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. -- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. -- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] - -#### docker-compose -docker-compose will automatically build the image, no need to build it manually. - -Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: - -```shell -docker-compose up -d -``` - -This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. - -#### Notes for Running Using docker-compose -The container needs to be restarted to apply any changes you make to *settings.json*. - -## Usage - -Now you can use OBS to push a stream to the server. Set the stream URL to - -```text -rtmp://your.domain.host/live -``` - -and enter the stream key. - -Now you can view the stream at - -```text -http://your.domain.host:8089/ -``` - -There is a video only version at - -```text -http://your.domain.host:8089/video -``` - -and a chat only version at - -```text -http://your.domain.host:8089/chat -``` - -The default listen port is `:8089`. It can be changed by providing a new port -at startup: - -```text -Usage of .\MovieNight.exe: - -e bool - Whether or not to download approved emotes on startup (default "false") - -k string - Stream key, to protect your stream (default: "") - -l string - host:port of the MovieNight (default ":8089") - -r string - host:port of the RTMP server (default ":1935") -``` - -## Configuration - -MovieNight’s configuration is controlled by `settings.json`: - -- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves - admin privileges. This value is automatically regenerated unless - `RegenAdminPass` is false. -- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into - MovieNight. Using `/addemotes <username>` in chat will add to this list. -- `Bans`: list of banned users. -- `LetThemLurk`: if false, announces when a user enters and leaves chat. -- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. -- `LogFile`: the path of the MovieNight logfile, relative to the executable. -- `LogLevel`: the log level, defaults to `debug`. -- `MaxMessageCount`: the number of messages displayed in the chat window. -- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. -- `PageTitle`: The base string used in the `<title>` element of the page. When - the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` -- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. -- `RoomAccess`: the access policy of the chat room; this is managed by the - application and should not be edited manually. -- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. -- `SessionKey`: key used for storing session data (cookies etc.) -- `StreamKey`: the key that OBS will use to connect to MovieNight. -- `StreamStats`: if true, prints statistics for the stream on server shutdown. -- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). -- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes -- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). -- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons - or brackets; e.g., `:PogChamp:` -- `RateLimitChat`: the number of seconds between each message a non-privileged - user can post in chat. -- `RateLimitNick`: the number of seconds before a user can change their nick again. -- `RakeLimitColor`: the number of seconds before a user can change their color again. -- `RateLimitAuth`: the number of seconds between each allowed auth attempt -- `RateLimitDuplicate`: the numeber of seconds before a user can post a - duplicate message. -- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP - header, to prevent caching responses. - -## License - -`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. +<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> +**Table of Contents** + +- [MovieNight stream server](#movienight-stream-server) + - [Build requirements](#build-requirements) + - [Older Go Versions](#older-go-versions) + - [Compile and install](#compile-and-install) + - [Docker build](#docker-build) + - [Building the Container](#building-the-container) + - [Running the Container](#running-the-container) + - [docker-compose](#docker-compose) + - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) + - [Usage](#usage) + - [Configuration](#configuration) + +<!-- markdown-toc end --> +# MovieNight stream server + +[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) + +This is a single-instance streaming server with chat. Originally written to +replace Rabbit as the platform for watching movies with a group of people +online. + +## Build requirements + +- Go 1.13 or newer +- GNU Make + +### Older Go Versions + +You can install a newer version of Go alongside your OS's distribution by +following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) + +Once you have that setup add an enviromnent variable named `GO_VERSION` and +set it to the version you installed (eg, `1.14.1`). The Makefile will now use +the newer version. + +### Compile and install +You have to : + - download ; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" + ; + - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + ; + - and run ; + +```bash +$ git clone https://github.com/zorchenhimer/MovieNight +$ cd MovieNight +$ make TARGET=windows ARCH=386 +$ ./MovieNight +``` + +### Docker build +MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. + +#### Building the Container +Install Docker, clone the repository and build: + +```shell +docker build -t movienight . +``` + +#### Running the Container +Run the image once it's built: + +```shell +docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight +``` + +Explanation: +- **-d** runs the container in the background. +- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. +- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. +- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] + +#### docker-compose +docker-compose will automatically build the image, no need to build it manually. + +Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: + +```shell +docker-compose up -d +``` + +This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. + +#### Notes for Running Using docker-compose +The container needs to be restarted to apply any changes you make to *settings.json*. + +## Usage + +Now you can use OBS to push a stream to the server. Set the stream URL to + +```text +rtmp://your.domain.host/live +``` + +and enter the stream key. + +Now you can view the stream at + +```text +http://your.domain.host:8089/ +``` + +There is a video only version at + +```text +http://your.domain.host:8089/video +``` + +and a chat only version at + +```text +http://your.domain.host:8089/chat +``` + +The default listen port is `:8089`. It can be changed by providing a new port +at startup: + +```text +Usage of .\MovieNight.exe: + -e bool + Whether or not to download approved emotes on startup (default "false") + -k string + Stream key, to protect your stream (default: "") + -l string + host:port of the MovieNight (default ":8089") + -r string + host:port of the RTMP server (default ":1935") +``` + +## Configuration + +MovieNight’s configuration is controlled by `settings.json`: + +- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves + admin privileges. This value is automatically regenerated unless + `RegenAdminPass` is false. +- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into + MovieNight. Using `/addemotes <username>` in chat will add to this list. +- `Bans`: list of banned users. +- `LetThemLurk`: if false, announces when a user enters and leaves chat. +- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. +- `LogFile`: the path of the MovieNight logfile, relative to the executable. +- `LogLevel`: the log level, defaults to `debug`. +- `MaxMessageCount`: the number of messages displayed in the chat window. +- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. +- `PageTitle`: The base string used in the `<title>` element of the page. When + the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` +- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. +- `RoomAccess`: the access policy of the chat room; this is managed by the + application and should not be edited manually. +- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. +- `SessionKey`: key used for storing session data (cookies etc.) +- `StreamKey`: the key that OBS will use to connect to MovieNight. +- `StreamStats`: if true, prints statistics for the stream on server shutdown. +- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). +- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes +- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). +- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons + or brackets; e.g., `:PogChamp:` +- `RateLimitChat`: the number of seconds between each message a non-privileged + user can post in chat. +- `RateLimitNick`: the number of seconds before a user can change their nick again. +- `RakeLimitColor`: the number of seconds before a user can change their color again. +- `RateLimitAuth`: the number of seconds between each allowed auth attempt +- `RateLimitDuplicate`: the numeber of seconds before a user can post a + duplicate message. +- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP + header, to prevent caching responses. + +## License + +`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. From a3b80e2e8eff36d49a5216b640e05f2d39213f0f Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 017/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- readme.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 8c4e75d..0a91b7a 100644 --- a/readme.md +++ b/readme.md @@ -38,12 +38,10 @@ the newer version. ### Compile and install You have to : - - download ; - - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" - ; - - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" - ; - - and run ; + - download the code; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"; + - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"; + - and run; ```bash $ git clone https://github.com/zorchenhimer/MovieNight From 3e1b05d06193d56159705dee996a5fac7b1ca73e Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:20:45 +0200 Subject: [PATCH 018/101] CleverCloud deploy conf --- clevercloud/go.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 clevercloud/go.json diff --git a/clevercloud/go.json b/clevercloud/go.json new file mode 100644 index 0000000..aa93730 --- /dev/null +++ b/clevercloud/go.json @@ -0,0 +1,7 @@ +{ + "deploy": { + "appIsGoPath": false, + "main": "MovieNight", + "execDir": "./" + } +} From 365d24332ab15b2edc0ce1c15650b5f18af4ddc7 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:30:40 +0200 Subject: [PATCH 019/101] Clever Cloud : "appIsGoPath": true, --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From ce1e91bf7a8c53b8c8f0d9d48636dae17bd2677f Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:34:16 +0200 Subject: [PATCH 020/101] Clever Cloud : "appIsGoPath": false --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From ed67a4e3d8fcb4fa75f312f2e1ac19ba5908c425 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:45:30 +0200 Subject: [PATCH 021/101] "appIsGoPath": true --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From 9ca2a2954bb0e4870090b6d854feb2619ca9e477 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 022/101] Revert ""appIsGoPath": true" This reverts commit 5d0786577e6dd5de07fab2a33dff7b0a2b3264e6. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From 54da334ead28806854ee521f9775cee755c85241 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 023/101] Revert "Clever Cloud : "appIsGoPath": false" This reverts commit dcad017738eeadcaf8894a12fb9e1307ac59ae52. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From 46795d53bcf892bf18a583cded8385cdad1ec84b Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 024/101] Revert "Clever Cloud : "appIsGoPath": true," This reverts commit b75f9e6ca0431fdd6cf89bb449bd59c138165525. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From 8e31c81299228aa80fc91ce6a5d6a66620396ff8 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 15:50:32 +0200 Subject: [PATCH 025/101] GitHub CI/CD --- .github/workflows/go.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..ae14b35 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight + + - name: Test + run: go test -v . From 2d070fbabb87ce8d5effacff313ba7459b88a03f Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:02:02 +0200 Subject: [PATCH 026/101] Release FreeBSD --- .github/workflows/go.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ae14b35..8c1493d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,8 @@ on: branches: [ master ] pull_request: branches: [ master ] + release: + types: [created] jobs: @@ -35,3 +37,15 @@ jobs: - name: Test run: go test -v . + + release-freebsd-amd64: + name: release freebsd/amd64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: wangyoucao577/go-release-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: FreeBSD + goarch: amd64 + From 968eab26292a3482d9bc5fd213116c28b794ab11 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:04:49 +0200 Subject: [PATCH 027/101] Release update --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8c1493d..19e10fd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: wangyoucao577/go-release-action@master + - uses: zorglube/go-release-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: FreeBSD From 8bd77c13911665fcec9779d6898fe63fbe7f6ac0 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:07:36 +0200 Subject: [PATCH 028/101] Remove release --- .github/workflows/go.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 19e10fd..ae14b35 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,8 +5,6 @@ on: branches: [ master ] pull_request: branches: [ master ] - release: - types: [created] jobs: @@ -37,15 +35,3 @@ jobs: - name: Test run: go test -v . - - release-freebsd-amd64: - name: release freebsd/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: zorglube/go-release-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: FreeBSD - goarch: amd64 - From ad93fb3403d36c896c7d8e767fcb3b4ac69c4f18 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:09:25 +0200 Subject: [PATCH 029/101] Remove git workflow --- .github/workflows/go.yml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index ae14b35..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Go - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - - - name: Build - run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight - - - name: Test - run: go test -v . From a9a8b45a2375a9f33f1e24c90885c26b61fc4d15 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:54:01 +0200 Subject: [PATCH 030/101] remove Clever Could conf --- clevercloud/go.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 clevercloud/go.json diff --git a/clevercloud/go.json b/clevercloud/go.json deleted file mode 100644 index aa93730..0000000 --- a/clevercloud/go.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "deploy": { - "appIsGoPath": false, - "main": "MovieNight", - "execDir": "./" - } -} From d67ef3dedc9d16a8bc8d979cfc9b1b64f5ebdf66 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:21:58 +0200 Subject: [PATCH 031/101] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 55a3d40..c580bbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,5 @@ go: env: - GO111MODULE=on + - ARCH=amd64 + - TARGET=FreeBSD From cae345dec8f48cb6e6820b050783fb7463f20eab Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:24:39 +0200 Subject: [PATCH 032/101] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c580bbd..55a3d40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,3 @@ go: env: - GO111MODULE=on - - ARCH=amd64 - - TARGET=FreeBSD From 8b2e1af6b0338a9fe9b1b23c2928f6bfeb62213b Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 14:37:42 +0200 Subject: [PATCH 033/101] BSD Make if --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f693306..07998fb 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,9 @@ TAGS= # Windows needs the .exe extension. -ifeq ($(TARGET),windows) +.if ${TARGET} == "windows" EXT=.exe -endif +.endif .PHONY: fmt vet get clean dev setdev test ServerMovieNight From ef0beae00f963e68769e5a067ece09a42f43f291 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:14:57 +0200 Subject: [PATCH 034/101] Add conf file var --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3dfeeac..e65c284 100644 --- a/main.go +++ b/main.go @@ -20,11 +20,12 @@ var ( sKey string stats = newStreamStats() sAdminPass string + confFile string ) func setupSettings() error { var err error - settings, err = LoadSettings("settings.json") + settings, err = LoadSettings(confFile) if err != nil { return fmt.Errorf("Unable to load settings: %s", err) } @@ -53,6 +54,7 @@ func main() { flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") flag.StringVar(&sAdminPass, "a", "", "Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json.") flag.BoolVar(&pullEmotes, "e", false, "Pull emotes") + flag.StringVar(&confFile, "f", "", "URI of the conf file") flag.Parse() format.RegisterAll() From 8b3490a4a6e41d86b8d2adc1604799570f020538 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:49:26 +0200 Subject: [PATCH 035/101] Relative dir --- main.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index e65c284..2ac6f1a 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "os/signal" + "path/filepath" "github.com/gorilla/sessions" "github.com/nareix/joy4/format" @@ -21,6 +22,7 @@ var ( stats = newStreamStats() sAdminPass string confFile string + path string ) func setupSettings() error { @@ -49,6 +51,7 @@ func setupSettings() error { } func main() { + &path, err := filepath.Abs(filepath.Dir(os.Args[0])) flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") @@ -132,20 +135,20 @@ func startRmtpServer() { func startServer() { // Chat websocket - http.HandleFunc("/ws", wsHandler) - http.HandleFunc("/static/js/", wsStaticFiles) - http.HandleFunc("/static/css/", wsStaticFiles) - http.HandleFunc("/static/img/", wsImages) - http.HandleFunc("/static/main.wasm", wsWasmFile) - http.HandleFunc("/emotes/", wsEmotes) - http.HandleFunc("/favicon.ico", wsStaticFiles) - http.HandleFunc("/chat", handleIndexTemplate) - http.HandleFunc("/video", handleIndexTemplate) - http.HandleFunc("/help", handleHelpTemplate) - http.HandleFunc("/pin", handlePin) - http.HandleFunc("/emotes", handleEmoteTemplate) + http.HandleFunc(path+"/ws", wsHandler) + http.HandleFunc(path+"/static/js/", wsStaticFiles) + http.HandleFunc(path+"/static/css/", wsStaticFiles) + http.HandleFunc(path+"/static/img/", wsImages) + http.HandleFunc(path+"/static/main.wasm", wsWasmFile) + http.HandleFunc(path+"/emotes/", wsEmotes) + http.HandleFunc(path+"/favicon.ico", wsStaticFiles) + http.HandleFunc(path+"/chat", handleIndexTemplate) + http.HandleFunc(path+"/video", handleIndexTemplate) + http.HandleFunc(path+"/help", handleHelpTemplate) + http.HandleFunc(path+"/pin", handlePin) + http.HandleFunc(path+"/emotes", handleEmoteTemplate) - http.HandleFunc("/", handleDefault) + http.HandleFunc(path+"/", handleDefault) err := http.ListenAndServe(addr, nil) if err != nil { From 28d40c497b8caaa8dc6f5363de8b2f82d703b652 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:53:49 +0200 Subject: [PATCH 036/101] absolut dir --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 2ac6f1a..d64baea 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,11 @@ func setupSettings() error { func main() { &path, err := filepath.Abs(filepath.Dir(os.Args[0])) + if err != nil { + log.Fatal(err) + } + fmt.Println(path) + flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") From c1572c0c81adc6268ab57468a6bf5a9c0c2e3d5c Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Thu, 20 Aug 2020 19:06:34 +0200 Subject: [PATCH 037/101] Relative running --- main.go | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index d64baea..9aa55a6 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ var ( stats = newStreamStats() sAdminPass string confFile string - path string + runPath string ) func setupSettings() error { @@ -51,11 +51,12 @@ func setupSettings() error { } func main() { - &path, err := filepath.Abs(filepath.Dir(os.Args[0])) - if err != nil { - log.Fatal(err) - } - fmt.Println(path) + ex, er := os.Executable() + if er != nil { + panic(er) + } + runPath := filepath.Dir(ex) + fmt.Println(runPath) flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") @@ -140,20 +141,20 @@ func startRmtpServer() { func startServer() { // Chat websocket - http.HandleFunc(path+"/ws", wsHandler) - http.HandleFunc(path+"/static/js/", wsStaticFiles) - http.HandleFunc(path+"/static/css/", wsStaticFiles) - http.HandleFunc(path+"/static/img/", wsImages) - http.HandleFunc(path+"/static/main.wasm", wsWasmFile) - http.HandleFunc(path+"/emotes/", wsEmotes) - http.HandleFunc(path+"/favicon.ico", wsStaticFiles) - http.HandleFunc(path+"/chat", handleIndexTemplate) - http.HandleFunc(path+"/video", handleIndexTemplate) - http.HandleFunc(path+"/help", handleHelpTemplate) - http.HandleFunc(path+"/pin", handlePin) - http.HandleFunc(path+"/emotes", handleEmoteTemplate) + http.HandleFunc(runPath+"/ws", wsHandler) + http.HandleFunc(runPath+"/static/js/", wsStaticFiles) + http.HandleFunc(runPath+"/static/css/", wsStaticFiles) + http.HandleFunc(runPath+"/static/img/", wsImages) + http.HandleFunc(runPath+"/static/main.wasm", wsWasmFile) + http.HandleFunc(runPath+"/emotes/", wsEmotes) + http.HandleFunc(runPath+"/favicon.ico", wsStaticFiles) + http.HandleFunc(runPath+"/chat", handleIndexTemplate) + http.HandleFunc(runPath+"/video", handleIndexTemplate) + http.HandleFunc(runPath+"/help", handleHelpTemplate) + http.HandleFunc(runPath+"/pin", handlePin) + http.HandleFunc(runPath+"/emotes", handleEmoteTemplate) - http.HandleFunc(path+"/", handleDefault) + http.HandleFunc(runPath+"/", handleDefault) err := http.ListenAndServe(addr, nil) if err != nil { From aaad03f44dc8fad438421501cf8de7ff030d7462 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 11:59:58 +0200 Subject: [PATCH 038/101] Run from anywhere Get the runpath at runtime, in order to run MovieNight from whatever position into the filesystem. --- common/templates.go | 24 ++++++++++++++++-------- emotes.go | 10 +++++++--- handlers.go | 25 +++++++++++++++++-------- main.go | 36 ++++++++++++++---------------------- 4 files changed, 54 insertions(+), 41 deletions(-) diff --git a/common/templates.go b/common/templates.go index e8b3abb..6790d45 100644 --- a/common/templates.go +++ b/common/templates.go @@ -4,6 +4,8 @@ import ( "fmt" html "html/template" "net/http" + "os" + "path/filepath" "strings" text "text/template" ) @@ -16,14 +18,6 @@ var chatTemplates map[string]*text.Template var isServer bool = false -// keys and files to load for that template -var serverTemplateDefs map[string][]string = map[string][]string{ - "pin": []string{"./static/base.html", "./static/thedoor.html"}, - "main": []string{"./static/base.html", "./static/main.html"}, - "help": []string{"./static/base.html", "./static/help.html"}, - "emotes": []string{"./static/base.html", "./static/emotes.html"}, -} - var chatTemplateDefs map[string]string = map[string]string{ fmt.Sprint(DTInvalid, 0): "wot", @@ -38,6 +32,20 @@ func InitTemplates() error { isServer = true serverTemplates = make(map[string]*html.Template) chatTemplates = make(map[string]*text.Template) + ex, er := os.Executable() + if er != nil { + panic(er) + } + runPath := filepath.Dir(ex) + fmt.Println(runPath) + + // keys and files to load for that template + var serverTemplateDefs map[string][]string = map[string][]string{ + "pin": []string{runPath + "/static/base.html", runPath + "/static/thedoor.html"}, + "main": []string{runPath + "/static/base.html", runPath + "/static/main.html"}, + "help": []string{runPath + "/static/base.html", runPath + "/static/help.html"}, + "emotes": []string{runPath + "/static/base.html", runPath + "/static/emotes.html"}, + } // Parse server templates for key, files := range serverTemplateDefs { diff --git a/emotes.go b/emotes.go index f9d117c..8954e1b 100644 --- a/emotes.go +++ b/emotes.go @@ -15,7 +15,7 @@ import ( "github.com/zorchenhimer/MovieNight/common" ) -const emoteDir = "./static/emotes/" +const emoteDir = "/static/emotes/" type TwitchUser struct { ID string @@ -28,8 +28,12 @@ type EmoteInfo struct { } func loadEmotes() error { - //fmt.Println(processEmoteDir(emoteDir)) - newEmotes, err := processEmoteDir(emoteDir) + ex, er := os.Executable() + if er != nil { + panic(er) + } + runPath := filepath.Dir(ex) + newEmotes, err := processEmoteDir(runPath + emoteDir) if err != nil { return err } diff --git a/handlers.go b/handlers.go index 969fa97..554a239 100644 --- a/handlers.go +++ b/handlers.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "os" "path" "path/filepath" "strings" @@ -44,24 +45,32 @@ func (self writeFlusher) Flush() error { return nil } +func runPath() string { + ex, er := os.Executable() + if er != nil { + panic(er) + } + return filepath.Dir(ex) +} + // Serving static files func wsStaticFiles(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/favicon.ico": - http.ServeFile(w, r, "./favicon.png") + http.ServeFile(w, r, runPath()+"/favicon.png") return case "/justchat": - http.ServeFile(w, r, "./static/justchat.html") + http.ServeFile(w, r, runPath()+"/static/justchat.html") return case "/justvideo": - http.ServeFile(w, r, "./static/justvideo.html") + http.ServeFile(w, r, runPath()+"/static/justvideo.html") return } goodPath := r.URL.Path[8:len(r.URL.Path)] - common.LogDebugf("[static] serving %q from folder ./static/\n", goodPath) + common.LogDebugf("[static] serving %q from folder %s\n", goodPath, runPath()) - http.ServeFile(w, r, "./static/"+goodPath) + http.ServeFile(w, r, runPath()+"/static/"+goodPath) } func wsWasmFile(w http.ResponseWriter, r *http.Request) { @@ -69,17 +78,17 @@ func wsWasmFile(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache, must-revalidate") } common.LogDebugln("[static] serving wasm file") - http.ServeFile(w, r, "./static/main.wasm") + http.ServeFile(w, r, runPath()+"/static/main.wasm") } func wsImages(w http.ResponseWriter, r *http.Request) { base := filepath.Base(r.URL.Path) common.LogDebugln("[img] ", base) - http.ServeFile(w, r, "./static/img/"+base) + http.ServeFile(w, r, runPath()+"/static/img/"+base) } func wsEmotes(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, path.Join("./static/", r.URL.Path)) + http.ServeFile(w, r, path.Join(runPath()+"/static/", r.URL.Path)) } // Handling the websocket diff --git a/main.go b/main.go index 9aa55a6..54a03d9 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "net/http" "os" "os/signal" - "path/filepath" + // "path/filepath" "github.com/gorilla/sessions" "github.com/nareix/joy4/format" @@ -22,7 +22,6 @@ var ( stats = newStreamStats() sAdminPass string confFile string - runPath string ) func setupSettings() error { @@ -51,13 +50,6 @@ func setupSettings() error { } func main() { - ex, er := os.Executable() - if er != nil { - panic(er) - } - runPath := filepath.Dir(ex) - fmt.Println(runPath) - flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") @@ -141,20 +133,20 @@ func startRmtpServer() { func startServer() { // Chat websocket - http.HandleFunc(runPath+"/ws", wsHandler) - http.HandleFunc(runPath+"/static/js/", wsStaticFiles) - http.HandleFunc(runPath+"/static/css/", wsStaticFiles) - http.HandleFunc(runPath+"/static/img/", wsImages) - http.HandleFunc(runPath+"/static/main.wasm", wsWasmFile) - http.HandleFunc(runPath+"/emotes/", wsEmotes) - http.HandleFunc(runPath+"/favicon.ico", wsStaticFiles) - http.HandleFunc(runPath+"/chat", handleIndexTemplate) - http.HandleFunc(runPath+"/video", handleIndexTemplate) - http.HandleFunc(runPath+"/help", handleHelpTemplate) - http.HandleFunc(runPath+"/pin", handlePin) - http.HandleFunc(runPath+"/emotes", handleEmoteTemplate) + http.HandleFunc("/ws", wsHandler) + http.HandleFunc("/static/js/", wsStaticFiles) + http.HandleFunc("/static/css/", wsStaticFiles) + http.HandleFunc("/static/img/", wsImages) + http.HandleFunc("/static/main.wasm", wsWasmFile) + http.HandleFunc("/emotes/", wsEmotes) + http.HandleFunc("/favicon.ico", wsStaticFiles) + http.HandleFunc("/chat", handleIndexTemplate) + http.HandleFunc("/video", handleIndexTemplate) + http.HandleFunc("/help", handleHelpTemplate) + http.HandleFunc("/pin", handlePin) + http.HandleFunc("/emotes", handleEmoteTemplate) - http.HandleFunc(runPath+"/", handleDefault) + http.HandleFunc("/", handleDefault) err := http.ListenAndServe(addr, nil) if err != nil { From affca20c332f9808fb89a0e01d0ea75cdb1b5aec Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 12:01:54 +0200 Subject: [PATCH 039/101] Removed: if windows It isn't mandatory to be suffixed by ".exe" to be runnable into an windows. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 07998fb..1ec3402 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,9 @@ TAGS= # Windows needs the .exe extension. -.if ${TARGET} == "windows" -EXT=.exe -.endif +#.if ${TARGET} == "windows" +#EXT=.exe +#.endif .PHONY: fmt vet get clean dev setdev test ServerMovieNight From 7cd9945e8a1d49dbc518e0bbfaf36b2e4214cdd3 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 12:01:54 +0200 Subject: [PATCH 040/101] Removed: if windows It isn't mandatory to be suffixed by ".exe" to be runnable into an windows. --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 07998fb..7dcda28 100644 --- a/Makefile +++ b/Makefile @@ -10,14 +10,9 @@ TAGS= -# Windows needs the .exe extension. -.if ${TARGET} == "windows" -EXT=.exe -.endif - .PHONY: fmt vet get clean dev setdev test ServerMovieNight -all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json +all: fmt vet test MovieNight static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm @@ -41,7 +36,7 @@ static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go clean: - -rm MovieNight$(EXT) ./static/main.wasm ./static/js/wasm_exec.js + -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js fmt: gofmt -w . From 7e0f11f851eb2ae0797ae9e6215eaf9643762042 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 12:29:00 +0200 Subject: [PATCH 041/101] settings.json default value --- main.go | 2 +- readme.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 54a03d9..b598480 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ func main() { flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") flag.StringVar(&sAdminPass, "a", "", "Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json.") flag.BoolVar(&pullEmotes, "e", false, "Pull emotes") - flag.StringVar(&confFile, "f", "", "URI of the conf file") + flag.StringVar(&confFile, "f", "./settings.json", "URI of the conf file") flag.Parse() format.RegisterAll() diff --git a/readme.md b/readme.md index d64a5c4..76d7c0a 100644 --- a/readme.md +++ b/readme.md @@ -130,6 +130,8 @@ Usage of .\MovieNight.exe: host:port of the MovieNight (default ":8089") -r string host:port of the RTMP server (default ":1935") + -f string + the settings file you want to use (default "./settings.json") ``` ## Configuration From 3ac43ba1f3d6fb61f8d9072a3b478614a3d41894 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 20:05:11 +0200 Subject: [PATCH 042/101] Very little factorize around "func runPath()" --- common/templates.go | 15 +++++++++------ emotes.go | 11 +++++++---- handlers.go | 9 --------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/common/templates.go b/common/templates.go index 6790d45..8659c79 100644 --- a/common/templates.go +++ b/common/templates.go @@ -27,17 +27,20 @@ var chatTemplateDefs map[string]string = map[string]string{ `</span> <span class="cmdme">{{.Message}}</span></span>`, } +func runPath() string { + ex, er := os.Executable() + if er != nil { + panic(er) + } + return filepath.Dir(ex) +} + // Called from the server func InitTemplates() error { isServer = true serverTemplates = make(map[string]*html.Template) chatTemplates = make(map[string]*text.Template) - ex, er := os.Executable() - if er != nil { - panic(er) - } - runPath := filepath.Dir(ex) - fmt.Println(runPath) + var runPath string = runPath() // keys and files to load for that template var serverTemplateDefs map[string][]string = map[string][]string{ diff --git a/emotes.go b/emotes.go index 8954e1b..9e76bba 100644 --- a/emotes.go +++ b/emotes.go @@ -27,13 +27,16 @@ type EmoteInfo struct { Code string } -func loadEmotes() error { +func runPath() string { ex, er := os.Executable() if er != nil { panic(er) } - runPath := filepath.Dir(ex) - newEmotes, err := processEmoteDir(runPath + emoteDir) + return filepath.Dir(ex) +} + +func loadEmotes() error { + newEmotes, err := processEmoteDir(runPath() + emoteDir) if err != nil { return err } @@ -92,7 +95,7 @@ func processEmoteDir(path string) (common.EmotesMap, error) { func findEmotes(dir string, em common.EmotesMap) (common.EmotesMap, error) { //em := NewEmotesMap() - fmt.Printf("finding emotes in %q\n", dir) + //fmt.Printf("finding emotes in %q\n", dir) emotePNGs, err := filepath.Glob(filepath.Join(dir, "*.png")) if err != nil { return em, fmt.Errorf("unable to glob emote directory: %s\n", err) diff --git a/handlers.go b/handlers.go index 554a239..c75130f 100644 --- a/handlers.go +++ b/handlers.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "net/http" - "os" "path" "path/filepath" "strings" @@ -45,14 +44,6 @@ func (self writeFlusher) Flush() error { return nil } -func runPath() string { - ex, er := os.Executable() - if er != nil { - panic(er) - } - return filepath.Dir(ex) -} - // Serving static files func wsStaticFiles(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { From a8c3d4f097fb55d2a5723e2284bf1b281b078a72 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 00:05:30 +0200 Subject: [PATCH 043/101] Log file directory --- settings.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/settings.go b/settings.go index f19d288..4b2408d 100644 --- a/settings.go +++ b/settings.go @@ -85,7 +85,9 @@ func LoadSettings(filename string) (*Settings, error) { } s.filename = filename - if err = common.SetupLogging(s.LogLevel, s.LogFile); err != nil { + var logFileDir string = runPath() + "/" + s.LogFile + fmt.Printf("Log file: %s\n", logFileDir) + if err = common.SetupLogging(s.LogLevel, logFileDir); err != nil { return nil, fmt.Errorf("Unable to setup logger: %s", err) } From 36bd6f6ea44677c1a709a9b8632401cf7b17a3e1 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 13:12:40 +0200 Subject: [PATCH 044/101] Add DSB into builds --- readme.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 76d7c0a..c1261b7 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,5 @@ <!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> **Table of Contents** - - [MovieNight stream server](#movienight-stream-server) - [Build requirements](#build-requirements) - [Older Go Versions](#older-go-versions) @@ -10,12 +9,12 @@ - [Running the Container](#running-the-container) - [docker-compose](#docker-compose) - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) + - [FreeNAS / FreeBSD build and run](#FreeNAS-FreeBSD) - [Usage](#usage) - [Configuration](#configuration) <!-- markdown-toc end --> # MovieNight stream server - [![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) This is a single-instance streaming server with chat. Originally written to @@ -23,12 +22,10 @@ replace Rabbit as the platform for watching movies with a group of people online. ## Build requirements - - Go 1.13 or newer - GNU Make ### Older Go Versions - You can install a newer version of Go alongside your OS's distribution by following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) @@ -89,8 +86,10 @@ This docker-compose file will create a volume called *movienight-config* and aut #### Notes for Running Using docker-compose The container needs to be restarted to apply any changes you make to *settings.json*. -## Usage +### FreeNAS - FreeBSD build and run +An script wich setup an Jail and build and run MovieNight into that Jail as been writen, you'll find it here [freenas-iocage-movienight] (https://github.com/zorglube/freenas-iocage-movienight) +## Usage Now you can use OBS to push a stream to the server. Set the stream URL to ```text @@ -135,7 +134,6 @@ Usage of .\MovieNight.exe: ``` ## Configuration - MovieNight’s configuration is controlled by `settings.json`: - `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves @@ -175,5 +173,4 @@ MovieNight’s configuration is controlled by `settings.json`: header, to prevent caching responses. ## License - `flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. From 37ff82f9cc976978a3ba6a952b1e3e6159581137 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 17:54:01 +0200 Subject: [PATCH 045/101] Factorize runPath() --- common/templates.go | 12 +----------- common/utils.go | 11 +++++++++++ emotes.go | 10 +--------- handlers.go | 17 +++++++++-------- settings.go | 2 +- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/common/templates.go b/common/templates.go index 8659c79..448bc29 100644 --- a/common/templates.go +++ b/common/templates.go @@ -4,8 +4,6 @@ import ( "fmt" html "html/template" "net/http" - "os" - "path/filepath" "strings" text "text/template" ) @@ -27,20 +25,12 @@ var chatTemplateDefs map[string]string = map[string]string{ `</span> <span class="cmdme">{{.Message}}</span></span>`, } -func runPath() string { - ex, er := os.Executable() - if er != nil { - panic(er) - } - return filepath.Dir(ex) -} - // Called from the server func InitTemplates() error { isServer = true serverTemplates = make(map[string]*html.Template) chatTemplates = make(map[string]*text.Template) - var runPath string = runPath() + var runPath string = RunPath() // keys and files to load for that template var serverTemplateDefs map[string][]string = map[string][]string{ diff --git a/common/utils.go b/common/utils.go index 4f1dda2..18e68d7 100644 --- a/common/utils.go +++ b/common/utils.go @@ -3,6 +3,8 @@ package common // Misc utils import ( + "os" + "path/filepath" "regexp" ) @@ -16,3 +18,12 @@ func IsValidName(name string) bool { return 3 <= len(name) && len(name) <= 36 && usernameRegex.MatchString(name) } + +// Return the absolut directory containing the MovieNight binary +func RunPath() string { + ex, er := os.Executable() + if er != nil { + panic(er) + } + return filepath.Dir(ex) +} diff --git a/emotes.go b/emotes.go index 9e76bba..6feeee4 100644 --- a/emotes.go +++ b/emotes.go @@ -27,16 +27,8 @@ type EmoteInfo struct { Code string } -func runPath() string { - ex, er := os.Executable() - if er != nil { - panic(er) - } - return filepath.Dir(ex) -} - func loadEmotes() error { - newEmotes, err := processEmoteDir(runPath() + emoteDir) + newEmotes, err := processEmoteDir(common.RunPath() + emoteDir) if err != nil { return err } diff --git a/handlers.go b/handlers.go index c75130f..4815401 100644 --- a/handlers.go +++ b/handlers.go @@ -46,22 +46,23 @@ func (self writeFlusher) Flush() error { // Serving static files func wsStaticFiles(w http.ResponseWriter, r *http.Request) { + var runPath string = common.RunPath() switch r.URL.Path { case "/favicon.ico": - http.ServeFile(w, r, runPath()+"/favicon.png") + http.ServeFile(w, r, runPath+"/favicon.png") return case "/justchat": - http.ServeFile(w, r, runPath()+"/static/justchat.html") + http.ServeFile(w, r, runPath+"/static/justchat.html") return case "/justvideo": - http.ServeFile(w, r, runPath()+"/static/justvideo.html") + http.ServeFile(w, r, runPath+"/static/justvideo.html") return } goodPath := r.URL.Path[8:len(r.URL.Path)] - common.LogDebugf("[static] serving %q from folder %s\n", goodPath, runPath()) + common.LogDebugf("[static] serving %q from folder %s\n", goodPath, runPath) - http.ServeFile(w, r, runPath()+"/static/"+goodPath) + http.ServeFile(w, r, runPath+"/static/"+goodPath) } func wsWasmFile(w http.ResponseWriter, r *http.Request) { @@ -69,17 +70,17 @@ func wsWasmFile(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache, must-revalidate") } common.LogDebugln("[static] serving wasm file") - http.ServeFile(w, r, runPath()+"/static/main.wasm") + http.ServeFile(w, r, common.RunPath()+"/static/main.wasm") } func wsImages(w http.ResponseWriter, r *http.Request) { base := filepath.Base(r.URL.Path) common.LogDebugln("[img] ", base) - http.ServeFile(w, r, runPath()+"/static/img/"+base) + http.ServeFile(w, r, common.RunPath()+"/static/img/"+base) } func wsEmotes(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, path.Join(runPath()+"/static/", r.URL.Path)) + http.ServeFile(w, r, path.Join(common.RunPath()+"/static/", r.URL.Path)) } // Handling the websocket diff --git a/settings.go b/settings.go index 4b2408d..d560a33 100644 --- a/settings.go +++ b/settings.go @@ -85,7 +85,7 @@ func LoadSettings(filename string) (*Settings, error) { } s.filename = filename - var logFileDir string = runPath() + "/" + s.LogFile + var logFileDir string = common.RunPath() + "/" + s.LogFile fmt.Printf("Log file: %s\n", logFileDir) if err = common.SetupLogging(s.LogLevel, logFileDir); err != nil { return nil, fmt.Errorf("Unable to setup logger: %s", err) From 9f6061c1d79f30fd64514de8bfab35447d246561 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 17:55:26 +0200 Subject: [PATCH 046/101] Changed EOL into readme.md --- readme.md | 352 +++++++++++++++++++++++++++--------------------------- 1 file changed, 176 insertions(+), 176 deletions(-) diff --git a/readme.md b/readme.md index c1261b7..e8086a6 100644 --- a/readme.md +++ b/readme.md @@ -1,176 +1,176 @@ -<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> -**Table of Contents** -- [MovieNight stream server](#movienight-stream-server) - - [Build requirements](#build-requirements) - - [Older Go Versions](#older-go-versions) - - [Compile and install](#compile-and-install) - - [Docker build](#docker-build) - - [Building the Container](#building-the-container) - - [Running the Container](#running-the-container) - - [docker-compose](#docker-compose) - - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) - - [FreeNAS / FreeBSD build and run](#FreeNAS-FreeBSD) - - [Usage](#usage) - - [Configuration](#configuration) - -<!-- markdown-toc end --> -# MovieNight stream server -[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) - -This is a single-instance streaming server with chat. Originally written to -replace Rabbit as the platform for watching movies with a group of people -online. - -## Build requirements -- Go 1.13 or newer -- GNU Make - -### Older Go Versions -You can install a newer version of Go alongside your OS's distribution by -following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) - -Once you have that setup add an enviromnent variable named `GO_VERSION` and -set it to the version you installed (eg, `1.14.1`). The Makefile will now use -the newer version. - -### Compile and install -You have to : -- download **git clone https://github.com/zorchenhimer/MovieNight**, go into the source directory **cd MovieNight**; -- choose your `TARGET` oneof "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"; -- choose your `ARCH` oneof "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"; -- build **make TARGET=windows ARCH=386**; -- and run **./MovieNight**; - -Example : -```bash -$ git clone https://github.com/zorchenhimer/MovieNight -$ cd MovieNight -$ make TARGET=windows ARCH=386 -$ ./MovieNight -``` - -### Docker build -MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. - -#### Building the Container -Install Docker, clone the repository and build: - -```shell -docker build -t movienight . -``` - -#### Running the Container -Run the image once it's built: - -```shell -docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight -``` - -Explanation: -- **-d** runs the container in the background. -- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. -- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. -- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] - -#### docker-compose -docker-compose will automatically build the image, no need to build it manually. - -Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: - -```shell -docker-compose up -d -``` - -This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. - -#### Notes for Running Using docker-compose -The container needs to be restarted to apply any changes you make to *settings.json*. - -### FreeNAS - FreeBSD build and run -An script wich setup an Jail and build and run MovieNight into that Jail as been writen, you'll find it here [freenas-iocage-movienight] (https://github.com/zorglube/freenas-iocage-movienight) - -## Usage -Now you can use OBS to push a stream to the server. Set the stream URL to - -```text -rtmp://your.domain.host/live -``` - -and enter the stream key. - -Now you can view the stream at - -```text -http://your.domain.host:8089/ -``` - -There is a video only version at - -```text -http://your.domain.host:8089/video -``` - -and a chat only version at - -```text -http://your.domain.host:8089/chat -``` - -The default listen port is `:8089`. It can be changed by providing a new port -at startup: - -```text -Usage of .\MovieNight.exe: - -e bool - Whether or not to download approved emotes on startup (default "false") - -k string - Stream key, to protect your stream (default: "") - -l string - host:port of the MovieNight (default ":8089") - -r string - host:port of the RTMP server (default ":1935") - -f string - the settings file you want to use (default "./settings.json") -``` - -## Configuration -MovieNight’s configuration is controlled by `settings.json`: - -- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves - admin privileges. This value is automatically regenerated unless - `RegenAdminPass` is false. -- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into - MovieNight. Using `/addemotes <username>` in chat will add to this list. -- `Bans`: list of banned users. -- `LetThemLurk`: if false, announces when a user enters and leaves chat. -- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. -- `LogFile`: the path of the MovieNight logfile, relative to the executable. -- `LogLevel`: the log level, defaults to `debug`. -- `MaxMessageCount`: the number of messages displayed in the chat window. -- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. -- `PageTitle`: The base string used in the `<title>` element of the page. When - the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` -- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. -- `RoomAccess`: the access policy of the chat room; this is managed by the - application and should not be edited manually. -- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. -- `SessionKey`: key used for storing session data (cookies etc.) -- `StreamKey`: the key that OBS will use to connect to MovieNight. -- `StreamStats`: if true, prints statistics for the stream on server shutdown. -- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). -- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes -- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). -- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons - or brackets; e.g., `:PogChamp:` -- `RateLimitChat`: the number of seconds between each message a non-privileged - user can post in chat. -- `RateLimitNick`: the number of seconds before a user can change their nick again. -- `RakeLimitColor`: the number of seconds before a user can change their color again. -- `RateLimitAuth`: the number of seconds between each allowed auth attempt -- `RateLimitDuplicate`: the numeber of seconds before a user can post a - duplicate message. -- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP - header, to prevent caching responses. - -## License -`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. +<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> +**Table of Contents** +- [MovieNight stream server](#movienight-stream-server) + - [Build requirements](#build-requirements) + - [Older Go Versions](#older-go-versions) + - [Compile and install](#compile-and-install) + - [Docker build](#docker-build) + - [Building the Container](#building-the-container) + - [Running the Container](#running-the-container) + - [docker-compose](#docker-compose) + - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) + - [FreeNAS / FreeBSD build and run](#FreeNAS-FreeBSD) + - [Usage](#usage) + - [Configuration](#configuration) + +<!-- markdown-toc end --> +# MovieNight stream server +[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) + +This is a single-instance streaming server with chat. Originally written to +replace Rabbit as the platform for watching movies with a group of people +online. + +## Build requirements +- Go 1.13 or newer +- GNU Make + +### Older Go Versions +You can install a newer version of Go alongside your OS's distribution by +following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) + +Once you have that setup add an enviromnent variable named `GO_VERSION` and +set it to the version you installed (eg, `1.14.1`). The Makefile will now use +the newer version. + +### Compile and install +You have to : +- download **git clone https://github.com/zorchenhimer/MovieNight**, go into the source directory **cd MovieNight**; +- choose your `TARGET` oneof "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"; +- choose your `ARCH` oneof "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"; +- build **make TARGET=windows ARCH=386**; +- and run **./MovieNight**; + +Example : +```bash +$ git clone https://github.com/zorchenhimer/MovieNight +$ cd MovieNight +$ make TARGET=windows ARCH=386 +$ ./MovieNight +``` + +### Docker build +MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. + +#### Building the Container +Install Docker, clone the repository and build: + +```shell +docker build -t movienight . +``` + +#### Running the Container +Run the image once it's built: + +```shell +docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight +``` + +Explanation: +- **-d** runs the container in the background. +- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. +- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. +- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL] + +#### docker-compose +docker-compose will automatically build the image, no need to build it manually. + +Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: + +```shell +docker-compose up -d +``` + +This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host. + +#### Notes for Running Using docker-compose +The container needs to be restarted to apply any changes you make to *settings.json*. + +### FreeNAS - FreeBSD build and run +An script wich setup an Jail and build and run MovieNight into that Jail as been writen, you'll find it here [freenas-iocage-movienight] (https://github.com/zorglube/freenas-iocage-movienight) + +## Usage +Now you can use OBS to push a stream to the server. Set the stream URL to + +```text +rtmp://your.domain.host/live +``` + +and enter the stream key. + +Now you can view the stream at + +```text +http://your.domain.host:8089/ +``` + +There is a video only version at + +```text +http://your.domain.host:8089/video +``` + +and a chat only version at + +```text +http://your.domain.host:8089/chat +``` + +The default listen port is `:8089`. It can be changed by providing a new port +at startup: + +```text +Usage of .\MovieNight.exe: + -e bool + Whether or not to download approved emotes on startup (default "false") + -k string + Stream key, to protect your stream (default: "") + -l string + host:port of the MovieNight (default ":8089") + -r string + host:port of the RTMP server (default ":1935") + -f string + the settings file you want to use (default "./settings.json") +``` + +## Configuration +MovieNight’s configuration is controlled by `settings.json`: + +- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves + admin privileges. This value is automatically regenerated unless + `RegenAdminPass` is false. +- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into + MovieNight. Using `/addemotes <username>` in chat will add to this list. +- `Bans`: list of banned users. +- `LetThemLurk`: if false, announces when a user enters and leaves chat. +- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. +- `LogFile`: the path of the MovieNight logfile, relative to the executable. +- `LogLevel`: the log level, defaults to `debug`. +- `MaxMessageCount`: the number of messages displayed in the chat window. +- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. +- `PageTitle`: The base string used in the `<title>` element of the page. When + the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` +- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. +- `RoomAccess`: the access policy of the chat room; this is managed by the + application and should not be edited manually. +- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. +- `SessionKey`: key used for storing session data (cookies etc.) +- `StreamKey`: the key that OBS will use to connect to MovieNight. +- `StreamStats`: if true, prints statistics for the stream on server shutdown. +- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). +- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes +- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). +- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons + or brackets; e.g., `:PogChamp:` +- `RateLimitChat`: the number of seconds between each message a non-privileged + user can post in chat. +- `RateLimitNick`: the number of seconds before a user can change their nick again. +- `RakeLimitColor`: the number of seconds before a user can change their color again. +- `RateLimitAuth`: the number of seconds between each allowed auth attempt +- `RateLimitDuplicate`: the numeber of seconds before a user can post a + duplicate message. +- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP + header, to prevent caching responses. + +## License +`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. From eb5cb38d10f3993420b9e60ad6f0fd4abd4ae1f1 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 18:03:45 +0200 Subject: [PATCH 047/101] Create MakeFile.BSD --- Makefile | 14 ++++++++------ Makefile.BSD | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 Makefile.BSD diff --git a/Makefile b/Makefile index 7dcda28..e7fa083 100644 --- a/Makefile +++ b/Makefile @@ -5,21 +5,23 @@ # For info on installing extra versions, see this page: # https://golang.org/doc/install#extra_versions -# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" -# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" - TAGS= +# Windows needs the .exe extension. +ifeq ($(OS),Windows_NT) +EXT=.exe +endif + .PHONY: fmt vet get clean dev setdev test ServerMovieNight -all: fmt vet test MovieNight static/main.wasm settings.json +all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm # Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") @@ -36,7 +38,7 @@ static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go clean: - -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js + -rm MovieNight$(EXT) ./static/main.wasm ./static/js/wasm_exec.js fmt: gofmt -w . diff --git a/Makefile.BSD b/Makefile.BSD new file mode 100644 index 0000000..17f72d3 --- /dev/null +++ b/Makefile.BSD @@ -0,0 +1,54 @@ +# If a different version of Go is installed (via `go get`) set the GO_VERSION +# environment variable to that version. For example, setting it to "1.13.7" +# will run `go1.13.7 build [...]` instead of `go build [...]`. +# +# For info on installing extra versions, see this page: +# https://golang.org/doc/install#extra_versions + +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + +TAGS= + +.PHONY: fmt vet get clean dev setdev test ServerMovieNight + +all: fmt vet test MovieNight static/main.wasm settings.json + +# Build the server deployment +server: ServerMovieNight static/main.wasm + +# Bulid used for deploying to my server. +ServerMovieNight: *.go common/*.go + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) + +setdev: + $(eval export TAGS=-tags "dev") + +dev: setdev all + +MovieNight: *.go common/*.go + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) + +static/js/wasm_exec.js: + cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ + +static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go + GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go + +clean: + -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js + +fmt: + gofmt -w . + +vet: + go$(GO_VERSION) vet $(TAGS) ./... + GOOS=js GOARCH=wasm go$(GO_VERSION) vet $(TAGS) ./... + +test: + go$(GO_VERSION) test $(TAGS) ./... + +# Do not put settings_example.json here as a prereq to avoid overwriting +# the settings if the example is updated. +settings.json: + cp settings_example.json settings.json From eb4cc640eb8977bcb09cb2bc6c50fa530a5ca71c Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 11 Sep 2020 14:08:54 +0200 Subject: [PATCH 048/101] Typo --- Makefile.BSD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.BSD b/Makefile.BSD index 17f72d3..6856566 100644 --- a/Makefile.BSD +++ b/Makefile.BSD @@ -17,7 +17,7 @@ all: fmt vet test MovieNight static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm -# Bulid used for deploying to my server. +# Build used for deploying to my server. ServerMovieNight: *.go common/*.go GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) From 994e0b7a4bc2a1699a05a5267ab335691bd7478e Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 11 Sep 2020 14:09:48 +0200 Subject: [PATCH 049/101] Typo + cross-compile arch --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e7fa083..3525e5a 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,9 @@ all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm -# Bulid used for deploying to my server. +# Build used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") @@ -29,7 +29,7 @@ setdev: dev: setdev all MovieNight$(EXT): *.go common/*.go - go$(GO_VERSION) build -o $@ $(TAGS) + GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) static/js/wasm_exec.js: cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ From 7d7c964ea43b326b6898488126034bd432f9f113 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 11 Sep 2020 14:10:57 +0200 Subject: [PATCH 050/101] Libs update --- go.mod | 9 +++++---- go.sum | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 80a73c0..1352df3 100644 --- a/go.mod +++ b/go.mod @@ -7,13 +7,14 @@ require ( github.com/cenkalti/backoff v2.1.1+incompatible // indirect github.com/chromedp/cdproto v0.0.0-20190412020601-c4267f5c421a // indirect github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 // indirect - github.com/gorilla/sessions v1.1.3 - github.com/gorilla/websocket v1.4.0 + github.com/gorilla/context v1.1.1 // indirect + github.com/gorilla/sessions v1.2.1 + github.com/gorilla/websocket v1.4.2 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect - github.com/nareix/joy4 v0.0.0-20181022032202-3ddbc8f9d431 + github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 github.com/ory/dockertest v3.3.4+incompatible // indirect - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.4.1 // indirect github.com/stretchr/objx v0.2.0 // indirect golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a // indirect diff --git a/go.sum b/go.sum index 6ddf141..81086ed 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,12 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.1.3 h1:uXoZdcdA5XdXF3QzuSlheVRUvjl+1rKY7zBXL68L9RU= github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= +github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= +github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls= @@ -54,6 +58,8 @@ github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/nareix/joy4 v0.0.0-20181022032202-3ddbc8f9d431 h1:nWhrOsCKdV6bivw03k7MROF2tYzCFGfYBYFrTEHyucs= github.com/nareix/joy4 v0.0.0-20181022032202-3ddbc8f9d431/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I= +github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 h1:Yp0zFEufLz0H7jzffb4UPXijavlyqlYeOg7dcyVUNnQ= +github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= @@ -67,6 +73,8 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= From 96bd1b94524588a129c808124fd87638ac3ee364 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 051/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- .gitignore | 2 ++ Makefile | 7 +++++-- readme.md | 11 ++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index d996f8d..7e1383f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ tags # channel and emote list from twitch subscribers.json +/.settings/ +/.project diff --git a/Makefile b/Makefile index e7fa083..f693306 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,13 @@ # For info on installing extra versions, see this page: # https://golang.org/doc/install#extra_versions +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + TAGS= # Windows needs the .exe extension. -ifeq ($(OS),Windows_NT) +ifeq ($(TARGET),windows) EXT=.exe endif @@ -21,7 +24,7 @@ server: ServerMovieNight static/main.wasm # Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") diff --git a/readme.md b/readme.md index 9e8506a..fae361e 100644 --- a/readme.md +++ b/readme.md @@ -37,13 +37,18 @@ set it to the version you installed (eg, `1.14.1`). The Makefile will now use the newer version. ### Compile and install - -To just download and run: +You have to : + - download ; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" + ; + - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + ; + - and run ; ```bash $ git clone https://github.com/zorchenhimer/MovieNight $ cd MovieNight -$ make +$ make TARGET=windows ARCH=386 $ ./MovieNight ``` From a12d24e34902649d7c47f681a977c0f9feadb6c9 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 052/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- readme.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index fae361e..29cb158 100644 --- a/readme.md +++ b/readme.md @@ -38,12 +38,10 @@ the newer version. ### Compile and install You have to : - - download ; - - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" - ; - - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" - ; - - and run ; + - download the code; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"; + - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"; + - and run; ```bash $ git clone https://github.com/zorchenhimer/MovieNight From 1d539a00d25025cc187bb1d8f87fa6b0f3c15501 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:20:45 +0200 Subject: [PATCH 053/101] CleverCloud deploy conf --- clevercloud/go.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 clevercloud/go.json diff --git a/clevercloud/go.json b/clevercloud/go.json new file mode 100644 index 0000000..aa93730 --- /dev/null +++ b/clevercloud/go.json @@ -0,0 +1,7 @@ +{ + "deploy": { + "appIsGoPath": false, + "main": "MovieNight", + "execDir": "./" + } +} From eb2547f7e6eb1f4c6f8e08bda1d24511b8e38bd4 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:30:40 +0200 Subject: [PATCH 054/101] Clever Cloud : "appIsGoPath": true, --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From 62cc0be675a8e872c007cb5e2be73cc2d03260b0 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:34:16 +0200 Subject: [PATCH 055/101] Clever Cloud : "appIsGoPath": false --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From 42b2e478fc6a778686e81e1eaca04a90e5210fe1 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:45:30 +0200 Subject: [PATCH 056/101] "appIsGoPath": true --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From a63bd7a400891d12c18b3bf41d8d2d31a76d1b0e Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 057/101] Revert ""appIsGoPath": true" This reverts commit 5d0786577e6dd5de07fab2a33dff7b0a2b3264e6. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From cc6ce54f0d4167b13c27819c3693bcd056374306 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 058/101] Revert "Clever Cloud : "appIsGoPath": false" This reverts commit dcad017738eeadcaf8894a12fb9e1307ac59ae52. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From 02cebe4719741e94a8c2ce6279eee858ca547cc0 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 059/101] Revert "Clever Cloud : "appIsGoPath": true," This reverts commit b75f9e6ca0431fdd6cf89bb449bd59c138165525. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From a230cebbcca346ee488368baef6440081773d64c Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 15:50:32 +0200 Subject: [PATCH 060/101] GitHub CI/CD --- .github/workflows/go.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..ae14b35 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight + + - name: Test + run: go test -v . From 4948b1a4930662ef82bc373d3fdb9bfb4021701e Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:02:02 +0200 Subject: [PATCH 061/101] Release FreeBSD --- .github/workflows/go.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ae14b35..8c1493d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,8 @@ on: branches: [ master ] pull_request: branches: [ master ] + release: + types: [created] jobs: @@ -35,3 +37,15 @@ jobs: - name: Test run: go test -v . + + release-freebsd-amd64: + name: release freebsd/amd64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: wangyoucao577/go-release-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: FreeBSD + goarch: amd64 + From 6ed9e1f3af25aee2fb44b54321b6420731faf5bd Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:04:49 +0200 Subject: [PATCH 062/101] Release update --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8c1493d..19e10fd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: wangyoucao577/go-release-action@master + - uses: zorglube/go-release-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: FreeBSD From 2a8909af5a3b3cd68e0defcf19bbe0b60147e5a4 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:07:36 +0200 Subject: [PATCH 063/101] Remove release --- .github/workflows/go.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 19e10fd..ae14b35 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,8 +5,6 @@ on: branches: [ master ] pull_request: branches: [ master ] - release: - types: [created] jobs: @@ -37,15 +35,3 @@ jobs: - name: Test run: go test -v . - - release-freebsd-amd64: - name: release freebsd/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: zorglube/go-release-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: FreeBSD - goarch: amd64 - From 80bb1a2285ab8b208087e20d9c2ee11bfc4f1f2a Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:09:25 +0200 Subject: [PATCH 064/101] Remove git workflow --- .github/workflows/go.yml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index ae14b35..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Go - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - - - name: Build - run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight - - - name: Test - run: go test -v . From fde8ae5c15a993c7f34a876731eaf65c88074c9c Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 065/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- readme.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 29cb158..fae361e 100644 --- a/readme.md +++ b/readme.md @@ -38,10 +38,12 @@ the newer version. ### Compile and install You have to : - - download the code; - - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"; - - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"; - - and run; + - download ; + - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" + ; + - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + ; + - and run ; ```bash $ git clone https://github.com/zorchenhimer/MovieNight From d3f89e0fae284cd49ea9b8a20d45e7d20291afb5 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 066/101] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index fae361e..08717d6 100644 --- a/readme.md +++ b/readme.md @@ -41,7 +41,7 @@ You have to : - download ; - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" ; - - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + - choose you `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" ; - and run ; From 8905dc856c8bbb56235db29d8d4c2c9761a4f3d7 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:30:40 +0200 Subject: [PATCH 067/101] Clever Cloud : "appIsGoPath": true, --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From bd87a281776a88ff9495b1859ace5b26f164d322 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:34:16 +0200 Subject: [PATCH 068/101] Clever Cloud : "appIsGoPath": false --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From a0e76fcd6a18559e2e7909ddcd81ddda04f86c45 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 14:45:30 +0200 Subject: [PATCH 069/101] "appIsGoPath": true --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From fc64d471f0d21d6da2280ecae5fc0de6c2805b83 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 070/101] Revert ""appIsGoPath": true" This reverts commit 5d0786577e6dd5de07fab2a33dff7b0a2b3264e6. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From 04c7a687640bb51f89f97e9ee2f54b24145cfb2d Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 071/101] Revert "Clever Cloud : "appIsGoPath": false" This reverts commit dcad017738eeadcaf8894a12fb9e1307ac59ae52. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index aa93730..e05b1ed 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": false, + "appIsGoPath": true, "main": "MovieNight", "execDir": "./" } From acbb81ce448b288e81b89558a9b130491224664e Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 14:47:24 +0200 Subject: [PATCH 072/101] Revert "Clever Cloud : "appIsGoPath": true," This reverts commit b75f9e6ca0431fdd6cf89bb449bd59c138165525. --- clevercloud/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clevercloud/go.json b/clevercloud/go.json index e05b1ed..aa93730 100644 --- a/clevercloud/go.json +++ b/clevercloud/go.json @@ -1,6 +1,6 @@ { "deploy": { - "appIsGoPath": true, + "appIsGoPath": false, "main": "MovieNight", "execDir": "./" } From a3c9e78b8ff1e5415a1c8225a34f9b98253ad64a Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 15:50:32 +0200 Subject: [PATCH 073/101] GitHub CI/CD --- .github/workflows/go.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..ae14b35 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight + + - name: Test + run: go test -v . From 820187cbc3f7c4a2cc7ca265ae9541a21648a50d Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:02:02 +0200 Subject: [PATCH 074/101] Release FreeBSD --- .github/workflows/go.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ae14b35..8c1493d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,8 @@ on: branches: [ master ] pull_request: branches: [ master ] + release: + types: [created] jobs: @@ -35,3 +37,15 @@ jobs: - name: Test run: go test -v . + + release-freebsd-amd64: + name: release freebsd/amd64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: wangyoucao577/go-release-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: FreeBSD + goarch: amd64 + From 8dba51a06f2d5a1b71620fa668989ed8e8d78cce Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:04:49 +0200 Subject: [PATCH 075/101] Release update --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8c1493d..19e10fd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: wangyoucao577/go-release-action@master + - uses: zorglube/go-release-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} goos: FreeBSD From 9cfa76b7fcc69afa60d51f82692b27eb0474226f Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:07:36 +0200 Subject: [PATCH 076/101] Remove release --- .github/workflows/go.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 19e10fd..ae14b35 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,8 +5,6 @@ on: branches: [ master ] pull_request: branches: [ master ] - release: - types: [created] jobs: @@ -37,15 +35,3 @@ jobs: - name: Test run: go test -v . - - release-freebsd-amd64: - name: release freebsd/amd64 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: zorglube/go-release-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: FreeBSD - goarch: amd64 - From 0c5d7d40f8196cc0d88450ba7c4550d85ce90a6c Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:09:25 +0200 Subject: [PATCH 077/101] Remove git workflow --- .github/workflows/go.yml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index ae14b35..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Go - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ^1.13 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - - - name: Build - run: TARGET="FreeBSD" ARCH="amd64" go build -o MovieNight - - - name: Test - run: go test -v . From 6fc0391a6dd559ed7d1cc05579d2b6d42b5328bf Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Wed, 19 Aug 2020 16:54:01 +0200 Subject: [PATCH 078/101] remove Clever Could conf --- clevercloud/go.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 clevercloud/go.json diff --git a/clevercloud/go.json b/clevercloud/go.json deleted file mode 100644 index aa93730..0000000 --- a/clevercloud/go.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "deploy": { - "appIsGoPath": false, - "main": "MovieNight", - "execDir": "./" - } -} From 660b4438b31228cbb4d82cd76ca1f6e5c21273b7 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:21:58 +0200 Subject: [PATCH 079/101] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 55a3d40..c580bbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,5 @@ go: env: - GO111MODULE=on + - ARCH=amd64 + - TARGET=FreeBSD From 7b64f4463f231671f1bdce102fbfc4697b4ebd08 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:24:39 +0200 Subject: [PATCH 080/101] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c580bbd..55a3d40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,3 @@ go: env: - GO111MODULE=on - - ARCH=amd64 - - TARGET=FreeBSD From 6a87ac6def01add007af096d8e7027625117d02c Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 14:37:42 +0200 Subject: [PATCH 081/101] BSD Make if --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f693306..07998fb 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,9 @@ TAGS= # Windows needs the .exe extension. -ifeq ($(TARGET),windows) +.if ${TARGET} == "windows" EXT=.exe -endif +.endif .PHONY: fmt vet get clean dev setdev test ServerMovieNight From 77a707eea62d5fc79ba7d087af01b1f18b2bab85 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:14:57 +0200 Subject: [PATCH 082/101] Add conf file var --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3dfeeac..e65c284 100644 --- a/main.go +++ b/main.go @@ -20,11 +20,12 @@ var ( sKey string stats = newStreamStats() sAdminPass string + confFile string ) func setupSettings() error { var err error - settings, err = LoadSettings("settings.json") + settings, err = LoadSettings(confFile) if err != nil { return fmt.Errorf("Unable to load settings: %s", err) } @@ -53,6 +54,7 @@ func main() { flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") flag.StringVar(&sAdminPass, "a", "", "Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json.") flag.BoolVar(&pullEmotes, "e", false, "Pull emotes") + flag.StringVar(&confFile, "f", "", "URI of the conf file") flag.Parse() format.RegisterAll() From dc2965194c344985f177d57d6c086cbe2fbf939c Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:49:26 +0200 Subject: [PATCH 083/101] Relative dir --- main.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index e65c284..2ac6f1a 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "os/signal" + "path/filepath" "github.com/gorilla/sessions" "github.com/nareix/joy4/format" @@ -21,6 +22,7 @@ var ( stats = newStreamStats() sAdminPass string confFile string + path string ) func setupSettings() error { @@ -49,6 +51,7 @@ func setupSettings() error { } func main() { + &path, err := filepath.Abs(filepath.Dir(os.Args[0])) flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") @@ -132,20 +135,20 @@ func startRmtpServer() { func startServer() { // Chat websocket - http.HandleFunc("/ws", wsHandler) - http.HandleFunc("/static/js/", wsStaticFiles) - http.HandleFunc("/static/css/", wsStaticFiles) - http.HandleFunc("/static/img/", wsImages) - http.HandleFunc("/static/main.wasm", wsWasmFile) - http.HandleFunc("/emotes/", wsEmotes) - http.HandleFunc("/favicon.ico", wsStaticFiles) - http.HandleFunc("/chat", handleIndexTemplate) - http.HandleFunc("/video", handleIndexTemplate) - http.HandleFunc("/help", handleHelpTemplate) - http.HandleFunc("/pin", handlePin) - http.HandleFunc("/emotes", handleEmoteTemplate) + http.HandleFunc(path+"/ws", wsHandler) + http.HandleFunc(path+"/static/js/", wsStaticFiles) + http.HandleFunc(path+"/static/css/", wsStaticFiles) + http.HandleFunc(path+"/static/img/", wsImages) + http.HandleFunc(path+"/static/main.wasm", wsWasmFile) + http.HandleFunc(path+"/emotes/", wsEmotes) + http.HandleFunc(path+"/favicon.ico", wsStaticFiles) + http.HandleFunc(path+"/chat", handleIndexTemplate) + http.HandleFunc(path+"/video", handleIndexTemplate) + http.HandleFunc(path+"/help", handleHelpTemplate) + http.HandleFunc(path+"/pin", handlePin) + http.HandleFunc(path+"/emotes", handleEmoteTemplate) - http.HandleFunc("/", handleDefault) + http.HandleFunc(path+"/", handleDefault) err := http.ListenAndServe(addr, nil) if err != nil { From 4153c7c84b44d4bc8fd85cd3a504daa263f1c850 Mon Sep 17 00:00:00 2001 From: Zorglube <630192+zorglube@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:53:49 +0200 Subject: [PATCH 084/101] absolut dir --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 2ac6f1a..d64baea 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,11 @@ func setupSettings() error { func main() { &path, err := filepath.Abs(filepath.Dir(os.Args[0])) + if err != nil { + log.Fatal(err) + } + fmt.Println(path) + flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") From 7cacf930fec11f9797ef6aaff6195de0f99cf954 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Thu, 20 Aug 2020 19:06:34 +0200 Subject: [PATCH 085/101] Relative running --- main.go | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index d64baea..9aa55a6 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ var ( stats = newStreamStats() sAdminPass string confFile string - path string + runPath string ) func setupSettings() error { @@ -51,11 +51,12 @@ func setupSettings() error { } func main() { - &path, err := filepath.Abs(filepath.Dir(os.Args[0])) - if err != nil { - log.Fatal(err) - } - fmt.Println(path) + ex, er := os.Executable() + if er != nil { + panic(er) + } + runPath := filepath.Dir(ex) + fmt.Println(runPath) flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") @@ -140,20 +141,20 @@ func startRmtpServer() { func startServer() { // Chat websocket - http.HandleFunc(path+"/ws", wsHandler) - http.HandleFunc(path+"/static/js/", wsStaticFiles) - http.HandleFunc(path+"/static/css/", wsStaticFiles) - http.HandleFunc(path+"/static/img/", wsImages) - http.HandleFunc(path+"/static/main.wasm", wsWasmFile) - http.HandleFunc(path+"/emotes/", wsEmotes) - http.HandleFunc(path+"/favicon.ico", wsStaticFiles) - http.HandleFunc(path+"/chat", handleIndexTemplate) - http.HandleFunc(path+"/video", handleIndexTemplate) - http.HandleFunc(path+"/help", handleHelpTemplate) - http.HandleFunc(path+"/pin", handlePin) - http.HandleFunc(path+"/emotes", handleEmoteTemplate) + http.HandleFunc(runPath+"/ws", wsHandler) + http.HandleFunc(runPath+"/static/js/", wsStaticFiles) + http.HandleFunc(runPath+"/static/css/", wsStaticFiles) + http.HandleFunc(runPath+"/static/img/", wsImages) + http.HandleFunc(runPath+"/static/main.wasm", wsWasmFile) + http.HandleFunc(runPath+"/emotes/", wsEmotes) + http.HandleFunc(runPath+"/favicon.ico", wsStaticFiles) + http.HandleFunc(runPath+"/chat", handleIndexTemplate) + http.HandleFunc(runPath+"/video", handleIndexTemplate) + http.HandleFunc(runPath+"/help", handleHelpTemplate) + http.HandleFunc(runPath+"/pin", handlePin) + http.HandleFunc(runPath+"/emotes", handleEmoteTemplate) - http.HandleFunc(path+"/", handleDefault) + http.HandleFunc(runPath+"/", handleDefault) err := http.ListenAndServe(addr, nil) if err != nil { From 2ca6b9c59c6932db5e9cf083533202717557e513 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 11:59:58 +0200 Subject: [PATCH 086/101] Run from anywhere Get the runpath at runtime, in order to run MovieNight from whatever position into the filesystem. --- common/templates.go | 24 ++++++++++++++++-------- emotes.go | 10 +++++++--- handlers.go | 25 +++++++++++++++++-------- main.go | 36 ++++++++++++++---------------------- 4 files changed, 54 insertions(+), 41 deletions(-) diff --git a/common/templates.go b/common/templates.go index e8b3abb..6790d45 100644 --- a/common/templates.go +++ b/common/templates.go @@ -4,6 +4,8 @@ import ( "fmt" html "html/template" "net/http" + "os" + "path/filepath" "strings" text "text/template" ) @@ -16,14 +18,6 @@ var chatTemplates map[string]*text.Template var isServer bool = false -// keys and files to load for that template -var serverTemplateDefs map[string][]string = map[string][]string{ - "pin": []string{"./static/base.html", "./static/thedoor.html"}, - "main": []string{"./static/base.html", "./static/main.html"}, - "help": []string{"./static/base.html", "./static/help.html"}, - "emotes": []string{"./static/base.html", "./static/emotes.html"}, -} - var chatTemplateDefs map[string]string = map[string]string{ fmt.Sprint(DTInvalid, 0): "wot", @@ -38,6 +32,20 @@ func InitTemplates() error { isServer = true serverTemplates = make(map[string]*html.Template) chatTemplates = make(map[string]*text.Template) + ex, er := os.Executable() + if er != nil { + panic(er) + } + runPath := filepath.Dir(ex) + fmt.Println(runPath) + + // keys and files to load for that template + var serverTemplateDefs map[string][]string = map[string][]string{ + "pin": []string{runPath + "/static/base.html", runPath + "/static/thedoor.html"}, + "main": []string{runPath + "/static/base.html", runPath + "/static/main.html"}, + "help": []string{runPath + "/static/base.html", runPath + "/static/help.html"}, + "emotes": []string{runPath + "/static/base.html", runPath + "/static/emotes.html"}, + } // Parse server templates for key, files := range serverTemplateDefs { diff --git a/emotes.go b/emotes.go index f9d117c..8954e1b 100644 --- a/emotes.go +++ b/emotes.go @@ -15,7 +15,7 @@ import ( "github.com/zorchenhimer/MovieNight/common" ) -const emoteDir = "./static/emotes/" +const emoteDir = "/static/emotes/" type TwitchUser struct { ID string @@ -28,8 +28,12 @@ type EmoteInfo struct { } func loadEmotes() error { - //fmt.Println(processEmoteDir(emoteDir)) - newEmotes, err := processEmoteDir(emoteDir) + ex, er := os.Executable() + if er != nil { + panic(er) + } + runPath := filepath.Dir(ex) + newEmotes, err := processEmoteDir(runPath + emoteDir) if err != nil { return err } diff --git a/handlers.go b/handlers.go index 969fa97..554a239 100644 --- a/handlers.go +++ b/handlers.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "os" "path" "path/filepath" "strings" @@ -44,24 +45,32 @@ func (self writeFlusher) Flush() error { return nil } +func runPath() string { + ex, er := os.Executable() + if er != nil { + panic(er) + } + return filepath.Dir(ex) +} + // Serving static files func wsStaticFiles(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/favicon.ico": - http.ServeFile(w, r, "./favicon.png") + http.ServeFile(w, r, runPath()+"/favicon.png") return case "/justchat": - http.ServeFile(w, r, "./static/justchat.html") + http.ServeFile(w, r, runPath()+"/static/justchat.html") return case "/justvideo": - http.ServeFile(w, r, "./static/justvideo.html") + http.ServeFile(w, r, runPath()+"/static/justvideo.html") return } goodPath := r.URL.Path[8:len(r.URL.Path)] - common.LogDebugf("[static] serving %q from folder ./static/\n", goodPath) + common.LogDebugf("[static] serving %q from folder %s\n", goodPath, runPath()) - http.ServeFile(w, r, "./static/"+goodPath) + http.ServeFile(w, r, runPath()+"/static/"+goodPath) } func wsWasmFile(w http.ResponseWriter, r *http.Request) { @@ -69,17 +78,17 @@ func wsWasmFile(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache, must-revalidate") } common.LogDebugln("[static] serving wasm file") - http.ServeFile(w, r, "./static/main.wasm") + http.ServeFile(w, r, runPath()+"/static/main.wasm") } func wsImages(w http.ResponseWriter, r *http.Request) { base := filepath.Base(r.URL.Path) common.LogDebugln("[img] ", base) - http.ServeFile(w, r, "./static/img/"+base) + http.ServeFile(w, r, runPath()+"/static/img/"+base) } func wsEmotes(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, path.Join("./static/", r.URL.Path)) + http.ServeFile(w, r, path.Join(runPath()+"/static/", r.URL.Path)) } // Handling the websocket diff --git a/main.go b/main.go index 9aa55a6..54a03d9 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "net/http" "os" "os/signal" - "path/filepath" + // "path/filepath" "github.com/gorilla/sessions" "github.com/nareix/joy4/format" @@ -22,7 +22,6 @@ var ( stats = newStreamStats() sAdminPass string confFile string - runPath string ) func setupSettings() error { @@ -51,13 +50,6 @@ func setupSettings() error { } func main() { - ex, er := os.Executable() - if er != nil { - panic(er) - } - runPath := filepath.Dir(ex) - fmt.Println(runPath) - flag.StringVar(&addr, "l", "", "host:port of the HTTP server") flag.StringVar(&rtmpAddr, "r", "", "host:port of the RTMP server") flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") @@ -141,20 +133,20 @@ func startRmtpServer() { func startServer() { // Chat websocket - http.HandleFunc(runPath+"/ws", wsHandler) - http.HandleFunc(runPath+"/static/js/", wsStaticFiles) - http.HandleFunc(runPath+"/static/css/", wsStaticFiles) - http.HandleFunc(runPath+"/static/img/", wsImages) - http.HandleFunc(runPath+"/static/main.wasm", wsWasmFile) - http.HandleFunc(runPath+"/emotes/", wsEmotes) - http.HandleFunc(runPath+"/favicon.ico", wsStaticFiles) - http.HandleFunc(runPath+"/chat", handleIndexTemplate) - http.HandleFunc(runPath+"/video", handleIndexTemplate) - http.HandleFunc(runPath+"/help", handleHelpTemplate) - http.HandleFunc(runPath+"/pin", handlePin) - http.HandleFunc(runPath+"/emotes", handleEmoteTemplate) + http.HandleFunc("/ws", wsHandler) + http.HandleFunc("/static/js/", wsStaticFiles) + http.HandleFunc("/static/css/", wsStaticFiles) + http.HandleFunc("/static/img/", wsImages) + http.HandleFunc("/static/main.wasm", wsWasmFile) + http.HandleFunc("/emotes/", wsEmotes) + http.HandleFunc("/favicon.ico", wsStaticFiles) + http.HandleFunc("/chat", handleIndexTemplate) + http.HandleFunc("/video", handleIndexTemplate) + http.HandleFunc("/help", handleHelpTemplate) + http.HandleFunc("/pin", handlePin) + http.HandleFunc("/emotes", handleEmoteTemplate) - http.HandleFunc(runPath+"/", handleDefault) + http.HandleFunc("/", handleDefault) err := http.ListenAndServe(addr, nil) if err != nil { From 3b9ed93a1d82bb095fafbd6a321749a5ccb2cf89 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 12:01:54 +0200 Subject: [PATCH 087/101] Removed: if windows It isn't mandatory to be suffixed by ".exe" to be runnable into an windows. --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 07998fb..7dcda28 100644 --- a/Makefile +++ b/Makefile @@ -10,14 +10,9 @@ TAGS= -# Windows needs the .exe extension. -.if ${TARGET} == "windows" -EXT=.exe -.endif - .PHONY: fmt vet get clean dev setdev test ServerMovieNight -all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json +all: fmt vet test MovieNight static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm @@ -41,7 +36,7 @@ static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go clean: - -rm MovieNight$(EXT) ./static/main.wasm ./static/js/wasm_exec.js + -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js fmt: gofmt -w . From 070a753081102e010be4aac5f80b5e9a5b6c2604 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 12:01:54 +0200 Subject: [PATCH 088/101] Removed: if windows It isn't mandatory to be suffixed by ".exe" to be runnable into an windows. --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7dcda28..1ec3402 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,14 @@ TAGS= +# Windows needs the .exe extension. +#.if ${TARGET} == "windows" +#EXT=.exe +#.endif + .PHONY: fmt vet get clean dev setdev test ServerMovieNight -all: fmt vet test MovieNight static/main.wasm settings.json +all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm @@ -36,7 +41,7 @@ static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go clean: - -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js + -rm MovieNight$(EXT) ./static/main.wasm ./static/js/wasm_exec.js fmt: gofmt -w . From 9e69193739a94eea764c62246947a6181869ad21 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 12:29:00 +0200 Subject: [PATCH 089/101] settings.json default value --- main.go | 2 +- readme.md | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 54a03d9..b598480 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ func main() { flag.StringVar(&sKey, "k", "", "Stream key, to protect your stream") flag.StringVar(&sAdminPass, "a", "", "Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json.") flag.BoolVar(&pullEmotes, "e", false, "Pull emotes") - flag.StringVar(&confFile, "f", "", "URI of the conf file") + flag.StringVar(&confFile, "f", "./settings.json", "URI of the conf file") flag.Parse() format.RegisterAll() diff --git a/readme.md b/readme.md index 08717d6..8e5f696 100644 --- a/readme.md +++ b/readme.md @@ -30,7 +30,7 @@ online. ### Older Go Versions You can install a newer version of Go alongside your OS's distribution by -following the guide here: [https://golang.org/doc/manage-install](https://golang.org/doc/manage-install) +following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) Once you have that setup add an enviromnent variable named `GO_VERSION` and set it to the version you installed (eg, `1.14.1`). The Makefile will now use @@ -38,13 +38,13 @@ the newer version. ### Compile and install You have to : - - download ; - - choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" - ; - - choose you `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" - ; - - and run ; +- download **git clone https://github.com/zorchenhimer/MovieNight**, go into the source directory **cd MovieNight**; +- choose your `TARGET` oneof "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"; +- choose your `ARCH` oneof "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"; +- build **make TARGET=windows ARCH=386**; +- and run **./MovieNight**; +Example : ```bash $ git clone https://github.com/zorchenhimer/MovieNight $ cd MovieNight @@ -130,6 +130,8 @@ Usage of .\MovieNight.exe: host:port of the MovieNight (default ":8089") -r string host:port of the RTMP server (default ":1935") + -f string + the settings file you want to use (default "./settings.json") ``` ## Configuration From ae6cbe97e1c993475670dad6f1c2445d0aaf193e Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 21 Aug 2020 20:05:11 +0200 Subject: [PATCH 090/101] Very little factorize around "func runPath()" --- common/templates.go | 15 +++++++++------ emotes.go | 11 +++++++---- handlers.go | 9 --------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/common/templates.go b/common/templates.go index 6790d45..8659c79 100644 --- a/common/templates.go +++ b/common/templates.go @@ -27,17 +27,20 @@ var chatTemplateDefs map[string]string = map[string]string{ `</span> <span class="cmdme">{{.Message}}</span></span>`, } +func runPath() string { + ex, er := os.Executable() + if er != nil { + panic(er) + } + return filepath.Dir(ex) +} + // Called from the server func InitTemplates() error { isServer = true serverTemplates = make(map[string]*html.Template) chatTemplates = make(map[string]*text.Template) - ex, er := os.Executable() - if er != nil { - panic(er) - } - runPath := filepath.Dir(ex) - fmt.Println(runPath) + var runPath string = runPath() // keys and files to load for that template var serverTemplateDefs map[string][]string = map[string][]string{ diff --git a/emotes.go b/emotes.go index 8954e1b..9e76bba 100644 --- a/emotes.go +++ b/emotes.go @@ -27,13 +27,16 @@ type EmoteInfo struct { Code string } -func loadEmotes() error { +func runPath() string { ex, er := os.Executable() if er != nil { panic(er) } - runPath := filepath.Dir(ex) - newEmotes, err := processEmoteDir(runPath + emoteDir) + return filepath.Dir(ex) +} + +func loadEmotes() error { + newEmotes, err := processEmoteDir(runPath() + emoteDir) if err != nil { return err } @@ -92,7 +95,7 @@ func processEmoteDir(path string) (common.EmotesMap, error) { func findEmotes(dir string, em common.EmotesMap) (common.EmotesMap, error) { //em := NewEmotesMap() - fmt.Printf("finding emotes in %q\n", dir) + //fmt.Printf("finding emotes in %q\n", dir) emotePNGs, err := filepath.Glob(filepath.Join(dir, "*.png")) if err != nil { return em, fmt.Errorf("unable to glob emote directory: %s\n", err) diff --git a/handlers.go b/handlers.go index 554a239..c75130f 100644 --- a/handlers.go +++ b/handlers.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "net/http" - "os" "path" "path/filepath" "strings" @@ -45,14 +44,6 @@ func (self writeFlusher) Flush() error { return nil } -func runPath() string { - ex, er := os.Executable() - if er != nil { - panic(er) - } - return filepath.Dir(ex) -} - // Serving static files func wsStaticFiles(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { From 84511a7500a2db3babac402d2d2e745cd488fa58 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 00:05:30 +0200 Subject: [PATCH 091/101] Log file directory --- settings.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/settings.go b/settings.go index f19d288..4b2408d 100644 --- a/settings.go +++ b/settings.go @@ -85,7 +85,9 @@ func LoadSettings(filename string) (*Settings, error) { } s.filename = filename - if err = common.SetupLogging(s.LogLevel, s.LogFile); err != nil { + var logFileDir string = runPath() + "/" + s.LogFile + fmt.Printf("Log file: %s\n", logFileDir) + if err = common.SetupLogging(s.LogLevel, logFileDir); err != nil { return nil, fmt.Errorf("Unable to setup logger: %s", err) } From 614a94b000e8e9a58b8249d54bf10228a26127f2 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 13:12:40 +0200 Subject: [PATCH 092/101] Add DSB into builds --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 8e5f696..7ff3790 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,7 @@ - [Running the Container](#running-the-container) - [docker-compose](#docker-compose) - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) + - [FreeNAS / FreeBSD build and run](#FreeNAS-FreeBSD) - [Usage](#usage) - [Configuration](#configuration) @@ -89,6 +90,9 @@ This docker-compose file will create a volume called *movienight-config* and aut #### Notes for Running Using docker-compose The container needs to be restarted to apply any changes you make to *settings.json*. +### FreeNAS - FreeBSD build and run +An script wich setup an Jail and build and run MovieNight into that Jail as been writen, you'll find it here [freenas-iocage-movienight] (https://github.com/zorglube/freenas-iocage-movienight) + ## Usage Now you can use OBS to push a stream to the server. Set the stream URL to From 00b141b603187d177028473398233ccebc0ecc59 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 17:54:01 +0200 Subject: [PATCH 093/101] Factorize runPath() --- common/templates.go | 12 +----------- common/utils.go | 11 +++++++++++ emotes.go | 10 +--------- handlers.go | 17 +++++++++-------- settings.go | 2 +- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/common/templates.go b/common/templates.go index 8659c79..448bc29 100644 --- a/common/templates.go +++ b/common/templates.go @@ -4,8 +4,6 @@ import ( "fmt" html "html/template" "net/http" - "os" - "path/filepath" "strings" text "text/template" ) @@ -27,20 +25,12 @@ var chatTemplateDefs map[string]string = map[string]string{ `</span> <span class="cmdme">{{.Message}}</span></span>`, } -func runPath() string { - ex, er := os.Executable() - if er != nil { - panic(er) - } - return filepath.Dir(ex) -} - // Called from the server func InitTemplates() error { isServer = true serverTemplates = make(map[string]*html.Template) chatTemplates = make(map[string]*text.Template) - var runPath string = runPath() + var runPath string = RunPath() // keys and files to load for that template var serverTemplateDefs map[string][]string = map[string][]string{ diff --git a/common/utils.go b/common/utils.go index 4f1dda2..18e68d7 100644 --- a/common/utils.go +++ b/common/utils.go @@ -3,6 +3,8 @@ package common // Misc utils import ( + "os" + "path/filepath" "regexp" ) @@ -16,3 +18,12 @@ func IsValidName(name string) bool { return 3 <= len(name) && len(name) <= 36 && usernameRegex.MatchString(name) } + +// Return the absolut directory containing the MovieNight binary +func RunPath() string { + ex, er := os.Executable() + if er != nil { + panic(er) + } + return filepath.Dir(ex) +} diff --git a/emotes.go b/emotes.go index 9e76bba..6feeee4 100644 --- a/emotes.go +++ b/emotes.go @@ -27,16 +27,8 @@ type EmoteInfo struct { Code string } -func runPath() string { - ex, er := os.Executable() - if er != nil { - panic(er) - } - return filepath.Dir(ex) -} - func loadEmotes() error { - newEmotes, err := processEmoteDir(runPath() + emoteDir) + newEmotes, err := processEmoteDir(common.RunPath() + emoteDir) if err != nil { return err } diff --git a/handlers.go b/handlers.go index c75130f..4815401 100644 --- a/handlers.go +++ b/handlers.go @@ -46,22 +46,23 @@ func (self writeFlusher) Flush() error { // Serving static files func wsStaticFiles(w http.ResponseWriter, r *http.Request) { + var runPath string = common.RunPath() switch r.URL.Path { case "/favicon.ico": - http.ServeFile(w, r, runPath()+"/favicon.png") + http.ServeFile(w, r, runPath+"/favicon.png") return case "/justchat": - http.ServeFile(w, r, runPath()+"/static/justchat.html") + http.ServeFile(w, r, runPath+"/static/justchat.html") return case "/justvideo": - http.ServeFile(w, r, runPath()+"/static/justvideo.html") + http.ServeFile(w, r, runPath+"/static/justvideo.html") return } goodPath := r.URL.Path[8:len(r.URL.Path)] - common.LogDebugf("[static] serving %q from folder %s\n", goodPath, runPath()) + common.LogDebugf("[static] serving %q from folder %s\n", goodPath, runPath) - http.ServeFile(w, r, runPath()+"/static/"+goodPath) + http.ServeFile(w, r, runPath+"/static/"+goodPath) } func wsWasmFile(w http.ResponseWriter, r *http.Request) { @@ -69,17 +70,17 @@ func wsWasmFile(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache, must-revalidate") } common.LogDebugln("[static] serving wasm file") - http.ServeFile(w, r, runPath()+"/static/main.wasm") + http.ServeFile(w, r, common.RunPath()+"/static/main.wasm") } func wsImages(w http.ResponseWriter, r *http.Request) { base := filepath.Base(r.URL.Path) common.LogDebugln("[img] ", base) - http.ServeFile(w, r, runPath()+"/static/img/"+base) + http.ServeFile(w, r, common.RunPath()+"/static/img/"+base) } func wsEmotes(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, path.Join(runPath()+"/static/", r.URL.Path)) + http.ServeFile(w, r, path.Join(common.RunPath()+"/static/", r.URL.Path)) } // Handling the websocket diff --git a/settings.go b/settings.go index 4b2408d..d560a33 100644 --- a/settings.go +++ b/settings.go @@ -85,7 +85,7 @@ func LoadSettings(filename string) (*Settings, error) { } s.filename = filename - var logFileDir string = runPath() + "/" + s.LogFile + var logFileDir string = common.RunPath() + "/" + s.LogFile fmt.Printf("Log file: %s\n", logFileDir) if err = common.SetupLogging(s.LogLevel, logFileDir); err != nil { return nil, fmt.Errorf("Unable to setup logger: %s", err) From e7526d3495162485bdb95e2286aab9eae5182ee1 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 17:55:26 +0200 Subject: [PATCH 094/101] Changed EOL into readme.md --- readme.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/readme.md b/readme.md index 7ff3790..23ee93d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,9 @@ <!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> **Table of Contents** +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md - [MovieNight stream server](#movienight-stream-server) - [Build requirements](#build-requirements) - [Older Go Versions](#older-go-versions) @@ -16,7 +19,10 @@ <!-- markdown-toc end --> # MovieNight stream server +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md [![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) This is a single-instance streaming server with chat. Originally written to @@ -24,12 +30,18 @@ replace Rabbit as the platform for watching movies with a group of people online. ## Build requirements +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md - Go 1.13 or newer - GNU Make ### Older Go Versions +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md You can install a newer version of Go alongside your OS's distribution by following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) @@ -45,7 +57,11 @@ You have to : - build **make TARGET=windows ARCH=386**; - and run **./MovieNight**; +<<<<<<< HEAD Example : +======= +Example : +>>>>>>> Changed EOL into readme.md ```bash $ git clone https://github.com/zorchenhimer/MovieNight $ cd MovieNight @@ -94,7 +110,10 @@ The container needs to be restarted to apply any changes you make to *settings.j An script wich setup an Jail and build and run MovieNight into that Jail as been writen, you'll find it here [freenas-iocage-movienight] (https://github.com/zorglube/freenas-iocage-movienight) ## Usage +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md Now you can use OBS to push a stream to the server. Set the stream URL to ```text @@ -139,7 +158,10 @@ Usage of .\MovieNight.exe: ``` ## Configuration +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md MovieNight’s configuration is controlled by `settings.json`: - `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves @@ -179,5 +201,8 @@ MovieNight’s configuration is controlled by `settings.json`: header, to prevent caching responses. ## License +<<<<<<< HEAD +======= +>>>>>>> Changed EOL into readme.md `flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. From 240c278b413614e1cc29bd5afa3eb9ddb0ccdde4 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 18:03:45 +0200 Subject: [PATCH 095/101] Create MakeFile.BSD --- Makefile | 11 ++++------- Makefile.BSD | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 Makefile.BSD diff --git a/Makefile b/Makefile index 1ec3402..e7fa083 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,12 @@ # For info on installing extra versions, see this page: # https://golang.org/doc/install#extra_versions -# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" -# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" - TAGS= # Windows needs the .exe extension. -#.if ${TARGET} == "windows" -#EXT=.exe -#.endif +ifeq ($(OS),Windows_NT) +EXT=.exe +endif .PHONY: fmt vet get clean dev setdev test ServerMovieNight @@ -24,7 +21,7 @@ server: ServerMovieNight static/main.wasm # Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") diff --git a/Makefile.BSD b/Makefile.BSD new file mode 100644 index 0000000..17f72d3 --- /dev/null +++ b/Makefile.BSD @@ -0,0 +1,54 @@ +# If a different version of Go is installed (via `go get`) set the GO_VERSION +# environment variable to that version. For example, setting it to "1.13.7" +# will run `go1.13.7 build [...]` instead of `go build [...]`. +# +# For info on installing extra versions, see this page: +# https://golang.org/doc/install#extra_versions + +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" + +TAGS= + +.PHONY: fmt vet get clean dev setdev test ServerMovieNight + +all: fmt vet test MovieNight static/main.wasm settings.json + +# Build the server deployment +server: ServerMovieNight static/main.wasm + +# Bulid used for deploying to my server. +ServerMovieNight: *.go common/*.go + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) + +setdev: + $(eval export TAGS=-tags "dev") + +dev: setdev all + +MovieNight: *.go common/*.go + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) + +static/js/wasm_exec.js: + cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ + +static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go + GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go + +clean: + -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js + +fmt: + gofmt -w . + +vet: + go$(GO_VERSION) vet $(TAGS) ./... + GOOS=js GOARCH=wasm go$(GO_VERSION) vet $(TAGS) ./... + +test: + go$(GO_VERSION) test $(TAGS) ./... + +# Do not put settings_example.json here as a prereq to avoid overwriting +# the settings if the example is updated. +settings.json: + cp settings_example.json settings.json From 5ac8c327604690eb8c298e55d340c68407b73a92 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 11 Sep 2020 14:08:54 +0200 Subject: [PATCH 096/101] Typo --- Makefile.BSD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.BSD b/Makefile.BSD index 17f72d3..6856566 100644 --- a/Makefile.BSD +++ b/Makefile.BSD @@ -17,7 +17,7 @@ all: fmt vet test MovieNight static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm -# Bulid used for deploying to my server. +# Build used for deploying to my server. ServerMovieNight: *.go common/*.go GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) From 208608e734900a706db52ad5df7c497dd98f8e95 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 11 Sep 2020 14:09:48 +0200 Subject: [PATCH 097/101] Typo + cross-compile arch --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e7fa083..3525e5a 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,9 @@ all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json # Build the server deployment server: ServerMovieNight static/main.wasm -# Bulid used for deploying to my server. +# Build used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") @@ -29,7 +29,7 @@ setdev: dev: setdev all MovieNight$(EXT): *.go common/*.go - go$(GO_VERSION) build -o $@ $(TAGS) + GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) static/js/wasm_exec.js: cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ From 5dc834ba862c7ff40ff4f6fa561326ad23b99129 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Fri, 11 Sep 2020 14:10:57 +0200 Subject: [PATCH 098/101] Libs update --- go.mod | 9 +++++---- go.sum | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 80a73c0..1352df3 100644 --- a/go.mod +++ b/go.mod @@ -7,13 +7,14 @@ require ( github.com/cenkalti/backoff v2.1.1+incompatible // indirect github.com/chromedp/cdproto v0.0.0-20190412020601-c4267f5c421a // indirect github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 // indirect - github.com/gorilla/sessions v1.1.3 - github.com/gorilla/websocket v1.4.0 + github.com/gorilla/context v1.1.1 // indirect + github.com/gorilla/sessions v1.2.1 + github.com/gorilla/websocket v1.4.2 github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 // indirect - github.com/nareix/joy4 v0.0.0-20181022032202-3ddbc8f9d431 + github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 github.com/ory/dockertest v3.3.4+incompatible // indirect - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.4.1 // indirect github.com/stretchr/objx v0.2.0 // indirect golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a // indirect diff --git a/go.sum b/go.sum index 6ddf141..81086ed 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,12 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.1.3 h1:uXoZdcdA5XdXF3QzuSlheVRUvjl+1rKY7zBXL68L9RU= github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= +github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= +github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls= @@ -54,6 +58,8 @@ github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/nareix/joy4 v0.0.0-20181022032202-3ddbc8f9d431 h1:nWhrOsCKdV6bivw03k7MROF2tYzCFGfYBYFrTEHyucs= github.com/nareix/joy4 v0.0.0-20181022032202-3ddbc8f9d431/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I= +github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 h1:Yp0zFEufLz0H7jzffb4UPXijavlyqlYeOg7dcyVUNnQ= +github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I= github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= @@ -67,6 +73,8 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= From 2a83dbc0690df6263b273759fc0b43b20b4967f4 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Mon, 14 Sep 2020 10:33:05 +0200 Subject: [PATCH 099/101] Crossplatform make Work in progress 50% --- Makefile | 75 +++++++++++++------------------------------- Makefile.BSD | 66 +++++++------------------------------- make/Makefile.common | 42 +++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 108 deletions(-) create mode 100644 make/Makefile.common diff --git a/Makefile b/Makefile index 3525e5a..82fb9db 100644 --- a/Makefile +++ b/Makefile @@ -1,56 +1,23 @@ -# If a different version of Go is installed (via `go get`) set the GO_VERSION -# environment variable to that version. For example, setting it to "1.13.7" -# will run `go1.13.7 build [...]` instead of `go build [...]`. -# -# For info on installing extra versions, see this page: -# https://golang.org/doc/install#extra_versions - -TAGS= +# If a different version of Go is installed (via `go get`) set the GO_VERSION +# environment variable to that version. For example, setting it to "1.13.7" +# will run `go1.13.7 build [...]` instead of `go build [...]`. +# +# For info on installing extra versions, see this page: +# https://golang.org/doc/install#extra_versions + +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" +include make/Makefile.common # Windows needs the .exe extension. -ifeq ($(OS),Windows_NT) -EXT=.exe -endif - -.PHONY: fmt vet get clean dev setdev test ServerMovieNight - -all: fmt vet test MovieNight$(EXT) static/main.wasm settings.json - -# Build the server deployment -server: ServerMovieNight static/main.wasm - -# Build used for deploying to my server. -ServerMovieNight: *.go common/*.go - GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) - -setdev: - $(eval export TAGS=-tags "dev") - -dev: setdev all - -MovieNight$(EXT): *.go common/*.go - GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) - -static/js/wasm_exec.js: - cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ - -static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go - GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go - -clean: - -rm MovieNight$(EXT) ./static/main.wasm ./static/js/wasm_exec.js - -fmt: - gofmt -w . - -vet: - go$(GO_VERSION) vet $(TAGS) ./... - GOOS=js GOARCH=wasm go$(GO_VERSION) vet $(TAGS) ./... - -test: - go$(GO_VERSION) test $(TAGS) ./... - -# Do not put settings_example.json here as a prereq to avoid overwriting -# the settings if the example is updated. -settings.json: - cp settings_example.json settings.json +ifeq ($(OS),Windows_NT) +EXT=.exe +endif + +ifeq ($(GOOS),) +GOOS=windows +endif +l +ifeq ($(ARCH),) +ARCH=386 +endif diff --git a/Makefile.BSD b/Makefile.BSD index 6856566..f49a3f2 100644 --- a/Makefile.BSD +++ b/Makefile.BSD @@ -1,54 +1,12 @@ -# If a different version of Go is installed (via `go get`) set the GO_VERSION -# environment variable to that version. For example, setting it to "1.13.7" -# will run `go1.13.7 build [...]` instead of `go build [...]`. -# -# For info on installing extra versions, see this page: -# https://golang.org/doc/install#extra_versions - -# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" -# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" - -TAGS= - -.PHONY: fmt vet get clean dev setdev test ServerMovieNight - -all: fmt vet test MovieNight static/main.wasm settings.json - -# Build the server deployment -server: ServerMovieNight static/main.wasm - -# Build used for deploying to my server. -ServerMovieNight: *.go common/*.go - GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) - -setdev: - $(eval export TAGS=-tags "dev") - -dev: setdev all - -MovieNight: *.go common/*.go - GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) - -static/js/wasm_exec.js: - cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ - -static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go - GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go - -clean: - -rm MovieNight ./static/main.wasm ./static/js/wasm_exec.js - -fmt: - gofmt -w . - -vet: - go$(GO_VERSION) vet $(TAGS) ./... - GOOS=js GOARCH=wasm go$(GO_VERSION) vet $(TAGS) ./... - -test: - go$(GO_VERSION) test $(TAGS) ./... - -# Do not put settings_example.json here as a prereq to avoid overwriting -# the settings if the example is updated. -settings.json: - cp settings_example.json settings.json +# If a different version of Go is installed (via `go get`) set the GO_VERSION +# environment variable to that version. For example, setting it to "1.13.7" +# will run `go1.13.7 build [...]` instead of `go build [...]`. +# +# For info on installing extra versions, see this page: +# https://golang.org/doc/install#extra_versions + +# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" +# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" +include make/Makefile.common + +GOOS=freebsd diff --git a/make/Makefile.common b/make/Makefile.common new file mode 100644 index 0000000..fcaa12e --- /dev/null +++ b/make/Makefile.common @@ -0,0 +1,42 @@ +TAGS= + +.PHONY: fmt vet get clean dev setdev test ServerMovieNight + +all: fmt vet test MovieNight static/main.wasm settings.json + +server: ServerMovieNight static/main.wasm + +ServerMovieNight: *.go common/*.go + GOOS=${GOOS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) + +setdev: + $(eval export TAGS=-tags "dev") + +dev: setdev all + +MovieNight: *.go common/*.go + GOOS=${GOOS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight${EXT} $(TAGS) + +static/js/wasm_exec.js: + $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ + +static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go + GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go + +clean: + -rm MovieNight${EXT} ./static/main.wasm ./static/js/wasm_exec.js + +fmt: + gofmt -w . + +vet: + go$(GO_VERSION) vet $(TAGS) ./... + GOOS=js GOARCH=wasm go$(GO_VERSION) vet $(TAGS) ./... + +test: + go$(GO_VERSION) test $(TAGS) ./... + +# Do not put settings_example.json here as a prereq to avoid overwriting +# the settings if the example is updated. +settings.json: + cp settings_example.json settings.json From f7cf1c39aaa6beea0d980e4de4af985180cc4d3f Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Mon, 19 Oct 2020 21:38:21 +0200 Subject: [PATCH 100/101] MakeFile: typo --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 82fb9db..6dd81f3 100644 --- a/Makefile +++ b/Makefile @@ -7,17 +7,17 @@ # goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows" # goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64" -include make/Makefile.common - -# Windows needs the .exe extension. -ifeq ($(OS),Windows_NT) -EXT=.exe +include make/Makefile.common + +# Windows needs the .exe extension. +ifeq ($(OS),Windows_NT) +EXT=.exe endif ifeq ($(GOOS),) GOOS=windows endif -l + ifeq ($(ARCH),) ARCH=386 endif From 1067780a77d8f01b47ab73a365813ec6bf81dc8e Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Tue, 20 Oct 2020 00:39:56 +0200 Subject: [PATCH 101/101] Makefile.common: fix stupid mistake --- make/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/Makefile.common b/make/Makefile.common index fcaa12e..cef3133 100644 --- a/make/Makefile.common +++ b/make/Makefile.common @@ -18,7 +18,7 @@ MovieNight: *.go common/*.go GOOS=${GOOS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight${EXT} $(TAGS) static/js/wasm_exec.js: - $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ + cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ static/main.wasm: static/js/wasm_exec.js wasm/*.go common/*.go GOOS=js GOARCH=wasm go$(GO_VERSION) build -o $@ $(TAGS) wasm/*.go