mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
add backend for CDP validation
This commit is contained in:
parent
4de2351e7c
commit
72e6c04644
5 changed files with 46 additions and 0 deletions
|
|
@ -247,6 +247,9 @@ type Query {
|
|||
): Directory!
|
||||
validateStashBoxCredentials(input: StashBoxInput!): StashBoxValidationResult!
|
||||
|
||||
# Validate remote CDP path
|
||||
ValidateCDPPath: CDPValidationResult!
|
||||
|
||||
# System status
|
||||
systemStatus: SystemStatus!
|
||||
|
||||
|
|
|
|||
|
|
@ -626,3 +626,8 @@ type StashBoxValidationResult {
|
|||
valid: Boolean!
|
||||
status: String!
|
||||
}
|
||||
|
||||
type CDPValidationResult {
|
||||
valid: Boolean!
|
||||
status: String!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/stashapp/stash/internal/manager/config"
|
||||
"github.com/stashapp/stash/pkg/fsutil"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/scraper"
|
||||
"golang.org/x/text/collate"
|
||||
)
|
||||
|
||||
|
|
@ -285,3 +286,17 @@ func (r *queryResolver) ValidateStashBoxCredentials(ctx context.Context, input c
|
|||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) ValidateCDPPath(ctx context.Context) (*CDPValidationResult, error) {
|
||||
err := scraper.TestRemoteCDP(config.GetInstance())
|
||||
if err == nil {
|
||||
return &CDPValidationResult{
|
||||
Valid: true,
|
||||
Status: "Successfully validated CDP path",
|
||||
}, nil
|
||||
}
|
||||
return &CDPValidationResult{
|
||||
Valid: false,
|
||||
Status: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,3 +329,19 @@ func splitProxyAuth(proxyUrl string) (string, string, string) {
|
|||
|
||||
return proxyUrl, "", ""
|
||||
}
|
||||
|
||||
func TestRemoteCDP(globalConfig GlobalConfig) error {
|
||||
cdpPath := globalConfig.GetScraperCDPPath()
|
||||
if cdpPath == "" {
|
||||
return fmt.Errorf("CDP path is empty")
|
||||
}
|
||||
if !isCDPPathHTTP(globalConfig) {
|
||||
// unable to test non-http CDP
|
||||
return fmt.Errorf("Unable to test non-http CDP paths")
|
||||
}
|
||||
_, err := getRemoteCDPWSAddress(context.Background(), cdpPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to get remote CDP websocket address: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,3 +18,10 @@ query ValidateStashBox($input: StashBoxInput!) {
|
|||
status
|
||||
}
|
||||
}
|
||||
|
||||
query ValidateCDP {
|
||||
ValidateCDPPath {
|
||||
valid
|
||||
status
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue