From 745bb322a3210b72a91baa584f4a9cacb3e4f5e1 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau Date: Tue, 18 Aug 2020 17:18:45 +0200 Subject: [PATCH 001/207] 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/207] 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/207] 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/207] 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/207] 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/207] "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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] "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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] "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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] "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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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/207] 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 From 2e32db2794bec49436141f6addbe507a04244513 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 102/207] 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 dd6f540df28d9b40cf1ebe9bd1fa201b863355f6 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 103/207] 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 35e279dac470652c426b9b459bc948bfd55c55c6 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 104/207] 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 15655dc4103ae6c2f4a0cf714a8fadd32f3fb0c8 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 105/207] 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 ad0dce9f72cdba54028bdd0aca414b280ae114ff 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 106/207] 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 302aaf04bc4ec00390741a0f9382729681519f6c 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 107/207] "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 0027301646e91212b21d81fc07ad557bb34d9ca8 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 108/207] 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 27f9e494e5c94b2ba662a062839c8cd7bb9decc1 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 109/207] 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 becc5679d55076bf1fe6ad28e768a2d0d13ae271 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 110/207] 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 d9fa3e7c5342e95c03e20fca92d3399e7e29a720 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 111/207] 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 6818ada1ab56652afc427cfd4db511c04bfa8b98 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 112/207] 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 8d4c5d4bc841d8b3080d00e5bbacf4727f5bfce4 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 113/207] 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 6185e89ddc98e4f4867e3f2dc360f68c989f4c52 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 114/207] 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 a169be1a0ffb8c56f86762e871b438bd5eb8944b 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 115/207] 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 0a5631fe0237da87394c1bdf9928ef22d194bb8a 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 116/207] 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 74b8bb749e8d09d1ec64267b849300a70c796302 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 117/207] 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 15a2d47adb213b97d11aac8a539d3b256d88704a 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 118/207] 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 e4333a2cc7d6308439d231d3ee5dca780d8568e7 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 119/207] 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 0fc9c94c3d6ae6c4291203420a325aec6d217e94 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 120/207] "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 e31b7729d875b81b04e20c0428e2d22575974e69 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 121/207] 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 e6023c909e54b93d41bb738e4f8694a3a413136d 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 122/207] 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 6a6a469716e2ed79b1010d5d2ef3624d42f7ed5d 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 123/207] 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 8d31ce726fabc919fa7670dbb3af74bf4c2d8f9d 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 124/207] 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 1a36be32df64a5b66d93d1b60d0315a3d339d060 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 125/207] 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 53be0161719a263aae0093508f50943ef6c0a27a 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 126/207] 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 597bfed0a20ca9addfe9cd31ffda18f574693bd6 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 127/207] 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 de990d2298dd146c73f56ce331c105c5618a3462 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 128/207] 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 bbb0423b7ac45573e52a380c55ca37baa7c577c3 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 129/207] 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 0b7598c2cac5645c6638da5feea9706b4f9f09d2 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 130/207] 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 614e8111bea0d91926870ac3bc8c429fe86dbc27 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 131/207] 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 12e47f9b668ce5da6aadd50805efb6d69c1006a9 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 132/207] 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 dc1413ba6ba58a8c118d28c71f41eb0d1a82c684 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 133/207] 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 9671f778263271e9e6ad951258c21aa277324f2f 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 134/207] 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 9d16f2407e8e789de00cd37cb4fca17a62a502a0 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 135/207] 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 462363c6f67f63945210fb9dfd82689055c2b51e Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Thu, 20 Aug 2020 19:06:34 +0200 Subject: [PATCH 136/207] 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 b71db84b69195fcd2db9968989ac2265feb121b5 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 137/207] 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 fbc8055e0c0157f5fcf01491550d572109134fe1 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 138/207] 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 a027951d1e8eac313ed5f115bee203b7d5a75419 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 139/207] 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 9e9e075e0fec1691b6031b4ee1ab89767fa60710 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 140/207] 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 5fe3036e03b85620905152e00066f18bcca7a90c 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 141/207] 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 99f48694ac5dbadfe5ec79b06c7d74a37a40aa88 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 00:05:30 +0200 Subject: [PATCH 142/207] 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 d63b361d8eb185712d6f5863bed1f89847b89b25 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 13:12:40 +0200 Subject: [PATCH 143/207] 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 7c33ba91d16a387032f009b3a0088295a35e5caa Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 17:54:01 +0200 Subject: [PATCH 144/207] 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 6fd61f822f7283f403607cc439ff2c58ad35de43 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 17:55:26 +0200 Subject: [PATCH 145/207] 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 e56d7d6fe119b3140c806c275b21c5f46345c214 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 18:03:45 +0200 Subject: [PATCH 146/207] 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 5c59f1a075cd21b2ede2cd3a09905ba4c1676545 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 147/207] 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 09062dcbb39018dddc4bd6efdde311cfebeaa7dc 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 148/207] 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 81cf970d689641e8a6fd051dae1abf363b9a1371 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 149/207] 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 c1c793988f72be2ed555c781c792457cad0fffa0 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 150/207] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- Makefile | 11 +++++++---- readme.md | 27 +-------------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 3525e5a..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 @@ -19,9 +22,9 @@ 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. +# Bulid used for deploying to my server. ServerMovieNight: *.go common/*.go - GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") @@ -29,7 +32,7 @@ setdev: dev: setdev all MovieNight$(EXT): *.go common/*.go - GOOS=${OS} GOARCH=${ARCH} go$(GO_VERSION) build -o $@ $(TAGS) + go$(GO_VERSION) build -o $@ $(TAGS) static/js/wasm_exec.js: cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ diff --git a/readme.md b/readme.md index 23ee93d..9972ab9 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,6 @@ <!-- 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) @@ -19,10 +16,7 @@ <!-- 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 @@ -30,18 +24,11 @@ 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) @@ -57,11 +44,7 @@ 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 @@ -107,13 +90,11 @@ This docker-compose file will create a volume called *movienight-config* and aut 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 -<<<<<<< HEAD -======= ->>>>>>> Changed EOL into readme.md Now you can use OBS to push a stream to the server. Set the stream URL to ```text @@ -158,10 +139,7 @@ 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 @@ -201,8 +179,5 @@ 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 5eaf2b130e8480c23f4d90e22a373c2e4599e45f 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 151/207] Multi-target build Try to customize the MakeFile in order to be able to build an binary for any target system. --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 9972ab9..6e336bc 100644 --- a/readme.md +++ b/readme.md @@ -29,6 +29,7 @@ online. - 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) From 9e28f9238f52639e45b7d61a9ef3f50768053c87 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 152/207] 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 7b9720af04d1bc2c2d390e2ebd575c1ffa3b866b 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 153/207] 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 7f61d31245eb9d663b60adb8cb661eac8b9ba199 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 154/207] 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 a7f99a885317354b0a4ad5d8fe29c9283846f6a9 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 155/207] "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 f15e8274ca12ac5e72000ed5577919bce446aa3b 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 156/207] 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 ab8498960645d4e4848cb2daa2e193645ba69855 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 157/207] 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 a17c0243a0790ea9eb3506371c305fd32d4199c9 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 158/207] 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 ea13725618d312848247379c005135c9ef43018e 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 159/207] 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 9a250738699f662dd38345ffd70cd0337e66ebcc 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 160/207] 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 4f0985f3c5d8c94588b282dadd04913ed6702442 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 161/207] 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 a9c02bf4efbb2238adfdf92c44d4b34773eedd05 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 162/207] 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 fccd8c59d5213aa9df70ff4d3cfcd054ba65408d 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 163/207] 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 f6e1f72eab17a6386971cc8325a3e5f43b6cd019 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 164/207] 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 0569ff41a1756ebfd9f390efe8c3987c589d1546 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 165/207] 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 081b34e6c19b45202264ce1604d2b74fe626d5bf 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 166/207] "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 072d5d351ba751dbba588100512b5f0f838b65ef 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 167/207] 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 4eb6f0c6c0d6902285cbf864736df870df5ab779 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 168/207] 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 1599fd90d2abaf5be5b4546a5e248d79b0b739b6 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 169/207] 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 8ce5687e018b9f3bf896164ad594d48bb8bef611 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 171/207] 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 e37a5271ce209c87c0cdc870e29a7510791c1838 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 172/207] 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 0e4b8db4c1def175cc0955e03af41b05e7bb5101 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 173/207] 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 aa666a1bbb9ea9ad21a32ff3181b537e4111ea06 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 174/207] 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 73d0731849401cb424b509f2416df638463bbc4c 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 175/207] 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 7ff584504c08d5f799128720ebf5fac78e58da34 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 176/207] 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 bdc4adc5a680b0894a9529072f25d316daf39fdb 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 177/207] 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 3b3ec278a6bc096ab1f5f7dc55c472260299a9c9 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 178/207] 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 a8d1019dc00ec35b833e40d8773e88b15f29d346 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 179/207] 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 304e4751e2d6e3fdf2cd8f9d251e0884b6df6cd7 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 180/207] Relative dir --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b598480..af3923f 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,6 +22,7 @@ var ( stats = newStreamStats() sAdminPass string confFile string + path string ) func setupSettings() error { @@ -50,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") From 8c7a303e14c81b3946f90f95fa6952203c093630 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 181/207] absolut dir --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index af3923f..043a43c 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 b3dc13affbb5a6f9e2ac30a3beae6b0a98b8c395 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Thu, 20 Aug 2020 19:06:34 +0200 Subject: [PATCH 182/207] Relative running --- main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 043a43c..95c470a 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") From 516b9a212ba7a9fdbbd136ce604ad93ee243bbb8 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 183/207] Run from anywhere Get the runpath at runtime, in order to run MovieNight from whatever position into the filesystem. --- main.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/main.go b/main.go index 95c470a..b598480 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") From 87d2d201ec89581813814ddae7501d836d6551a5 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 184/207] 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 4e9741fa6e2419112bfae225503e12bd0c93df47 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 13:12:40 +0200 Subject: [PATCH 185/207] Add DSB into builds --- readme.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/readme.md b/readme.md index 6e336bc..007f10d 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) @@ -16,7 +15,6 @@ <!-- 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 @@ -24,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) @@ -91,11 +87,9 @@ This docker-compose file will create a volume called *movienight-config* and aut 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 @@ -140,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 @@ -180,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 223fabf53a891483e0bba50f7372bc675eb25171 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sun, 23 Aug 2020 18:03:45 +0200 Subject: [PATCH 186/207] Create MakeFile.BSD --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 . From be67c273556b98cd2c11dd58a051da02e2aeec36 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 187/207] 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 ebb0d7bdc2a026e92a8efc75cc2ae5fdcb2a2337 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 188/207] 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 3a61dc6948a20fccd2738f2f45e93f129bdd468e Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Mon, 19 Oct 2020 21:38:21 +0200 Subject: [PATCH 189/207] 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 0ecc1996217dcf76a76a8ddd5a85f54945055455 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Tue, 20 Oct 2020 00:39:56 +0200 Subject: [PATCH 190/207] 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 From 6b7e6cd0835c9b014af3d6ad3bc923cccc0537d2 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Tue, 20 Oct 2020 20:57:05 +0200 Subject: [PATCH 191/207] Fixed the Emotes feature --- common/utils.go | 14 ++++++++++++++ emotes.go | 39 ++++++++++++++++++++++++++++----------- handlers.go | 1 + 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/common/utils.go b/common/utils.go index 18e68d7..f84900c 100644 --- a/common/utils.go +++ b/common/utils.go @@ -27,3 +27,17 @@ func RunPath() string { } return filepath.Dir(ex) } + +func Substr(input string, start int, length int) string { + asRunes := []rune(input) + + if start >= len(asRunes) { + return "" + } + + if start+length > len(asRunes) { + length = len(asRunes) - start + } + + return string(asRunes[start : start+length]) +} diff --git a/emotes.go b/emotes.go index 6feeee4..8f681ba 100644 --- a/emotes.go +++ b/emotes.go @@ -70,7 +70,7 @@ func processEmoteDir(path string) (common.EmotesMap, error) { } for _, d := range subd { if d.IsDir() { - //emotes = append(emotes, findEmotes(filepath.Join(path, dir, d.Name()))...) + // emotes = append(emotes, findEmotes(filepath.Join(path, dir, d.Name()))...) p := filepath.Join(path, dir, d.Name()) em, err = findEmotes(p, em) if err != nil { @@ -80,33 +80,50 @@ func processEmoteDir(path string) (common.EmotesMap, error) { } } - fmt.Printf("processEmoteDir: %d\n", len(em)) + common.LogInfof("processEmoteDir: %d\n", len(em)) return em, nil } -func findEmotes(dir string, em common.EmotesMap) (common.EmotesMap, error) { - //em := NewEmotesMap() +func substr(input string, start int, length int) string { + asRunes := []rune(input) - //fmt.Printf("finding emotes in %q\n", dir) + if start >= len(asRunes) { + return "" + } + + if start+length > len(asRunes) { + length = len(asRunes) - start + } + + return string(asRunes[start : start+length]) +} + +func findEmotes(dir string, em common.EmotesMap) (common.EmotesMap, error) { + var runPathLength = len(common.RunPath() + "/static/") + + common.LogDebugf("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) } - fmt.Printf("%d emotePNGs\n", len(emotePNGs)) + common.LogInfof("Found %d emotePNGs\n", len(emotePNGs)) emoteGIFs, err := filepath.Glob(filepath.Join(dir, "*.gif")) if err != nil { return em, errors.Wrap(err, "unable to glob emote directory:") } - fmt.Printf("%d emoteGIFs\n", len(emoteGIFs)) + common.LogInfof("Found %d emoteGIFs\n", len(emoteGIFs)) for _, file := range emotePNGs { - em = em.Add(file) - //emotes = append(emotes, common.Emote{FullPath: dir, Code: file}) + png := strings.ReplaceAll(common.Substr(file, runPathLength, len(file)), "\\", "/") + //common.LogDebugf("Emote PNG: %s", png) + em = em.Add(png) } for _, file := range emoteGIFs { - em = em.Add(file) + gif := strings.ReplaceAll(common.Substr(file, runPathLength, len(file)), "\\", "/") + //common.LogDebugf("Emote GIF: %s", gif) + em = em.Add(gif) } return em, nil @@ -122,7 +139,7 @@ func getEmotes(names []string) error { return errors.Wrapf(err, "could not get emote data for \"%s\"", user.ID) } - emoteUserDir := filepath.Join(emoteDir, "twitch", user.Login) + emoteUserDir := filepath.Join(common.RunPath()+emoteDir, "twitch", user.Login) if _, err := os.Stat(emoteUserDir); os.IsNotExist(err) { os.MkdirAll(emoteUserDir, os.ModePerm) } diff --git a/handlers.go b/handlers.go index 4815401..0a2a3a2 100644 --- a/handlers.go +++ b/handlers.go @@ -283,6 +283,7 @@ func handleEmoteTemplate(w http.ResponseWriter, r *http.Request) { Emotes: common.Emotes, } + common.LogDebugf("Emotes Data: %s", data) err := common.ExecuteServerTemplate(w, "emotes", data) if err != nil { common.LogErrorf("Error executing file, %v", err) From 73496282932163beaf8319c08e3d782dacc7a7d9 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Sat, 24 Oct 2020 01:08:57 +0200 Subject: [PATCH 192/207] setting.go: - Leave the position of the log file free --- settings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.go b/settings.go index d560a33..34e6388 100644 --- a/settings.go +++ b/settings.go @@ -85,7 +85,7 @@ func LoadSettings(filename string) (*Settings, error) { } s.filename = filename - var logFileDir string = common.RunPath() + "/" + s.LogFile + var logFileDir string = 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 2d1cd12fc08d42193aec5261d2a71f4896ad5b53 Mon Sep 17 00:00:00 2001 From: Bertrand Moreau <bertrand.moreau-prestataire@ca-cib.com> Date: Mon, 26 Oct 2020 14:27:14 +0100 Subject: [PATCH 193/207] Chat template --- common/chatdata.go | 106 +++++++++++++++++++++++++++------------------ go.mod | 14 ------ go.sum | 99 ------------------------------------------ 3 files changed, 65 insertions(+), 154 deletions(-) diff --git a/common/chatdata.go b/common/chatdata.go index 1fd77c7..bc7a191 100644 --- a/common/chatdata.go +++ b/common/chatdata.go @@ -1,10 +1,12 @@ package common import ( + "bytes" "encoding/json" "errors" "fmt" "strings" + "text/template" ) type DataInterface interface { @@ -89,38 +91,51 @@ type DataMessage struct { Type MessageType } +var ( + cmdme = template.Must(template.New("cmdme").Parse(`<span style="color:{{.Color}}"><span class="name">{{.From}}</span> <span class="cmdme">{{.Message}}</span></span>`)) + announcement = template.Must(template.New("announcement").Parse(`<span class="announcement">{{.Message}}</span>`)) + errormsg = template.Must(template.New("error").Parse(`<span class="error">{{.Message}}</span>`)) + notice = template.Must(template.New("notice").Parse(`<span class="notice">{{.Message}}</span>`)) + command = template.Must(template.New("command").Parse(`<span class="command">{{.Message}}</span>`)) + commanderror = template.Must(template.New("commanderror").Parse(`<span class="commanderror">{{.Message}}</span>`)) + cmdlMod = template.Must(template.New("cmdlMod").Parse(`<span><img src="/static/img/mod.png" class="badge" /><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) + cmdlAdmin = template.Must(template.New("CmdlAdmin").Parse(`<span><img src="/static/img/admin.png" class="badge" /><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) + defaultMsg = template.Must(template.New("defaultMsg").Parse(`<span><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) +) + // TODO: Read this HTML from a template somewhere func (dc DataMessage) HTML() string { + buf := &bytes.Buffer{} switch dc.Type { case MsgAction: - return `<span style="color:` + dc.Color + `"><span class="name">` + dc.From + - `</span> <span class="cmdme">` + dc.Message + `</span></span>` - + cmdme.Execute(buf, dc) + return buf.String() case MsgServer: - return `<span class="announcement">` + dc.Message + `</span>` - + announcement.Execute(buf, dc) + return buf.String() case MsgError: - return `<span class="error">` + dc.Message + `</span>` - + errormsg.Execute(buf, dc) + return buf.String() case MsgNotice: - return `<span class="notice">` + dc.Message + `</span>` - + notice.Execute(buf, dc) + return buf.String() case MsgCommandResponse: - return `<span class="command">` + dc.Message + `</span>` - + command.Execute(buf, dc) + return buf.String() case MsgCommandError: - return `<span class="commanderror">` + dc.Message + `</span>` + commanderror.Execute(buf, dc) + return buf.String() default: - badge := "" switch dc.Level { case CmdlMod: - badge = `<img src="/static/img/mod.png" class="badge" />` + cmdlMod.Execute(buf, dc) case CmdlAdmin: - badge = `<img src="/static/img/admin.png" class="badge" />` + cmdlAdmin.Execute(buf, dc) + default: + defaultMsg.Execute(buf, dc) } - return `<span>` + badge + `<span class="name" style="color:` + dc.Color + `">` + dc.From + - `</span><b>:</b> <span class="msg">` + dc.Message + `</span></span>` + return buf.String() } } @@ -165,42 +180,51 @@ type DataEvent struct { Event EventType User string Color string + Users []string } +var ( + evKick = template.Must(template.New("evKick").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has been kicked.</span>`)) + evLeave = template.Must(template.New("evLeave").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has left the chat.</span>`)) + evBan = template.Must(template.New("evBan").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has been banned.</span>`)) + evJoin = template.Must(template.New("evJoin").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has joined the chat.</span>`)) + evNameChangeWC = template.Must(template.New("evNameChangeWC").Parse(`<span class="event">Somebody changed their name, but IDK who {{.}}.</span>`)) + evNameChange = template.Must(template.New("evNameChange").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{index .Users 0}}</span> has changed their name to <span class="name" style="color:{{.Color}}">{{index .Users 1}}</span>.</span>`)) + evNameChangeForced = template.Must(template.New("evNameChangeForced").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{index .Users 0}}</span> has had their name changed to <span class="name" style="color:{{.Color}}">{{index .Users 1}}</span> by an admin.</span>`)) + evNameChangeForcedWC = template.Must(template.New("evNameChangeForcedWC").Parse(`<span class="event">An admin changed somebody's name, but IDK who {{.}}.</span>`)) +) + func (de DataEvent) HTML() string { + buf := &bytes.Buffer{} switch de.Event { case EvKick: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has been kicked.</span>` + evKick.Execute(buf, de) + return buf.String() case EvLeave: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has left the chat.</span>` + evLeave.Execute(buf, de) + return buf.String() case EvBan: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has been banned.</span>` + evBan.Execute(buf, de) + return buf.String() case EvJoin: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has joined the chat.</span>` + evJoin.Execute(buf, de) + return buf.String() case EvNameChange: - names := strings.Split(de.User, ":") - if len(names) != 2 { - return `<span class="event">Somebody changed their name, but IDK who ` + - ParseEmotes("Jebaited") + `.</span>` + de.Users = strings.Split(de.User, ":") + if len(de.Users) < 2 { + evNameChangeWC.Execute(buf, ParseEmotes("Jebaited")) + } else { + evNameChange.Execute(buf, de) } - - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - names[0] + `</span> has changed their name to <span class="name" style="color:` + - de.Color + `">` + names[1] + `</span>.</span>` + return buf.String() case EvNameChangeForced: - names := strings.Split(de.User, ":") - if len(names) != 2 { - return `<span class="event">An admin changed somebody's name, but IDK who ` + - ParseEmotes("Jebaited") + `.</span>` + de.Users = strings.Split(de.User, ":") + if len(de.Users) < 2 { + evNameChangeForcedWC.Execute(buf, ParseEmotes("Jebaited")) + } else { + evNameChangeForced.Execute(buf, de) } - - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - names[0] + `</span> has had their name changed to <span class="name" style="color:` + - de.Color + `">` + names[1] + `</span> by an admin.</span>` + return buf.String() } return "" } diff --git a/go.mod b/go.mod index 1352df3..eab47af 100644 --- a/go.mod +++ b/go.mod @@ -3,22 +3,8 @@ module github.com/zorchenhimer/MovieNight go 1.12 require ( - github.com/Microsoft/go-winio v0.4.12 // indirect - 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/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-20200507095837-05a4ffbb5369 - github.com/ory/dockertest v3.3.4+incompatible // indirect 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 - golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f // indirect - golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect - golang.org/x/sys v0.0.0-20190412213103-97732733099d // indirect ) diff --git a/go.sum b/go.sum index 81086ed..d31e651 100644 --- a/go.sum +++ b/go.sum @@ -1,109 +1,10 @@ -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Microsoft/go-winio v0.4.11 h1:zoIOcVf0xPN1tnMVbTtEdI+P8OofVk3NObnwOQ6nK2Q= -github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.12/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= -github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/cenkalti/backoff v2.0.0+incompatible h1:5IIPUHhlnUZbcHQsQou5k1Tn58nJkeJL9U+ig5CHJbY= -github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/chromedp/cdproto v0.0.0-20190217000753-2d8e8962ceb2 h1:4Ck8YOuS0G3+0xMb80cDSff7QpUolhSc0PGyfagbcdA= -github.com/chromedp/cdproto v0.0.0-20190217000753-2d8e8962ceb2/go.mod h1:xquOK9dIGFlLaIGI4c6IyfLI/Gz0LiYYuJtzhsUODgI= -github.com/chromedp/cdproto v0.0.0-20190412020601-c4267f5c421a/go.mod h1:xquOK9dIGFlLaIGI4c6IyfLI/Gz0LiYYuJtzhsUODgI= -github.com/chromedp/chromedp v0.1.3 h1:Nkqt42/7tvzg57mexc4LbM8nZbx7vSZ+eiUpeczGGL8= -github.com/chromedp/chromedp v0.1.3/go.mod h1:ZahQlJx8YBfDtuFN80zn6P7fskSotBkdhgKDoLWFANk= -github.com/containerd/continuity v0.0.0-20181027224239-bea7585dbfac h1:PThQaO4yCvJzJBUW1XoFQxLotWRhvX2fgljJX8yrhFI= -github.com/containerd/continuity v0.0.0-20181027224239-bea7585dbfac/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dennwc/dom v0.3.0 h1:u89+QvT1OPRSSTFf54o9RuK7C0Uoq2jFo4VCa4rnjtI= -github.com/dennwc/dom v0.3.0/go.mod h1:/z5w9Stx19m8RUwolsmsqTs9rDxKgJO5T9UEumilgk4= -github.com/dennwc/testproxy v1.0.1 h1:mQhNVWHPolTYjJrDZYKcugIplWRSlFAis6k/Zf1s0c0= -github.com/dennwc/testproxy v1.0.1/go.mod h1:EHGV9tzWhMPLmEoVJ2KGyC149XqwKZwBDViCjhKD5d8= -github.com/disintegration/imaging v1.6.0 h1:nVPXRUUQ36Z7MNf0O77UzgnOb1mkMMor7lmJMJXc/mA= -github.com/disintegration/imaging v1.6.0/go.mod h1:xuIt+sRxDFrHS0drzXUlCJthkJ8k7lkkUojDSR247MQ= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= -github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= 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= -github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307/go.mod h1:BjPj+aVjl9FW/cCGiF3nGh5v+9Gd3VCgBQbod/GlMaQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= -github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f h1:B6PQkurxGG1rqEX96oE14gbj8bqvYC5dtks9r5uGmlE= -github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -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= -github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/ory/dockertest v3.3.2+incompatible h1:uO+NcwH6GuFof/Uz8yzjNi1g0sGT5SLAJbdBvD8bUYc= -github.com/ory/dockertest v3.3.2+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -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= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067 h1:KYGJGHOQy8oSi1fDlSpcZF0+juKwk/hEMv5SiwHogR0= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 h1:YoY1wS6JYVRpIfFngRf2HHo9R9dAne3xbkGOQ5rJXjU= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= From 8260e9c9df3038a63ba68c4cfac1a8aeca9f1ae1 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Mon, 2 Nov 2020 12:41:34 +0100 Subject: [PATCH 194/207] zorchenhimer PR comment --- readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 007f10d..7e9ab77 100644 --- a/readme.md +++ b/readme.md @@ -27,7 +27,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/install#extra_versions](https://golang.org/doc/install#extra_versions) +following the guide here: [https://golang.org/doc/manage-install](https://golang.org/doc/manage-install) 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 @@ -35,11 +35,11 @@ the newer version. ### Compile and install You have to : -- download **git clone https://github.com/zorchenhimer/MovieNight**, go into the source directory **cd MovieNight**; +- 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**; +- build `make TARGET=windows ARCH=386`; +- and run `./MovieNight`; Example : ```bash @@ -87,7 +87,7 @@ This docker-compose file will create a volume called *movienight-config* and aut 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) +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 a0b3e856c25e91174bf7eb0b9259d020431506c2 Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Mon, 2 Nov 2020 12:45:15 +0100 Subject: [PATCH 195/207] revert common/chatdata.go --- common/chatdata.go | 106 ++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 65 deletions(-) diff --git a/common/chatdata.go b/common/chatdata.go index bc7a191..1fd77c7 100644 --- a/common/chatdata.go +++ b/common/chatdata.go @@ -1,12 +1,10 @@ package common import ( - "bytes" "encoding/json" "errors" "fmt" "strings" - "text/template" ) type DataInterface interface { @@ -91,51 +89,38 @@ type DataMessage struct { Type MessageType } -var ( - cmdme = template.Must(template.New("cmdme").Parse(`<span style="color:{{.Color}}"><span class="name">{{.From}}</span> <span class="cmdme">{{.Message}}</span></span>`)) - announcement = template.Must(template.New("announcement").Parse(`<span class="announcement">{{.Message}}</span>`)) - errormsg = template.Must(template.New("error").Parse(`<span class="error">{{.Message}}</span>`)) - notice = template.Must(template.New("notice").Parse(`<span class="notice">{{.Message}}</span>`)) - command = template.Must(template.New("command").Parse(`<span class="command">{{.Message}}</span>`)) - commanderror = template.Must(template.New("commanderror").Parse(`<span class="commanderror">{{.Message}}</span>`)) - cmdlMod = template.Must(template.New("cmdlMod").Parse(`<span><img src="/static/img/mod.png" class="badge" /><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) - cmdlAdmin = template.Must(template.New("CmdlAdmin").Parse(`<span><img src="/static/img/admin.png" class="badge" /><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) - defaultMsg = template.Must(template.New("defaultMsg").Parse(`<span><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) -) - // TODO: Read this HTML from a template somewhere func (dc DataMessage) HTML() string { - buf := &bytes.Buffer{} switch dc.Type { case MsgAction: - cmdme.Execute(buf, dc) - return buf.String() + return `<span style="color:` + dc.Color + `"><span class="name">` + dc.From + + `</span> <span class="cmdme">` + dc.Message + `</span></span>` + case MsgServer: - announcement.Execute(buf, dc) - return buf.String() + return `<span class="announcement">` + dc.Message + `</span>` + case MsgError: - errormsg.Execute(buf, dc) - return buf.String() + return `<span class="error">` + dc.Message + `</span>` + case MsgNotice: - notice.Execute(buf, dc) - return buf.String() + return `<span class="notice">` + dc.Message + `</span>` + case MsgCommandResponse: - command.Execute(buf, dc) - return buf.String() + return `<span class="command">` + dc.Message + `</span>` + case MsgCommandError: - commanderror.Execute(buf, dc) - return buf.String() + return `<span class="commanderror">` + dc.Message + `</span>` default: + badge := "" switch dc.Level { case CmdlMod: - cmdlMod.Execute(buf, dc) + badge = `<img src="/static/img/mod.png" class="badge" />` case CmdlAdmin: - cmdlAdmin.Execute(buf, dc) - default: - defaultMsg.Execute(buf, dc) + badge = `<img src="/static/img/admin.png" class="badge" />` } - return buf.String() + return `<span>` + badge + `<span class="name" style="color:` + dc.Color + `">` + dc.From + + `</span><b>:</b> <span class="msg">` + dc.Message + `</span></span>` } } @@ -180,51 +165,42 @@ type DataEvent struct { Event EventType User string Color string - Users []string } -var ( - evKick = template.Must(template.New("evKick").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has been kicked.</span>`)) - evLeave = template.Must(template.New("evLeave").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has left the chat.</span>`)) - evBan = template.Must(template.New("evBan").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has been banned.</span>`)) - evJoin = template.Must(template.New("evJoin").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has joined the chat.</span>`)) - evNameChangeWC = template.Must(template.New("evNameChangeWC").Parse(`<span class="event">Somebody changed their name, but IDK who {{.}}.</span>`)) - evNameChange = template.Must(template.New("evNameChange").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{index .Users 0}}</span> has changed their name to <span class="name" style="color:{{.Color}}">{{index .Users 1}}</span>.</span>`)) - evNameChangeForced = template.Must(template.New("evNameChangeForced").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{index .Users 0}}</span> has had their name changed to <span class="name" style="color:{{.Color}}">{{index .Users 1}}</span> by an admin.</span>`)) - evNameChangeForcedWC = template.Must(template.New("evNameChangeForcedWC").Parse(`<span class="event">An admin changed somebody's name, but IDK who {{.}}.</span>`)) -) - func (de DataEvent) HTML() string { - buf := &bytes.Buffer{} switch de.Event { case EvKick: - evKick.Execute(buf, de) - return buf.String() + return `<span class="event"><span class="name" style="color:` + de.Color + `">` + + de.User + `</span> has been kicked.</span>` case EvLeave: - evLeave.Execute(buf, de) - return buf.String() + return `<span class="event"><span class="name" style="color:` + de.Color + `">` + + de.User + `</span> has left the chat.</span>` case EvBan: - evBan.Execute(buf, de) - return buf.String() + return `<span class="event"><span class="name" style="color:` + de.Color + `">` + + de.User + `</span> has been banned.</span>` case EvJoin: - evJoin.Execute(buf, de) - return buf.String() + return `<span class="event"><span class="name" style="color:` + de.Color + `">` + + de.User + `</span> has joined the chat.</span>` case EvNameChange: - de.Users = strings.Split(de.User, ":") - if len(de.Users) < 2 { - evNameChangeWC.Execute(buf, ParseEmotes("Jebaited")) - } else { - evNameChange.Execute(buf, de) + names := strings.Split(de.User, ":") + if len(names) != 2 { + return `<span class="event">Somebody changed their name, but IDK who ` + + ParseEmotes("Jebaited") + `.</span>` } - return buf.String() + + return `<span class="event"><span class="name" style="color:` + de.Color + `">` + + names[0] + `</span> has changed their name to <span class="name" style="color:` + + de.Color + `">` + names[1] + `</span>.</span>` case EvNameChangeForced: - de.Users = strings.Split(de.User, ":") - if len(de.Users) < 2 { - evNameChangeForcedWC.Execute(buf, ParseEmotes("Jebaited")) - } else { - evNameChangeForced.Execute(buf, de) + names := strings.Split(de.User, ":") + if len(names) != 2 { + return `<span class="event">An admin changed somebody's name, but IDK who ` + + ParseEmotes("Jebaited") + `.</span>` } - return buf.String() + + return `<span class="event"><span class="name" style="color:` + de.Color + `">` + + names[0] + `</span> has had their name changed to <span class="name" style="color:` + + de.Color + `">` + names[1] + `</span> by an admin.</span>` } return "" } From a840f80f9a950718677451d4d232918903c6f077 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Wed, 4 Nov 2020 22:59:01 -0500 Subject: [PATCH 196/207] Fix make recipe for wasm_exec.js file Add GO_VERSION to the command that copies the wasm_exec.js file so it will look in the correct folder when using an alternate version of Go. --- make/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/Makefile.common b/make/Makefile.common index cef3133..c939903 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: - cp $$(go env GOROOT)/misc/wasm/wasm_exec.js $@ + cp $$(go$(GO_VERSION) 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 From e26ae33758ce86c5fea5f45a38c4720359648f46 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Wed, 4 Nov 2020 23:20:15 -0500 Subject: [PATCH 197/207] Fix building on non-windows machines Don't default to windows if GOOS is not set. Likewise, don't default to 386 if GOARCH isn't set. Go will use the system's default values, or any values set before running `make`. --- Makefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Makefile b/Makefile index 6dd81f3..cf476cd 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,3 @@ include make/Makefile.common ifeq ($(OS),Windows_NT) EXT=.exe endif - -ifeq ($(GOOS),) -GOOS=windows -endif - -ifeq ($(ARCH),) -ARCH=386 -endif From 0fa99f7ab47a61dd1b8e2a8bd63615a2b4341d4f Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Wed, 11 Nov 2020 20:51:29 +0100 Subject: [PATCH 198/207] Templated the chat messages. --- common/chatdata.go | 106 +++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 41 deletions(-) diff --git a/common/chatdata.go b/common/chatdata.go index 1fd77c7..bc7a191 100644 --- a/common/chatdata.go +++ b/common/chatdata.go @@ -1,10 +1,12 @@ package common import ( + "bytes" "encoding/json" "errors" "fmt" "strings" + "text/template" ) type DataInterface interface { @@ -89,38 +91,51 @@ type DataMessage struct { Type MessageType } +var ( + cmdme = template.Must(template.New("cmdme").Parse(`<span style="color:{{.Color}}"><span class="name">{{.From}}</span> <span class="cmdme">{{.Message}}</span></span>`)) + announcement = template.Must(template.New("announcement").Parse(`<span class="announcement">{{.Message}}</span>`)) + errormsg = template.Must(template.New("error").Parse(`<span class="error">{{.Message}}</span>`)) + notice = template.Must(template.New("notice").Parse(`<span class="notice">{{.Message}}</span>`)) + command = template.Must(template.New("command").Parse(`<span class="command">{{.Message}}</span>`)) + commanderror = template.Must(template.New("commanderror").Parse(`<span class="commanderror">{{.Message}}</span>`)) + cmdlMod = template.Must(template.New("cmdlMod").Parse(`<span><img src="/static/img/mod.png" class="badge" /><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) + cmdlAdmin = template.Must(template.New("CmdlAdmin").Parse(`<span><img src="/static/img/admin.png" class="badge" /><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) + defaultMsg = template.Must(template.New("defaultMsg").Parse(`<span><span class="name" style="color:{{.Color}}">{{.From}}</span><b>:</b> <span class="msg">{{.Message}}</span></span>`)) +) + // TODO: Read this HTML from a template somewhere func (dc DataMessage) HTML() string { + buf := &bytes.Buffer{} switch dc.Type { case MsgAction: - return `<span style="color:` + dc.Color + `"><span class="name">` + dc.From + - `</span> <span class="cmdme">` + dc.Message + `</span></span>` - + cmdme.Execute(buf, dc) + return buf.String() case MsgServer: - return `<span class="announcement">` + dc.Message + `</span>` - + announcement.Execute(buf, dc) + return buf.String() case MsgError: - return `<span class="error">` + dc.Message + `</span>` - + errormsg.Execute(buf, dc) + return buf.String() case MsgNotice: - return `<span class="notice">` + dc.Message + `</span>` - + notice.Execute(buf, dc) + return buf.String() case MsgCommandResponse: - return `<span class="command">` + dc.Message + `</span>` - + command.Execute(buf, dc) + return buf.String() case MsgCommandError: - return `<span class="commanderror">` + dc.Message + `</span>` + commanderror.Execute(buf, dc) + return buf.String() default: - badge := "" switch dc.Level { case CmdlMod: - badge = `<img src="/static/img/mod.png" class="badge" />` + cmdlMod.Execute(buf, dc) case CmdlAdmin: - badge = `<img src="/static/img/admin.png" class="badge" />` + cmdlAdmin.Execute(buf, dc) + default: + defaultMsg.Execute(buf, dc) } - return `<span>` + badge + `<span class="name" style="color:` + dc.Color + `">` + dc.From + - `</span><b>:</b> <span class="msg">` + dc.Message + `</span></span>` + return buf.String() } } @@ -165,42 +180,51 @@ type DataEvent struct { Event EventType User string Color string + Users []string } +var ( + evKick = template.Must(template.New("evKick").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has been kicked.</span>`)) + evLeave = template.Must(template.New("evLeave").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has left the chat.</span>`)) + evBan = template.Must(template.New("evBan").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has been banned.</span>`)) + evJoin = template.Must(template.New("evJoin").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{.User}}</span> has joined the chat.</span>`)) + evNameChangeWC = template.Must(template.New("evNameChangeWC").Parse(`<span class="event">Somebody changed their name, but IDK who {{.}}.</span>`)) + evNameChange = template.Must(template.New("evNameChange").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{index .Users 0}}</span> has changed their name to <span class="name" style="color:{{.Color}}">{{index .Users 1}}</span>.</span>`)) + evNameChangeForced = template.Must(template.New("evNameChangeForced").Parse(`<span class="event"><span class="name" style="color:{{.Color}}">{{index .Users 0}}</span> has had their name changed to <span class="name" style="color:{{.Color}}">{{index .Users 1}}</span> by an admin.</span>`)) + evNameChangeForcedWC = template.Must(template.New("evNameChangeForcedWC").Parse(`<span class="event">An admin changed somebody's name, but IDK who {{.}}.</span>`)) +) + func (de DataEvent) HTML() string { + buf := &bytes.Buffer{} switch de.Event { case EvKick: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has been kicked.</span>` + evKick.Execute(buf, de) + return buf.String() case EvLeave: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has left the chat.</span>` + evLeave.Execute(buf, de) + return buf.String() case EvBan: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has been banned.</span>` + evBan.Execute(buf, de) + return buf.String() case EvJoin: - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - de.User + `</span> has joined the chat.</span>` + evJoin.Execute(buf, de) + return buf.String() case EvNameChange: - names := strings.Split(de.User, ":") - if len(names) != 2 { - return `<span class="event">Somebody changed their name, but IDK who ` + - ParseEmotes("Jebaited") + `.</span>` + de.Users = strings.Split(de.User, ":") + if len(de.Users) < 2 { + evNameChangeWC.Execute(buf, ParseEmotes("Jebaited")) + } else { + evNameChange.Execute(buf, de) } - - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - names[0] + `</span> has changed their name to <span class="name" style="color:` + - de.Color + `">` + names[1] + `</span>.</span>` + return buf.String() case EvNameChangeForced: - names := strings.Split(de.User, ":") - if len(names) != 2 { - return `<span class="event">An admin changed somebody's name, but IDK who ` + - ParseEmotes("Jebaited") + `.</span>` + de.Users = strings.Split(de.User, ":") + if len(de.Users) < 2 { + evNameChangeForcedWC.Execute(buf, ParseEmotes("Jebaited")) + } else { + evNameChangeForced.Execute(buf, de) } - - return `<span class="event"><span class="name" style="color:` + de.Color + `">` + - names[0] + `</span> has had their name changed to <span class="name" style="color:` + - de.Color + `">` + names[1] + `</span> by an admin.</span>` + return buf.String() } return "" } From ded51b2b2098fccd010a19205218594d6e277688 Mon Sep 17 00:00:00 2001 From: Bruno-DaSilva <Bruno-DaSilva@users.noreply.github.com> Date: Tue, 1 Dec 2020 21:23:41 -0800 Subject: [PATCH 199/207] Add unlocks to error cases in handlers::handlePublish() In handlers::handlePublish(), the mutex for the rtmp stream is locked at the beginning of the function. The previous implementation checked for error cases (e.g. incorrect stream key), logging and immediately returning if an error case was found. The mutex, however, was not unlocked, leading to the server effectively 'freezing' as other interactions try and lock that mutex. This MR adds mutex unlocks in each error case to ensure that the server continues to function in the event of a recoverable error. --- handlers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/handlers.go b/handlers.go index 0a2a3a2..e2c30dd 100644 --- a/handlers.go +++ b/handlers.go @@ -363,16 +363,19 @@ func handlePublish(conn *rtmp.Conn) { if len(urlParts) > 2 { common.LogErrorln("Extra garbage after stream key") + l.Unlock() return } if len(urlParts) != 2 { common.LogErrorln("Missing stream key") + l.Unlock() return } if urlParts[1] != settings.GetStreamKey() { common.LogErrorln("Stream key is incorrect. Denying stream.") + l.Unlock() return //If key not match, deny stream } From faa0792e9c2c02f4b8c5a99abf31aa3ff6679bff Mon Sep 17 00:00:00 2001 From: Raz Hemo <razhemo1337@gmail.com> Date: Fri, 8 Jan 2021 11:42:40 +0200 Subject: [PATCH 200/207] fix windows cross compiling --- make/Makefile.common | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 make/Makefile.common diff --git a/make/Makefile.common b/make/Makefile.common old mode 100644 new mode 100755 index c939903..e179728 --- a/make/Makefile.common +++ b/make/Makefile.common @@ -7,7 +7,7 @@ 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) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS) setdev: $(eval export TAGS=-tags "dev") @@ -15,7 +15,7 @@ setdev: dev: setdev all MovieNight: *.go common/*.go - GOOS=${GOOS} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight${EXT} $(TAGS) + GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight${EXT} $(TAGS) static/js/wasm_exec.js: cp $$(go$(GO_VERSION) env GOROOT)/misc/wasm/wasm_exec.js $@ From 238d80658b8c91bdccd7fad9658130b658790773 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Sun, 10 Jan 2021 12:04:16 -0500 Subject: [PATCH 201/207] Cleanup incoming stream handler Cleaned up the incoming RTMP handler to close connections on error. The code aquireing the RTMP channel was also rewritten to be more idomatic and easier to follow. --- handlers.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/handlers.go b/handlers.go index e2c30dd..3c80f1a 100644 --- a/handlers.go +++ b/handlers.go @@ -364,37 +364,39 @@ func handlePublish(conn *rtmp.Conn) { if len(urlParts) > 2 { common.LogErrorln("Extra garbage after stream key") l.Unlock() + conn.Close() return } if len(urlParts) != 2 { common.LogErrorln("Missing stream key") l.Unlock() + conn.Close() return } if urlParts[1] != settings.GetStreamKey() { common.LogErrorln("Stream key is incorrect. Denying stream.") l.Unlock() + conn.Close() return //If key not match, deny stream } streamPath := urlParts[0] - ch := channels[streamPath] - if ch == nil { - ch = &Channel{} - ch.que = pubsub.NewQueue() - ch.que.WriteHeader(streams) - channels[streamPath] = ch - } else { - ch = nil - } - l.Unlock() - if ch == nil { - common.LogErrorln("Unable to start stream, channel is nil.") + ch, exists := channels[streamPath] + if exists { + common.LogErrorln("Stream already running. Denying publish.") + conn.Close() + l.Unlock() return } + ch = &Channel{} + ch.que = pubsub.NewQueue() + ch.que.WriteHeader(streams) + channels[streamPath] = ch + l.Unlock() + stats.startStream() common.LogInfoln("Stream started") From ebc51f938ce63610287601605ec8ce8f93753865 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Sun, 10 Jan 2021 20:06:48 -0500 Subject: [PATCH 202/207] Remove the /pin endpoint This was never supposed to be in there. --- handlers.go | 22 ---------------------- main.go | 1 - 2 files changed, 23 deletions(-) diff --git a/handlers.go b/handlers.go index 3c80f1a..3b86a53 100644 --- a/handlers.go +++ b/handlers.go @@ -2,7 +2,6 @@ package main import ( "encoding/json" - "fmt" "io" "net/http" "path" @@ -290,27 +289,6 @@ func handleEmoteTemplate(w http.ResponseWriter, r *http.Request) { } } -func handlePin(w http.ResponseWriter, r *http.Request) { - session, err := sstore.Get(r, "moviesession") - if err != nil { - common.LogDebugf("Unable to get session: %v\n", err) - } - - val := session.Values["pin"] - if val == nil { - session.Values["pin"] = "1234" - err := session.Save(r, w) - if err != nil { - fmt.Fprintf(w, "unable to save session: %v", err) - } - fmt.Fprint(w, "Pin was not set") - common.LogDebugln("pin was not set") - } else { - fmt.Fprintf(w, "pin set: %v", val) - common.LogDebugf("pin is set: %v\n", val) - } -} - func handleIndexTemplate(w http.ResponseWriter, r *http.Request) { if settings.RoomAccess != AccessOpen { if !checkRoomAccess(w, r) { diff --git a/main.go b/main.go index b598480..2c585d5 100644 --- a/main.go +++ b/main.go @@ -143,7 +143,6 @@ func startServer() { http.HandleFunc("/chat", handleIndexTemplate) http.HandleFunc("/video", handleIndexTemplate) http.HandleFunc("/help", handleHelpTemplate) - http.HandleFunc("/pin", handlePin) http.HandleFunc("/emotes", handleEmoteTemplate) http.HandleFunc("/", handleDefault) From e051cade7865717466afe577298d9e9dd00ce728 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Sun, 10 Jan 2021 20:07:20 -0500 Subject: [PATCH 203/207] Allow the pin to be passed in via the URL Instead of only prompting the user for a pin, also allow it to be passed in as the URL parameter "pin". --- handlers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/handlers.go b/handlers.go index 3b86a53..89367f5 100644 --- a/handlers.go +++ b/handlers.go @@ -190,6 +190,14 @@ func checkRoomAccess(w http.ResponseWriter, r *http.Request) bool { // Pin is incorrect. handlePinTemplate(w, r, "Incorrect PIN") return false + } else { + qpin := r.URL.Query().Get("pin") + if qpin != "" && qpin == settings.RoomAccessPin { + // Pin is correct. Save it to session and return true. + session.Values["pin"] = settings.RoomAccessPin + session.Save(r, w) + return true + } } // nope. display pin entry and return handlePinTemplate(w, r, "") From d06e2251a41d62e9521537685f33cef495f0d5e8 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Sat, 16 Jan 2021 15:29:23 -0500 Subject: [PATCH 204/207] Separate /live and / http handlers Separate the /live and / (main) http handlers. This cleans up the related code a little bit and makes it a lot easier to follow. --- handlers.go | 20 ++++++++++++-------- main.go | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/handlers.go b/handlers.go index 89367f5..8b3ae68 100644 --- a/handlers.go +++ b/handlers.go @@ -408,7 +408,7 @@ func handlePlay(conn *rtmp.Conn) { } } -func handleDefault(w http.ResponseWriter, r *http.Request) { +func handleLive(w http.ResponseWriter, r *http.Request) { l.RLock() ch := channels[strings.Trim(r.URL.Path, "/")] l.RUnlock() @@ -426,12 +426,16 @@ func handleDefault(w http.ResponseWriter, r *http.Request) { avutil.CopyFile(muxer, cursor) } else { - if r.URL.Path != "/" { - // not really an error for the server, but for the client. - common.LogInfoln("[http 404] ", r.URL.Path) - http.NotFound(w, r) - } else { - handleIndexTemplate(w, r) - } + + } +} + +func handleDefault(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + // not really an error for the server, but for the client. + common.LogInfoln("[http 404] ", r.URL.Path) + http.NotFound(w, r) + } else { + handleIndexTemplate(w, r) } } diff --git a/main.go b/main.go index 2c585d5..ca383c5 100644 --- a/main.go +++ b/main.go @@ -145,6 +145,7 @@ func startServer() { http.HandleFunc("/help", handleHelpTemplate) http.HandleFunc("/emotes", handleEmoteTemplate) + http.HandleFunc("/live", handleLive) http.HandleFunc("/", handleDefault) err := http.ListenAndServe(addr, nil) From f76d1841731f1553d7c88ced0b8a03bce0e1cb59 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Sat, 16 Jan 2021 15:36:44 -0500 Subject: [PATCH 205/207] Don't hardcode emote size Replaced the hardcoded height attribute in the emote img tags with a class attribute. This allows the emotes to be resized with the change of a CSS value instead of recompiling the server. Resolves #150 --- common/emotes.go | 4 ++-- common/emotes_test.go | 36 ++++++++++++++++++------------------ static/css/site.css | 4 ++++ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/common/emotes.go b/common/emotes.go index fcd3746..052e265 100644 --- a/common/emotes.go +++ b/common/emotes.go @@ -48,7 +48,7 @@ func (em EmotesMap) Add(fullpath string) EmotesMap { } func EmoteToHtml(file, title string) string { - return fmt.Sprintf(`<img src="%s" height="28px" title="%s" />`, file, title) + return fmt.Sprintf(`<img src="%s" class="emote" title="%s" />`, file, title) } // Used with a regexp.ReplaceAllStringFunc() call. Needs to lookup the value as it @@ -56,7 +56,7 @@ func EmoteToHtml(file, title string) string { func emoteToHmtl2(key string) string { key = strings.Trim(key, ":[]") if val, ok := Emotes[key]; ok { - return fmt.Sprintf(`<img src="%s" height="28px" title="%s" />`, val, key) + return fmt.Sprintf(`<img src="%s" class="emote" title="%s" />`, val, key) } return key } diff --git a/common/emotes_test.go b/common/emotes_test.go index 0e61f87..0e3cf28 100644 --- a/common/emotes_test.go +++ b/common/emotes_test.go @@ -6,31 +6,31 @@ import ( ) var data_good = map[string]string{ - "one": `<img src="/emotes/one.png" height="28px" title="one" />`, - "two": `<img src="/emotes/two.png" height="28px" title="two" />`, - "three": `<img src="/emotes/three.gif" height="28px" title="three" />`, + "one": `<img src="/emotes/one.png" class="emote" title="one" />`, + "two": `<img src="/emotes/two.png" class="emote" title="two" />`, + "three": `<img src="/emotes/three.gif" class="emote" title="three" />`, - ":one:": `<img src="/emotes/one.png" height="28px" title="one" />`, - ":two:": `<img src="/emotes/two.png" height="28px" title="two" />`, - ":three:": `<img src="/emotes/three.gif" height="28px" title="three" />`, + ":one:": `<img src="/emotes/one.png" class="emote" title="one" />`, + ":two:": `<img src="/emotes/two.png" class="emote" title="two" />`, + ":three:": `<img src="/emotes/three.gif" class="emote" title="three" />`, - ":one::one:": `<img src="/emotes/one.png" height="28px" title="one" /><img src="/emotes/one.png" height="28px" title="one" />`, - ":one:one:": `<img src="/emotes/one.png" height="28px" title="one" />one:`, + ":one::one:": `<img src="/emotes/one.png" class="emote" title="one" /><img src="/emotes/one.png" class="emote" title="one" />`, + ":one:one:": `<img src="/emotes/one.png" class="emote" title="one" />one:`, "oneone": "oneone", - "one:one:": `one<img src="/emotes/one.png" height="28px" title="one" />`, + "one:one:": `one<img src="/emotes/one.png" class="emote" title="one" />`, - "[one]": `<img src="/emotes/one.png" height="28px" title="one" />`, - "[two]": `<img src="/emotes/two.png" height="28px" title="two" />`, - "[three]": `<img src="/emotes/three.gif" height="28px" title="three" />`, + "[one]": `<img src="/emotes/one.png" class="emote" title="one" />`, + "[two]": `<img src="/emotes/two.png" class="emote" title="two" />`, + "[three]": `<img src="/emotes/three.gif" class="emote" title="three" />`, - "[one][one]": `<img src="/emotes/one.png" height="28px" title="one" /><img src="/emotes/one.png" height="28px" title="one" />`, - "[one]one": `<img src="/emotes/one.png" height="28px" title="one" />one`, + "[one][one]": `<img src="/emotes/one.png" class="emote" title="one" /><img src="/emotes/one.png" class="emote" title="one" />`, + "[one]one": `<img src="/emotes/one.png" class="emote" title="one" />one`, - ":one: two [three]": `<img src="/emotes/one.png" height="28px" title="one" /> <img src="/emotes/two.png" height="28px" title="two" /> <img src="/emotes/three.gif" height="28px" title="three" />`, + ":one: two [three]": `<img src="/emotes/one.png" class="emote" title="one" /> <img src="/emotes/two.png" class="emote" title="two" /> <img src="/emotes/three.gif" class="emote" title="three" />`, - "nope one what": `nope <img src="/emotes/one.png" height="28px" title="one" /> what`, - "nope :two: what": `nope <img src="/emotes/two.png" height="28px" title="two" /> what`, - "nope [three] what": `nope <img src="/emotes/three.gif" height="28px" title="three" /> what`, + "nope one what": `nope <img src="/emotes/one.png" class="emote" title="one" /> what`, + "nope :two: what": `nope <img src="/emotes/two.png" class="emote" title="two" /> what`, + "nope [three] what": `nope <img src="/emotes/three.gif" class="emote" title="three" /> what`, } var data_wrapped = map[string]string{ diff --git a/static/css/site.css b/static/css/site.css index 5f06b58..5604b2a 100644 --- a/static/css/site.css +++ b/static/css/site.css @@ -124,6 +124,10 @@ input[type=text] { width: 112px; } +.emote { + height: 28px; +} + .notice { color: #595959; font-size: 75%; From 127fb4c3faffe5943b23ad20d7c5e6fc165f9dc9 Mon Sep 17 00:00:00 2001 From: Zorchenhimer <zorchenhimer@gmail.com> Date: Sun, 7 Feb 2021 15:55:51 -0500 Subject: [PATCH 206/207] Gracefully shutdown HTTP server Rearranged how the RTMP and HTTP servers are started so they could be gracefully shutdown easier. Currently, only the HTTP server is gracefully shutdown. I'm unsure if it is even possible for the RTMP server. The documentation for the RTMP library is basically non-existent, so it's impossible to know for sure without diving into the library code. --- main.go | 84 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/main.go b/main.go index ca383c5..36f73b4 100644 --- a/main.go +++ b/main.go @@ -1,12 +1,13 @@ package main import ( + "context" "flag" "fmt" "net/http" "os" "os/signal" - // "path/filepath" + "time" "github.com/gorilla/sessions" "github.com/nareix/joy4/format" @@ -112,47 +113,64 @@ func main() { common.LogInfoln("RoomAccess: ", settings.RoomAccess) common.LogInfoln("RoomAccessPin: ", settings.RoomAccessPin) - go startServer() - go startRmtpServer() - - <-exit -} - -func startRmtpServer() { - server := &rtmp.Server{ + rtmpServer := &rtmp.Server{ HandlePlay: handlePlay, HandlePublish: handlePublish, Addr: rtmpAddr, } - err := server.ListenAndServe() - if err != nil { - // If the server cannot start, don't pretend we can continue. - panic("Error trying to start rtmp server: " + err.Error()) + + router := http.NewServeMux() + + router.HandleFunc("/ws", wsHandler) // Chat websocket + router.HandleFunc("/static/js/", wsStaticFiles) + router.HandleFunc("/static/css/", wsStaticFiles) + router.HandleFunc("/static/img/", wsImages) + router.HandleFunc("/static/main.wasm", wsWasmFile) + router.HandleFunc("/emotes/", wsEmotes) + router.HandleFunc("/favicon.ico", wsStaticFiles) + router.HandleFunc("/chat", handleIndexTemplate) + router.HandleFunc("/video", handleIndexTemplate) + router.HandleFunc("/help", handleHelpTemplate) + router.HandleFunc("/emotes", handleEmoteTemplate) + + router.HandleFunc("/live", handleLive) + router.HandleFunc("/", handleDefault) + + httpServer := &http.Server{ + Addr: addr, + Handler: router, } -} -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("/emotes", handleEmoteTemplate) + // RTMP Server + go func() { + err := rtmpServer.ListenAndServe() + if err != nil { + // If the server cannot start, don't pretend we can continue. + panic("Error trying to start rtmp server: " + err.Error()) + } + }() - http.HandleFunc("/live", handleLive) - http.HandleFunc("/", handleDefault) + // HTTP Server + go func() { + err := httpServer.ListenAndServe() + if err != nil && err != http.ErrServerClosed { + // If the server cannot start, don't pretend we can continue. + panic("Error trying to start chat/http server: " + err.Error()) + } + }() - err := http.ListenAndServe(addr, nil) - if err != nil { - // If the server cannot start, don't pretend we can continue. - panic("Error trying to start chat/http server: " + err.Error()) + <-exit + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + if err := httpServer.Shutdown(ctx); err != nil && err != http.ErrServerClosed { + panic("Gracefull HTTP server shutdown failed: " + err.Error()) } + + // I don't think the RTMP server can be shutdown cleanly. Apparently the author + // of joy4 want's everyone to use joy5, but that one doesn't seem to allow clean + // shutdowns either? Idk, the documentation on joy4 and joy5 are non-existent. } func handleInterrupt(exit chan bool) { From 19438a1409f4aeb43331a529c7b97e7cbbc95b2f Mon Sep 17 00:00:00 2001 From: Zorglube <zorglube@broncotoxique.com> Date: Wed, 10 Mar 2021 20:22:11 +0100 Subject: [PATCH 207/207] Update readme, FreeNAS plugin had been released --- readme.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 7e9ab77..868525d 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,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) + - [FreeNAS / TrueNAS / FreeBSD build and run](#freenas-freebsd-build-and-run) - [Usage](#usage) - [Configuration](#configuration) @@ -86,8 +86,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) +### FreeNAS-FreeBSD build and run +A [FreeNAS & TrueNAS plugin](https://github.com/zorglube/iocage-plugin-movienight) had been released. You should find MovieNight into the plugin section of you management GUI. However you still can make an manual plugin deployment, documentation [here](https://github.com/freenas/iocage-ix-plugins) +If you prefer to make an Jail without using the plugin management, a script wich setup an Jail and build and run MovieNight into that Jail as been written, 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