mirror of
https://github.com/teacat/chaturbate-dvr.git
synced 2025-10-29 16:59:59 +00:00
Added gin BasicAuth
Create docker-compose-web.yml and web.Dockerfile Create Makefile
This commit is contained in:
parent
45308d806a
commit
21c689768c
64
Makefile
Normal file
64
Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
##
|
||||
## ----------------------------------------------------------------------------
|
||||
## Docker
|
||||
## ----------------------------------------------------------------------------
|
||||
##
|
||||
|
||||
docker-start-chaturbate-dvr: ## Start docker Chaturbate DVR
|
||||
docker-compose -f docker-compose.yml up -d
|
||||
|
||||
docker-stop-chaturbate-dvr: ## Stop docker Chaturbate DVR
|
||||
docker-compose -f docker-compose.yml down
|
||||
|
||||
docker-restart-chaturbate-dvr: ## Restart project Chaturbate DVR
|
||||
docker-compose -f docker-compose.yml restart
|
||||
|
||||
docker-start-chaturbate-dvr-web: ## Start docker Chaturbate DVR WEB
|
||||
docker-compose -f docker-compose-web.yml up -d
|
||||
|
||||
docker-stop-chaturbate-dvr-web: ## Stop docker Chaturbate DVR WEB
|
||||
docker-compose -f docker-compose-web.yml down
|
||||
|
||||
docker-restart-chaturbate-dvr-web: ## Restart project Chaturbate DVR WEB
|
||||
docker-compose -f docker-compose-web.yml restart
|
||||
|
||||
.PHONY: docker-start-chaturbate-dvr docker-stop-chaturbate-dvr docker-restart-chaturbate-dvr docker-start-chaturbate-dvr-web docker-stop-chaturbate-dvr-web docker-restart-chaturbate-dvr-web
|
||||
|
||||
##
|
||||
## ----------------------------------------------------------------------------
|
||||
## Compile
|
||||
## ----------------------------------------------------------------------------
|
||||
##
|
||||
|
||||
64bit-windows-macos-linux: ## Compile all arch amd64
|
||||
GOOS=windows GOARCH=amd64 go build -o bin/windows/chatubrate-dvr.exe && \
|
||||
GOOS=darwin GOARCH=amd64 go build -o bin/darwin/chatubrate-dvr && \
|
||||
GOOS=linux GOARCH=amd64 go build -o bin/linux/chatubrate-dvr
|
||||
|
||||
arm64-windows-macos-linux: ## Compile all arch arm64
|
||||
GOOS=windows GOARCH=arm64 go build -o bin/arm64/windows/chatubrate-dvr.exe && \
|
||||
GOOS=darwin GOARCH=arm64 go build -o bin/arm64/darwin/chatubrate-dvr && \
|
||||
GOOS=linux GOARCH=arm64 go build -o bin/arm64/linux/chatubrate-dvr
|
||||
|
||||
compile-all: ## Compile all
|
||||
GOOS=windows GOARCH=amd64 go build -o bin/windows/chatubrate-dvr.exe && \
|
||||
GOOS=darwin GOARCH=amd64 go build -o bin/darwin/chatubrate-dvr && \
|
||||
GOOS=linux GOARCH=amd64 go build -o bin/linux/chatubrate-dvr && \
|
||||
GOOS=windows GOARCH=arm64 go build -o bin/arm64/windows/chatubrate-dvr.exe && \
|
||||
GOOS=darwin GOARCH=arm64 go build -o bin/arm64/darwin/chatubrate-dvr && \
|
||||
GOOS=linux GOARCH=arm64 go build -o bin/arm64/linux/chatubrate-dvr
|
||||
|
||||
.PHONY: 64bit-windows-macos-linux arm64-windows-macos-linux
|
||||
|
||||
##
|
||||
## ----------------------------------------------------------------------------
|
||||
## Help
|
||||
## ----------------------------------------------------------------------------
|
||||
##
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: help
|
||||
help: ## Show this help
|
||||
@egrep -h '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \
|
||||
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' \
|
||||
| sed -e 's/\[32m##/[33m/'
|
||||
12
README.md
12
README.md
@ -42,6 +42,18 @@ $ chaturbate-dvr -u CHANNEL_USERNAME
|
||||
|
||||
|
||||
|
||||
**🔒 Restrict access page**
|
||||
|
||||
If you want to restrict access to the page using a username and password, add this to the accounts.json file
|
||||
|
||||
```json
|
||||
{
|
||||
"john.doe": "password"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Preview
|
||||
|
||||

|
||||
|
||||
1
accounts.json
Normal file
1
accounts.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
BIN
bin/arm64/darwin/chatubrate-dvr
Normal file → Executable file
BIN
bin/arm64/darwin/chatubrate-dvr
Normal file → Executable file
Binary file not shown.
BIN
bin/arm64/linux/chatubrate-dvr
Normal file → Executable file
BIN
bin/arm64/linux/chatubrate-dvr
Normal file → Executable file
Binary file not shown.
BIN
bin/arm64/windows/chatubrate-dvr.exe
Normal file → Executable file
BIN
bin/arm64/windows/chatubrate-dvr.exe
Normal file → Executable file
Binary file not shown.
BIN
bin/darwin/chatubrate-dvr
Normal file → Executable file
BIN
bin/darwin/chatubrate-dvr
Normal file → Executable file
Binary file not shown.
BIN
bin/linux/chatubrate-dvr
Normal file → Executable file
BIN
bin/linux/chatubrate-dvr
Normal file → Executable file
Binary file not shown.
BIN
bin/windows/chatubrate-dvr.exe
Normal file → Executable file
BIN
bin/windows/chatubrate-dvr.exe
Normal file → Executable file
Binary file not shown.
12
docker-compose-web.yml
Normal file
12
docker-compose-web.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: "3.0"
|
||||
|
||||
services:
|
||||
chaturbate-dvr-web:
|
||||
container_name: chaturbate-dvr-web
|
||||
build:
|
||||
context: .
|
||||
dockerfile: web.Dockerfile
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./accounts.json:/usr/src/app/accounts.json
|
||||
@ -1,9 +1,10 @@
|
||||
version: "3.0"
|
||||
|
||||
services:
|
||||
chaturbate-dvr:
|
||||
build: .
|
||||
environment:
|
||||
- USERNAME=CHANNEL_USERNAME
|
||||
volumes:
|
||||
- ./videos:/usr/src/app/videos
|
||||
chaturbate-dvr:
|
||||
container_name: chaturbate-dvr
|
||||
build: .
|
||||
environment:
|
||||
- USERNAME=CHANNEL_USERNAME
|
||||
volumes:
|
||||
- ./videos:/usr/src/app/videos
|
||||
|
||||
50
main.go
50
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
@ -126,6 +127,21 @@ func start(c *cli.Context) error {
|
||||
//go:embed handler/view
|
||||
var FS embed.FS
|
||||
|
||||
func listAccounts() gin.Accounts {
|
||||
b, err := os.ReadFile("accounts.json")
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
var configs gin.Accounts
|
||||
if err := json.Unmarshal(b, &configs); err != nil {
|
||||
return nil
|
||||
}
|
||||
return configs
|
||||
}
|
||||
|
||||
func startWeb(c *cli.Context) error {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.Default()
|
||||
@ -140,18 +156,30 @@ func startWeb(c *cli.Context) error {
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
r.StaticFS("/static", http.FS(fe))
|
||||
r.StaticFileFS("/", "/", http.FS(fe))
|
||||
|
||||
r.POST("/api/get_channel", handler.NewGetChannelHandler(m, c).Handle)
|
||||
r.POST("/api/create_channel", handler.NewCreateChannelHandler(m, c).Handle)
|
||||
r.POST("/api/list_channels", handler.NewListChannelsHandler(m, c).Handle)
|
||||
r.POST("/api/delete_channel", handler.NewDeleteChannelHandler(m, c).Handle)
|
||||
r.POST("/api/pause_channel", handler.NewPauseChannelHandler(m, c).Handle)
|
||||
r.POST("/api/resume_channel", handler.NewResumeChannelHandler(m, c).Handle)
|
||||
r.GET("/api/listen_update", handler.NewListenUpdateHandler(m, c).Handle)
|
||||
r.POST("/api/get_settings", handler.NewGetSettingsHandler(c).Handle)
|
||||
r.POST("/api/terminate_program", handler.NewTerminateProgramHandler(c).Handle)
|
||||
accounts := listAccounts()
|
||||
|
||||
var authorized = r.Group("/")
|
||||
var authorizedApi = r.Group("/api")
|
||||
|
||||
if len(accounts) > 0 {
|
||||
ginBasicAuth := gin.BasicAuth(accounts)
|
||||
authorized.Use(ginBasicAuth)
|
||||
authorizedApi.Use(ginBasicAuth)
|
||||
}
|
||||
|
||||
authorized.StaticFS("/static", http.FS(fe))
|
||||
authorized.StaticFileFS("/", "/", http.FS(fe))
|
||||
|
||||
authorizedApi.POST("/get_channel", handler.NewGetChannelHandler(m, c).Handle)
|
||||
authorizedApi.POST("/create_channel", handler.NewCreateChannelHandler(m, c).Handle)
|
||||
authorizedApi.POST("/list_channels", handler.NewListChannelsHandler(m, c).Handle)
|
||||
authorizedApi.POST("/delete_channel", handler.NewDeleteChannelHandler(m, c).Handle)
|
||||
authorizedApi.POST("/pause_channel", handler.NewPauseChannelHandler(m, c).Handle)
|
||||
authorizedApi.POST("/resume_channel", handler.NewResumeChannelHandler(m, c).Handle)
|
||||
authorizedApi.GET("/listen_update", handler.NewListenUpdateHandler(m, c).Handle)
|
||||
authorizedApi.POST("/get_settings", handler.NewGetSettingsHandler(c).Handle)
|
||||
authorizedApi.POST("/terminate_program", handler.NewTerminateProgramHandler(c).Handle)
|
||||
|
||||
fmt.Printf("👋 Visit http://localhost:%s to use the Web UI\n", c.String("port"))
|
||||
|
||||
|
||||
11
web.Dockerfile
Normal file
11
web.Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM golang:latest
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
RUN go build
|
||||
|
||||
CMD [ "sh", "-c", "./chaturbate-dvr" ]
|
||||
Loading…
x
Reference in New Issue
Block a user