refresh back

This commit is contained in:
2025-10-03 16:55:09 +06:00
parent fbb530c619
commit ec2df9e612
7 changed files with 143 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
package cmd
import (
import (
"fmt"
"strconv"
"strings"
@@ -100,13 +100,17 @@ func parseInlineTargets(targetsStr, delayStr string) (*internal.Config, error) {
// Разбираем формат [proto]:[host]:[port]
parts := strings.Split(targetStr, ":")
if len(parts) != 3 {
return nil, fmt.Errorf("неверный формат цели '%s', ожидается [proto]:[host]:[port]", targetStr)
if len(parts) != 3 && len(parts) != 4 {
return nil, fmt.Errorf("неверный формат цели '%s', ожидается [proto]:[host]:[port] или [proto]:[host]:[port]:[gateway]", targetStr)
}
protocol := strings.TrimSpace(parts[0])
host := strings.TrimSpace(parts[1])
portStr := strings.TrimSpace(parts[2])
gateway := ""
if len(parts) == 4 {
gateway = strings.TrimSpace(parts[3])
}
// Проверяем протокол
if protocol != "tcp" && protocol != "udp" {
@@ -130,7 +134,7 @@ func parseInlineTargets(targetsStr, delayStr string) (*internal.Config, error) {
Protocol: protocol,
Delay: internal.Duration(delay),
WaitConnection: false,
Gateway: "",
Gateway: gateway,
}
config.Targets = append(config.Targets, target)