feat: add local cdp startup and external association
This commit is contained in:
+25
-12
@@ -14,6 +14,10 @@ type BrowserKind string
|
||||
const (
|
||||
BrowserChrome BrowserKind = "chrome"
|
||||
BrowserEdge BrowserKind = "edge"
|
||||
|
||||
DefaultRemoteDebugPort = 9666
|
||||
MinRemoteDebugPort = 1024
|
||||
MaxRemoteDebugPort = 65535
|
||||
)
|
||||
|
||||
func (k BrowserKind) Valid() bool { return k == BrowserChrome || k == BrowserEdge }
|
||||
@@ -35,6 +39,7 @@ type LaunchSpec struct {
|
||||
Executable string
|
||||
UserDataDir string
|
||||
ProfileDirectory string
|
||||
RemoteDebugPort int
|
||||
TargetURL string
|
||||
ProxyServer string
|
||||
Headless bool
|
||||
@@ -49,6 +54,9 @@ func (s LaunchSpec) Normalize() (LaunchSpec, error) {
|
||||
if userDataDir == "" || !filepath.IsAbs(userDataDir) {
|
||||
return LaunchSpec{}, fmt.Errorf("%w: user data dir must be absolute", ErrInvalidLaunchSpec)
|
||||
}
|
||||
if s.RemoteDebugPort != 0 && !ValidRemoteDebugPort(s.RemoteDebugPort) {
|
||||
return LaunchSpec{}, fmt.Errorf("%w: remote debugging port must be between %d and %d", ErrInvalidLaunchSpec, MinRemoteDebugPort, MaxRemoteDebugPort)
|
||||
}
|
||||
target := strings.TrimSpace(s.TargetURL)
|
||||
if target != "" {
|
||||
parsed, err := url.Parse(target)
|
||||
@@ -67,19 +75,24 @@ func (s LaunchSpec) Normalize() (LaunchSpec, error) {
|
||||
return normalized, nil
|
||||
}
|
||||
|
||||
func ValidRemoteDebugPort(port int) bool {
|
||||
return port >= MinRemoteDebugPort && port <= MaxRemoteDebugPort
|
||||
}
|
||||
|
||||
type InstanceView struct {
|
||||
ID string
|
||||
Kind BrowserKind
|
||||
Executable string
|
||||
PID int
|
||||
UserDataDir string
|
||||
Profile string
|
||||
TargetURL string
|
||||
Status InstanceStatus
|
||||
ExitCode *int
|
||||
StartedAt time.Time
|
||||
ChangedAt time.Time
|
||||
IdentityNote string
|
||||
ID string
|
||||
Kind BrowserKind
|
||||
Executable string
|
||||
PID int
|
||||
RemoteDebugPort int
|
||||
UserDataDir string
|
||||
Profile string
|
||||
TargetURL string
|
||||
Status InstanceStatus
|
||||
ExitCode *int
|
||||
StartedAt time.Time
|
||||
ChangedAt time.Time
|
||||
IdentityNote string
|
||||
}
|
||||
|
||||
type EventKind string
|
||||
|
||||
Reference in New Issue
Block a user