Skip to content

Commit

Permalink
fix: make remoted management OS specific
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-przytarski committed Sep 20, 2024
1 parent 317ae7c commit 74ee1e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/elazarl/goproxy v0.0.0-20240726154733-8b0c20506380 h1:1NyRx2f4W4WBRyg0Kys0ZbaNmDDzZ2R/C7DTi+bbsJ0=
github.com/elazarl/goproxy v0.0.0-20240726154733-8b0c20506380/go.mod h1:thX175TtLTzLj3p7N/Q9IiKZ7NF+p72cvL91emV0hzo=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
Expand Down
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Ev
github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
Expand Down
15 changes: 6 additions & 9 deletions ios/tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import (
"math/big"
"os/exec"
"runtime"
"syscall"
"time"

"github.com/danielpaulus/go-ios/ios"
"github.com/danielpaulus/go-ios/ios/http"
"github.com/pbar1/pkill-go"
"github.com/danielpaulus/go-ios/ios/remoted"

"github.com/quic-go/quic-go"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -50,13 +49,11 @@ func (t Tunnel) Close() error {
// After a successful pairing a tunnel for this device gets started and the tunnel information is returned
func ManualPairAndConnectToTunnel(ctx context.Context, device ios.DeviceEntry, p PairRecordManager) (Tunnel, error) {
logrus.Info("ManualPairAndConnectToTunnel: starting manual pairing and tunnel connection, dont forget run this with sudo.")
if runtime.GOOS == "darwin" {
_, err := pkill.Pkill("remoted", syscall.SIGSTOP)
if err != nil {
return Tunnel{}, fmt.Errorf("ManualPairAndConnectToTunnel: failed to stop remoted: %w", err)
} else {
logrus.Info("ManualPairAndConnectToTunnel: stopped remoted")
}
err := remoted.StopRemoted()
if err != nil {
return Tunnel{}, fmt.Errorf("ManualPairAndConnectToTunnel: failed to stop remoted: %w", err)
} else {
logrus.Info("ManualPairAndConnectToTunnel: stopped remoted")
}
addr, err := ios.FindDeviceInterfaceAddress(ctx, device)
if err != nil {
Expand Down
15 changes: 6 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os/signal"
"path"
"path/filepath"
"runtime"
"runtime/debug"
"sort"
"strconv"
Expand All @@ -21,8 +20,8 @@ import (

"github.com/danielpaulus/go-ios/ios/debugproxy"
"github.com/danielpaulus/go-ios/ios/deviceinfo"
"github.com/danielpaulus/go-ios/ios/remoted"

Check failure on line 23 in main.go

View workflow job for this annotation

GitHub Actions / test_on_linux

no required module provides package github.com/danielpaulus/go-ios/ios/remoted; to add it:
"github.com/danielpaulus/go-ios/ios/tunnel"
"github.com/pbar1/pkill-go"

"github.com/danielpaulus/go-ios/ios/amfi"
"github.com/danielpaulus/go-ios/ios/mobileactivation"
Expand Down Expand Up @@ -2117,13 +2116,11 @@ func startTunnel(ctx context.Context, recordsPath string, tunnelInfoPort int, us
log.Info("Tunnel server started")
<-ctx.Done()

if runtime.GOOS == "darwin" {
_, err := pkill.Pkill("remoted", syscall.SIGCONT)
if err != nil {
log.Errorf("failed to resume remoted: %v", err)
} else {
log.Info("resumed remoted")
}
err = remoted.ContinueRemoted()
if err != nil {
log.Errorf("failed to resume remoted: %v", err)
} else {
log.Info("resumed remoted")
}
}

Expand Down

0 comments on commit 74ee1e8

Please sign in to comment.