mirror of
https://github.com/teacat/chaturbate-dvr.git
synced 2025-10-29 16:59:59 +00:00
Merge pull request #48 from gunter423/basic-auth
Integrate authentication + Create Dockerfile for web service
This commit is contained in:
commit
dec4f8f302
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/'
|
||||
@ -95,6 +95,8 @@ COMMANDS:
|
||||
|
||||
GLOBAL OPTIONS:
|
||||
--username value, -u value channel username to record.
|
||||
--gui-username value, --gui-u value username for auth web.
|
||||
--gui-password value, --gui-p value password for auth web.
|
||||
--framerate value, -f value preferred framerate. (default: 30)
|
||||
--resolution value, -r value preferred resolution (default: 1080)
|
||||
--resolution-fallback value, --rf value fallback to 'up' (larger) or 'down' (smaller) resolution if preferred resolution is not available (default: "down")
|
||||
|
||||
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.
13
docker-compose-web.yml
Normal file
13
docker-compose-web.yml
Normal file
@ -0,0 +1,13 @@
|
||||
version: "3.0"
|
||||
|
||||
services:
|
||||
chaturbate-dvr-web:
|
||||
container_name: chaturbate-dvr-web
|
||||
build:
|
||||
context: .
|
||||
dockerfile: web.Dockerfile
|
||||
environment:
|
||||
- GUI_USERNAME=johndoe
|
||||
- GUI_PASSWORD=password
|
||||
ports:
|
||||
- "8080:8080"
|
||||
@ -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
|
||||
|
||||
49
main.go
49
main.go
@ -40,6 +40,18 @@ func main() {
|
||||
Usage: "channel username to record.",
|
||||
Value: "",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gui-username",
|
||||
Aliases: []string{"gui-u"},
|
||||
Usage: "username for auth web.",
|
||||
Value: "",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gui-password",
|
||||
Aliases: []string{"gui-p"},
|
||||
Usage: "password for auth web.",
|
||||
Value: "",
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "framerate",
|
||||
Aliases: []string{"f"},
|
||||
@ -140,18 +152,33 @@ 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)
|
||||
guiUsername := c.String("gui-username")
|
||||
guiPassword := c.String("gui-password")
|
||||
|
||||
var authorized = r.Group("/")
|
||||
var authorizedApi = r.Group("/api")
|
||||
|
||||
if guiUsername != "" && guiPassword != "" {
|
||||
ginBasicAuth := gin.BasicAuth(gin.Accounts{
|
||||
guiUsername: guiPassword,
|
||||
})
|
||||
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 -gui-username ${GUI_USERNAME} -gui-password ${GUI_PASSWORD}" ]
|
||||
Loading…
x
Reference in New Issue
Block a user