resolve server creation issues
This commit is contained in:
@@ -123,11 +123,12 @@ func (e *CallbackInteractiveCommandExecutor) monitorOutputWithCallbacks(ctx cont
|
||||
stdoutScanner := bufio.NewScanner(stdout)
|
||||
stderrScanner := bufio.NewScanner(stderr)
|
||||
|
||||
outputChan := make(chan outputLine, 100)
|
||||
outputChan := make(chan outputLine, 10000)
|
||||
readersDone := make(chan struct{}, 2)
|
||||
|
||||
steamConsoleStarted := false
|
||||
tfaRequestCreated := false
|
||||
tfaAutoCompleted := false
|
||||
|
||||
go func() {
|
||||
defer func() { readersDone <- struct{}{} }()
|
||||
@@ -182,13 +183,14 @@ func (e *CallbackInteractiveCommandExecutor) monitorOutputWithCallbacks(ctx cont
|
||||
if readersFinished == 2 {
|
||||
close(outputChan)
|
||||
for lineData := range outputChan {
|
||||
if e.is2FAPrompt(lineData.text) {
|
||||
if err := e.handle2FAPrompt(ctx, lineData.text, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
e.callbacks.OnOutput(e.serverID, fmt.Sprintf("Failed to handle 2FA prompt: %v", err), true)
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
if e.is2FAPrompt(lineData.text) && !tfaRequestCreated {
|
||||
tfaRequestCreated = true
|
||||
go func(prompt string) {
|
||||
if err := e.handle2FAPrompt(ctx, prompt, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
e.callbacks.OnOutput(e.serverID, fmt.Sprintf("Failed to handle 2FA prompt: %v", err), true)
|
||||
}
|
||||
}(lineData.text)
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -207,33 +209,34 @@ func (e *CallbackInteractiveCommandExecutor) monitorOutputWithCallbacks(ctx cont
|
||||
|
||||
if e.is2FAPrompt(lineData.text) {
|
||||
if !tfaRequestCreated {
|
||||
e.callbacks.OnOutput(e.serverID, "2FA prompt detected - waiting for user confirmation", false)
|
||||
if err := e.handle2FAPrompt(ctx, lineData.text, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
e.callbacks.OnOutput(e.serverID, fmt.Sprintf("Failed to handle 2FA prompt: %v", err), true)
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
tfaRequestCreated = true
|
||||
e.callbacks.OnOutput(e.serverID, "2FA prompt detected - waiting for user confirmation", false)
|
||||
go func(prompt string) {
|
||||
if err := e.handle2FAPrompt(ctx, prompt, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
e.callbacks.OnOutput(e.serverID, fmt.Sprintf("Failed to handle 2FA prompt: %v", err), true)
|
||||
}
|
||||
}(lineData.text)
|
||||
}
|
||||
}
|
||||
|
||||
if tfaRequestCreated && e.isSteamContinuing(lineData.text) {
|
||||
if tfaRequestCreated && !tfaAutoCompleted && e.isSteamContinuing(lineData.text) {
|
||||
logging.Info("Steam CMD appears to have continued after 2FA confirmation")
|
||||
tfaAutoCompleted = true
|
||||
e.callbacks.OnOutput(e.serverID, "Steam CMD continued after 2FA confirmation", false)
|
||||
e.autoCompletePendingRequests(serverID)
|
||||
}
|
||||
case <-time.After(15 * time.Second):
|
||||
if steamConsoleStarted && !tfaRequestCreated {
|
||||
tfaRequestCreated = true
|
||||
logging.Info("Steam Console started but no output for 15 seconds - likely waiting for Steam Guard 2FA")
|
||||
e.callbacks.OnOutput(e.serverID, "Waiting for Steam Guard 2FA confirmation...", false)
|
||||
if err := e.handle2FAPrompt(ctx, "Steam CMD appears to be waiting for Steam Guard confirmation after startup", serverID); err != nil {
|
||||
logging.Error("Failed to handle Steam Guard 2FA prompt: %v", err)
|
||||
e.callbacks.OnOutput(e.serverID, fmt.Sprintf("Failed to handle Steam Guard 2FA prompt: %v", err), true)
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
tfaRequestCreated = true
|
||||
go func() {
|
||||
if err := e.handle2FAPrompt(ctx, "Steam CMD appears to be waiting for Steam Guard confirmation after startup", serverID); err != nil {
|
||||
logging.Error("Failed to handle Steam Guard 2FA prompt: %v", err)
|
||||
e.callbacks.OnOutput(e.serverID, fmt.Sprintf("Failed to handle Steam Guard 2FA prompt: %v", err), true)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,11 +106,12 @@ func (e *InteractiveCommandExecutor) monitorOutput(ctx context.Context, stdout,
|
||||
stdoutScanner := bufio.NewScanner(stdout)
|
||||
stderrScanner := bufio.NewScanner(stderr)
|
||||
|
||||
outputChan := make(chan string, 100)
|
||||
outputChan := make(chan string, 10000)
|
||||
readersDone := make(chan struct{}, 2)
|
||||
|
||||
steamConsoleStarted := false
|
||||
tfaRequestCreated := false
|
||||
tfaAutoCompleted := false
|
||||
|
||||
go func() {
|
||||
defer func() { readersDone <- struct{}{} }()
|
||||
@@ -165,12 +166,13 @@ func (e *InteractiveCommandExecutor) monitorOutput(ctx context.Context, stdout,
|
||||
if readersFinished == 2 {
|
||||
close(outputChan)
|
||||
for line := range outputChan {
|
||||
if e.is2FAPrompt(line) {
|
||||
if err := e.handle2FAPrompt(ctx, line, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
if e.is2FAPrompt(line) && !tfaRequestCreated {
|
||||
tfaRequestCreated = true
|
||||
go func(prompt string) {
|
||||
if err := e.handle2FAPrompt(ctx, prompt, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
}
|
||||
}(line)
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -188,28 +190,29 @@ func (e *InteractiveCommandExecutor) monitorOutput(ctx context.Context, stdout,
|
||||
|
||||
if e.is2FAPrompt(line) {
|
||||
if !tfaRequestCreated {
|
||||
if err := e.handle2FAPrompt(ctx, line, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
tfaRequestCreated = true
|
||||
go func(prompt string) {
|
||||
if err := e.handle2FAPrompt(ctx, prompt, serverID); err != nil {
|
||||
logging.Error("Failed to handle 2FA prompt: %v", err)
|
||||
}
|
||||
}(line)
|
||||
}
|
||||
}
|
||||
|
||||
if tfaRequestCreated && e.isSteamContinuing(line) {
|
||||
if tfaRequestCreated && !tfaAutoCompleted && e.isSteamContinuing(line) {
|
||||
logging.Info("Steam CMD appears to have continued after 2FA confirmation - auto-completing 2FA request")
|
||||
tfaAutoCompleted = true
|
||||
e.autoCompletePendingRequests(serverID)
|
||||
}
|
||||
case <-time.After(15 * time.Second):
|
||||
if steamConsoleStarted && !tfaRequestCreated {
|
||||
logging.Info("Steam Console started but no output for 15 seconds - likely waiting for Steam Guard 2FA")
|
||||
if err := e.handle2FAPrompt(ctx, "Steam CMD appears to be waiting for Steam Guard confirmation after startup", serverID); err != nil {
|
||||
logging.Error("Failed to handle Steam Guard 2FA prompt: %v", err)
|
||||
done <- err
|
||||
return
|
||||
}
|
||||
tfaRequestCreated = true
|
||||
logging.Info("Steam Console started but no output for 15 seconds - likely waiting for Steam Guard 2FA")
|
||||
go func() {
|
||||
if err := e.handle2FAPrompt(ctx, "Steam CMD appears to be waiting for Steam Guard confirmation after startup", serverID); err != nil {
|
||||
logging.Error("Failed to handle Steam Guard 2FA prompt: %v", err)
|
||||
}
|
||||
}()
|
||||
} else if !steamConsoleStarted {
|
||||
logging.Info("No output for 15 seconds (Steam Console not yet started)")
|
||||
}
|
||||
@@ -220,22 +223,15 @@ func (e *InteractiveCommandExecutor) monitorOutput(ctx context.Context, stdout,
|
||||
func (e *InteractiveCommandExecutor) is2FAPrompt(line string) bool {
|
||||
twoFAKeywords := []string{
|
||||
"please enter your steam guard code",
|
||||
"steam guard",
|
||||
"two-factor",
|
||||
"authentication code",
|
||||
"steam guard code",
|
||||
"two-factor authentication",
|
||||
"please check your steam mobile app",
|
||||
"confirm in application",
|
||||
"enter the current code from your steam mobile app",
|
||||
"steam guard mobile authenticator",
|
||||
"waiting for user info",
|
||||
"login failure",
|
||||
"two factor code required",
|
||||
"enter steam guard code",
|
||||
"mobile authenticator code",
|
||||
"authenticator app",
|
||||
"guard code",
|
||||
"mobile app",
|
||||
"confirmation required",
|
||||
"2fa prompt detected",
|
||||
}
|
||||
|
||||
lowerLine := strings.ToLower(line)
|
||||
@@ -246,21 +242,6 @@ func (e *InteractiveCommandExecutor) is2FAPrompt(line string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
waitingPatterns := []string{
|
||||
"waiting for",
|
||||
"please enter",
|
||||
"enter code",
|
||||
"code:",
|
||||
"authenticator:",
|
||||
}
|
||||
|
||||
for _, pattern := range waitingPatterns {
|
||||
if strings.Contains(lowerLine, pattern) {
|
||||
logging.Info("Potential 2FA waiting pattern found: '%s' in line: '%s'", pattern, line)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ type RouteGroups struct {
|
||||
System fiber.Router
|
||||
WebSocket fiber.Router
|
||||
Leaderboard fiber.Router
|
||||
Steam fiber.Router
|
||||
}
|
||||
|
||||
func CheckError(err error) {
|
||||
|
||||
16
local/utl/env/env.go
vendored
16
local/utl/env/env.go
vendored
@@ -10,8 +10,7 @@ const (
|
||||
DefaultNSSMPath = ".\\nssm.exe"
|
||||
DefaultPlatform = "windows"
|
||||
DefaultACCImage = "acc-wine:latest"
|
||||
DefaultACCGameVolume = "/data/acc-game"
|
||||
DefaultACCConfigBasePath = "/data/configs"
|
||||
DefaultACCServersPath = "/data/servers"
|
||||
DefaultLinuxSteamCMDPath = "/usr/games/steamcmd"
|
||||
)
|
||||
|
||||
@@ -59,18 +58,11 @@ func GetACCImage() string {
|
||||
return DefaultACCImage
|
||||
}
|
||||
|
||||
func GetACCGameVolume() string {
|
||||
if v := os.Getenv("ACC_GAME_VOLUME"); v != "" {
|
||||
return v
|
||||
}
|
||||
return DefaultACCGameVolume
|
||||
}
|
||||
|
||||
func GetACCConfigBasePath() string {
|
||||
if p := os.Getenv("ACC_CONFIG_BASE_PATH"); p != "" {
|
||||
func GetACCServersPath() string {
|
||||
if p := os.Getenv("ACC_SERVERS_PATH"); p != "" {
|
||||
return p
|
||||
}
|
||||
return DefaultACCConfigBasePath
|
||||
return DefaultACCServersPath
|
||||
}
|
||||
|
||||
func ValidatePaths() map[string]error {
|
||||
|
||||
Reference in New Issue
Block a user