From 5a88c9d429615effe1774893e11e3b3822b37468 Mon Sep 17 00:00:00 2001 From: PenguinRobert1 <152218269+PenguinRobert1@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:03:43 +0000 Subject: [PATCH] 1 --- .../wdaproxy-master/wdaproxy-master/.fsw.yml | 18 - .../.github/workflows/release.yml | 28 - .../wdaproxy-master/.gitignore | 33 - .../wdaproxy-master/.goreleaser.yml | 26 - .../wdaproxy-master/.travis.yml | 9 - proxy/wdaproxy-master/wdaproxy-master/API.md | 87 --- proxy/wdaproxy-master/wdaproxy-master/LICENSE | 21 - .../wdaproxy-master/wdaproxy-master/README.md | 124 ---- .../wdaproxy-master/connector/connector.go | 169 ----- proxy/wdaproxy-master/wdaproxy-master/go.mod | 22 - .../wdaproxy-master/httplog.go | 21 - .../wdaproxy-master/installer.go | 33 - .../wdaproxy-master/wdaproxy-master/ioskit.go | 30 - proxy/wdaproxy-master/wdaproxy-master/main.go | 216 ------ .../wdaproxy-master/provider.go | 239 ------- .../wdaproxy-master/revproxy.go | 94 --- .../web/assets/images/favicon.ico | Bin 21662 -> 0 bytes .../wdaproxy-master/web/assets/index.html | 49 -- .../wdaproxy-master/web/assets/packages.html | 82 --- .../web/assets/remote-control.html | 629 ------------------ .../wdaproxy-master/web/assets_dev.go | 9 - .../wdaproxy-master/web/assets_generate.go | 23 - 22 files changed, 1962 deletions(-) delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/.fsw.yml delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/.github/workflows/release.yml delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/.gitignore delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/.goreleaser.yml delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/.travis.yml delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/API.md delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/LICENSE delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/README.md delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/connector/connector.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/go.mod delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/httplog.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/installer.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/ioskit.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/main.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/provider.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/revproxy.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/web/assets/images/favicon.ico delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/web/assets/index.html delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/web/assets/packages.html delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/web/assets/remote-control.html delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/web/assets_dev.go delete mode 100644 proxy/wdaproxy-master/wdaproxy-master/web/assets_generate.go diff --git a/proxy/wdaproxy-master/wdaproxy-master/.fsw.yml b/proxy/wdaproxy-master/wdaproxy-master/.fsw.yml deleted file mode 100644 index bc5767e5..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/.fsw.yml +++ /dev/null @@ -1,18 +0,0 @@ -desc: Auto generated by fswatch [wdaproxy] -triggers: -- name: "" - pattens: - - '**/*.go' - - '**/*.c' - - '**/*.py' - env: - DEBUG: "1" - cmd: go build && ./wdaproxy -p 8200 - shell: true - delay: 100ms - stop_timeout: 500ms - signal: KILL - kill_signal: "" -watch_paths: -- . -watch_depth: 0 diff --git a/proxy/wdaproxy-master/wdaproxy-master/.github/workflows/release.yml b/proxy/wdaproxy-master/wdaproxy-master/.github/workflows/release.yml deleted file mode 100644 index 826ba4bc..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/.github/workflows/release.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: goreleaser - -on: - pull_request: - push: - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.15 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} diff --git a/proxy/wdaproxy-master/wdaproxy-master/.gitignore b/proxy/wdaproxy-master/wdaproxy-master/.gitignore deleted file mode 100644 index f8ec270d..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof - -# Manual -*.py -*.zip -wdaproxy -assets_vfsdata.go - -go.sum -dist/ diff --git a/proxy/wdaproxy-master/wdaproxy-master/.goreleaser.yml b/proxy/wdaproxy-master/wdaproxy-master/.goreleaser.yml deleted file mode 100644 index ca890891..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/.goreleaser.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This is an example goreleaser.yaml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com -before: - hooks: - # you may remove this if you don't use vgo - - go mod tidy - # you may remove this if you don't need go generate - - go generate ./web -builds: - - env: - - CGO_ENABLED=0 - main: . - flags: - - -tags=vfs - goos: - - darwin - goarch: - - amd64 -brews: - - - tap: - owner: openatx - name: homebrew-tap - folder: Formula - dependencies: - - name: usbmuxd diff --git a/proxy/wdaproxy-master/wdaproxy-master/.travis.yml b/proxy/wdaproxy-master/wdaproxy-master/.travis.yml deleted file mode 100644 index 07f716d9..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go -go: -- 1.13.x -install: go get -v -t -script: -- go generate ./web -- go test -v -after_success: - test -n "$TRAVIS_TAG" && curl -sL https://git.io/goreleaser | bash diff --git a/proxy/wdaproxy-master/wdaproxy-master/API.md b/proxy/wdaproxy-master/wdaproxy-master/API.md deleted file mode 100644 index 52cae4b0..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/API.md +++ /dev/null @@ -1,87 +0,0 @@ -# Interface -API which offer to FE - -## File operation -Get file list - -``` -$ curl -X GET /api/v1/files -{ - "success": true, - "value": [{ - "name": "a/f.txt" - }, { - "name": "b/f.py" - }] -} -``` - -Delete file - -``` -$ curl -X DELETE /api/v1/files/{name} -{ - "success": true, - "description": "file deleted" -} -``` - -Add file - -``` -$ curl -X POST /api/v1/files <` to `/` -- [x] Add the missing Index page -- [x] Support Package management API -- [x] Support launch WDA -- [x] iOS device remote control -- [x] Support Appium Desktop (Beta) - -# Installl -``` -$ brew install openatx/tap/wdaproxy -``` - -# Usage -Simple run - -``` -$ wdaproxy -p 8100 -u $UDID -``` - -Run with WDA - -``` -$ wdaproxy -W ../WebDriverAgent -``` - -For more run `wdaproxy -h` - -Strong recommended use [python facebook-wda](https://github.com/openatx/facebook-wda) to write tests. -But if you have to use appium. Just keep reading. - -## Simulate appium server -Since WDA implements WebDriver protocol. -Even through many API not implemented. But it still works. `wdaproxy` implemented a few api listed bellow. - -- wdaproxy "/wd/hubs/sessions" -- wdaproxy "/wd/hubs/session/$sessionId/window/current/size" - -Launch wdaproxy with command `wdaproxy -p 8100 -u $UDID` - -Here is sample `Python-Appium-Client` code. - -```python -from appium import webdriver -import time - -driver = webdriver.Remote("http://127.0.0.1:8100/wd/hub", {"bundleId": "com.apple.Preferences"}) - -def wait_element(xpath, timeout=10): - print("Wait ELEMENT", xpath) - deadline = time.time() + timeout - while time.time() <= deadline: - el = driver.find_element_by_xpath(xpath) - if el: - return el - time.sleep(.2) - raise RuntimeError("Element for " + xpath + " not found") - -wait_element('//XCUIElementTypeCell[@name="蓝牙"]').click() -``` - -Not working well code - -```python -driver.background_app(3) -driver.implicitly_wait(30) -driver.get_window_rect() -# many a lot. -``` - -# Extended API -Package install - -``` -$ curl -X POST -F file=@some.ipa http://localhost:8100/api/v1/packages -$ curl -X POST -F url="http://somehost.com/some.ipa" http://localhost:8100/api/v1/packages -``` - -Package uninstall - -``` -$ curl -X DELETE http://localhost:8100/api/v1/packages/${BUNDLE_ID} -``` - -Package list (parse from `ideviceinstaller -l`) - -``` -$ curl -X GET http://localhost:8100/api/v1/packages -``` - -# For developer -First checkout this repository - -```bash -git clone https://github.com/openatx/wdaproxy $GOPATH/src/github.com/openatx/wdaproxy -cd $GOPATH/src/github.com/openatx/wdaproxy -``` - -Update golang vendor -```bash -brew install glide -glide up -``` - -Package web resources into binary - -```bash -go generate ./web -go build -tags vfs -``` - -# LICENSE -Under [MIT](LICENSE) diff --git a/proxy/wdaproxy-master/wdaproxy-master/connector/connector.go b/proxy/wdaproxy-master/wdaproxy-master/connector/connector.go deleted file mode 100644 index a5e73238..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/connector/connector.go +++ /dev/null @@ -1,169 +0,0 @@ -package connector - -import ( - "fmt" - "net/url" - "os" - "runtime" - "strconv" - "time" - - "github.com/codeskyblue/muuid" - "github.com/gorilla/websocket" - "github.com/pkg/errors" - qlog "github.com/gobuild/log" -) - -var log = qlog.New(os.Stdout, "", qlog.Llevel|qlog.Lshortfile|qlog.LstdFlags) - -const ( - ActionInit = "init" - ActionDeviceAdd = "addDevice" - ActionDeviceRemove = "removeDevice" - ActionDeviceRelease = "releaseDevice" -) - -type Connector struct { - ws *websocket.Conn - host string - listenPort int - msgC chan interface{} - - Id string `json:"id"` - Name string `json:"name"` - OS string `json:"os"` - Arch string `json:"arch"` - Group string `json:"group"` - Address string `json:"address"` - - RemoteIp string `json:"-"` - devices map[string]interface{} -} - -func New(host string, group string, listenPort int) *Connector { - c := &Connector{ - host: host, - msgC: make(chan interface{}), - Group: group, - listenPort: listenPort, - Id: muuid.UUID() + ":" + strconv.Itoa(listenPort), - OS: runtime.GOOS, - Arch: runtime.GOARCH, - devices: make(map[string]interface{}), - } - c.Name, _ = os.Hostname() - return c -} - -func (w *Connector) KeepOnline() { - if w.host == "" { - return - } - for { - w.keepOnline() - log.Println("Retry connect to center after 3.0s") - time.Sleep(3 * time.Second) - } -} - -func (w *Connector) keepOnline() error { - u := url.URL{ - Scheme: "ws", - Host: w.host, - Path: "/websocket", - } - log.Printf("connecting to %s", u.String()) - - ws, _, err := websocket.DefaultDialer.Dial(u.String(), nil) - if err != nil { - return errors.Wrap(err, "dial websocket") - } - w.ws = ws - defer ws.Close() - - // Step 1: get remote ip - var t = struct { - RemoteIp string `json:"remoteIp"` - }{} - if err := ws.ReadJSON(&t); err != nil { - return errors.Wrap(err, "read remoteIp") - } - w.RemoteIp = t.RemoteIp - w.Address = fmt.Sprintf("http://%s:%d", t.RemoteIp, w.listenPort) - - // Step 2: send provider info - err = ws.WriteJSON(map[string]interface{}{ - "type": ActionInit, - "data": w, - }) - if err != nil { - return errors.Wrap(err, "send init data") - } - - done := make(chan bool, 1) - go w.keepPing(done) - defer func() { - done <- true - }() - - // resend registed device data - for _, device := range w.devices { - w.Do(ActionDeviceAdd, device) - } - - for { - _, message, err := ws.ReadMessage() - if err != nil { - return errors.Wrap(err, "read message") - } - log.Printf("recv: %s", message) - } - return nil -} - -func (w *Connector) keepPing(done chan bool) { - ticker := time.NewTicker(20 * time.Second) - defer ticker.Stop() - for { - select { - case <-ticker.C: - if err := w.ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil { - log.Warnf("send ping: %v", err) - return - } - case msg := <-w.msgC: - if err := w.ws.WriteJSON(msg); err != nil { - log.Warnf("send data: %v", err) - return - } - case <-done: - return - } - } -} - -func (w *Connector) WriteJSON(v interface{}) { - w.msgC <- v -} - -func (w *Connector) Do(action string, data interface{}) { - w.msgC <- map[string]interface{}{ - "type": action, - "data": data, - } -} - -func (w *Connector) AddDevice(id string, device interface{}) { - w.Do(ActionDeviceAdd, device) - w.devices[id] = device -} - -// func (w *Connector) ReleaseDevice(serial string, oneOffToken string) { -// w.msgC <- map[string]interface{}{ -// "type": "releaseDevice", -// "data": map[string]string{ -// "serial": serial, -// "oneOffToken": oneOffToken, -// }, -// } -// } diff --git a/proxy/wdaproxy-master/wdaproxy-master/go.mod b/proxy/wdaproxy-master/wdaproxy-master/go.mod deleted file mode 100644 index b33eb947..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module github.com/openatx/wdaproxy - -go 1.13 - -require ( - github.com/codeskyblue/muuid v0.0.0-20170401091614-44f8dfd4b3a9 - github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9 - github.com/gobuild/log v1.0.0 - github.com/gorilla/mux v1.8.0 - github.com/gorilla/websocket v1.4.2 - github.com/mash/go-accesslog v1.2.0 - github.com/ogier/pflag v0.0.1 - github.com/pkg/errors v0.9.1 - github.com/satori/go.uuid v1.2.0 // indirect - github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect - github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 - github.com/stretchr/testify v1.6.1 // indirect - golang.org/x/tools v0.0.0-20201121010211-780cb80bd7fb // indirect - howett.net/plist v0.0.0-20201026045517-117a925f2150 -) - -replace github.com/qiniu/log => github.com/gobuild/log v0.1.0 diff --git a/proxy/wdaproxy-master/wdaproxy-master/httplog.go b/proxy/wdaproxy-master/wdaproxy-master/httplog.go deleted file mode 100644 index 0cb43065..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/httplog.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "fmt" - "log" - "os" - - accesslog "github.com/mash/go-accesslog" -) - -var logger = log.New(os.Stdout, "\033[0;32m[", log.Ltime) - -type HTTPLogger struct { -} - -// Example -// [I 170227 14:47:16 web:1946] 200 GET /api/v1/devices (10.240.185.65) 28.00ms -func (l HTTPLogger) Log(record accesslog.LogRecord) { - logger.Println(fmt.Sprintf("\b] \033[0;m%d %s %s (%s) %.2fms", record.Status, record.Method, record.Uri, record.Ip, - float64(record.ElapsedTime.Nanoseconds()/1000)/1000.0)) -} diff --git a/proxy/wdaproxy-master/wdaproxy-master/installer.go b/proxy/wdaproxy-master/wdaproxy-master/installer.go deleted file mode 100644 index e8a89e50..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/installer.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "bytes" - "os/exec" - - plist "howett.net/plist" -) - -type Package struct { - Name string `plist:"CFBundleDisplayName" json:"name"` - BundleId string `plist:"CFBundleIdentifier" json:"bundleId"` - Version string `plist:"CFBundleVersion" json:"version"` - MinOSVersion string `plist:"MinimumOSVersion" json:"miniOSVersion"` - SupportedDevices []string `plist:"UISupportedDevices" json:"UISupportedDevices"` -} - -func ListPackages(udid string) (pkgs []Package, err error) { - pkgs = make([]Package, 0) - c := exec.Command("ideviceinstaller", "--udid", udid, "-l", "-o", "xml") - data, err := c.Output() - if err != nil { - return nil, err - } - err = plist.NewDecoder(bytes.NewReader(data)).Decode(&pkgs) - return -} - -func UninstallPackage(udid, bundleId string) (output string, err error) { - c := exec.Command("ideviceinstaller", "--udid", udid, "--uninstall", bundleId) - data, err := c.CombinedOutput() - return string(data), err -} diff --git a/proxy/wdaproxy-master/wdaproxy-master/ioskit.go b/proxy/wdaproxy-master/wdaproxy-master/ioskit.go deleted file mode 100644 index 432490cd..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/ioskit.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "bytes" - "os/exec" - - plist "howett.net/plist" -) - -type DeviceInfo struct { - MacAddress string `plist:"EthernetAddress" json:"-"` // eg: a0:11:28:31:42:21 - ProductName string `plist:"ProductName" json:"-"` // eg: iPhone OS - HardwareModel string `plist:"HardwareModel" json:"-"` // eg: N56AP - ProductType string `plist:"ProductType" json:"model"` // eg: iPhone7,1 - Version string `plist:"ProductVersion" json:"version"` // eg: 10.2 - CPUArchitecture string `plist:"CPUArchitecture" json:"abi"` // eg: arm64 - Udid string `plist:"UniqueDeviceID" json:"serial"` - Manufacturer string `json:"manufacturer"` -} - -func GetDeviceInfo(udid string) (v DeviceInfo, err error) { - c := exec.Command("ideviceinfo", "--udid", udid, "--xml") - output, err := c.Output() - if err != nil { - return - } - v.Manufacturer = "Apple" - err = plist.NewDecoder(bytes.NewReader(output)).Decode(&v) - return -} diff --git a/proxy/wdaproxy-master/wdaproxy-master/main.go b/proxy/wdaproxy-master/wdaproxy-master/main.go deleted file mode 100644 index 4bc662ae..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/main.go +++ /dev/null @@ -1,216 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "os" - "os/exec" - "path/filepath" - "strconv" - "strings" - - "github.com/facebookgo/freeport" - "github.com/gobuild/log" - "github.com/gorilla/mux" - accesslog "github.com/mash/go-accesslog" - flag "github.com/ogier/pflag" - "github.com/openatx/wdaproxy/web" - _ "github.com/shurcooL/vfsgen" -) - -func init() { - log.SetFlags(log.Lshortfile | log.LstdFlags) -} - -var ( - version = "develop" - lisPort = 8100 - pWda string - udid string - yosemiteServer string - yosemiteGroup string - debug bool - - rt = mux.NewRouter() - udidNames = map[string]string{} -) - -type statusResp struct { - Value map[string]interface{} `json:"value,omitempty"` - SessionId string `json:"sessionId,omitempty"` - Status int `json:"status"` -} - -func getUdid() string { - if udid != "" { - return udid - } - output, err := exec.Command("idevice_id", "-l").Output() - if err != nil { - panic(err) - } - return strings.TrimSpace(string(output)) -} - -func assetsContent(name string) string { - fd, err := web.Assets.Open(name) - if err != nil { - panic(err) - } - data, err := ioutil.ReadAll(fd) - if err != nil { - panic(err) - } - return string(data) -} - -type Device struct { - Udid string `json:"serial"` - Manufacturer string `json:"manufacturer"` -} - -// LocalIP returns the non loopback local IP of the host -func LocalIP() string { - addrs, err := net.InterfaceAddrs() - if err != nil { - return "" - } - for _, address := range addrs { - // check the address type and if it is not a loopback the display it - if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - return ipnet.IP.String() - } - } - } - return "" -} - -func main() { - showVer := flag.BoolP("version", "v", false, "Print version") - flag.IntVarP(&lisPort, "port", "p", 8100, "Proxy listen port") - flag.StringVarP(&udid, "udid", "u", "", "device udid") - flag.StringVarP(&pWda, "wda", "W", "", "WebDriverAgent project directory [optional]") - flag.BoolVarP(&debug, "debug", "d", false, "Open debug mode") - - // flag.StringVarP(&yosemiteServer, "yosemite-server", "S", - // os.Getenv("YOSEMITE_SERVER"), - // "server center(not open source yet") - // flag.StringVarP(&yosemiteGroup, "yosemite-group", "G", - // "everyone", - // "server center group") - flag.Parse() - if udid == "" { - udid = getUdid() - } - - if *showVer { - println(version) - return - } - - lis, err := net.Listen("tcp", ":"+strconv.Itoa(lisPort)) - if err != nil { - log.Fatal(err) - } - - // if yosemiteServer != "" { - // mockIOSProvider() - // } - - errC := make(chan error) - freePort, err := freeport.Get() - if err != nil { - log.Fatal(err) - } - log.Printf("freeport %d", freePort) - - go func() { - log.Printf("launch tcp-proxy, listen on %d", lisPort) - targetURL, _ := url.Parse("http://127.0.0.1:" + strconv.Itoa(freePort)) - rt.HandleFunc("/wd/hub/{path:.*}", NewAppiumProxyHandlerFunc(targetURL)) - rt.HandleFunc("/{path:.*}", NewReverseProxyHandlerFunc(targetURL)) - errC <- http.Serve(lis, accesslog.NewLoggingHandler(rt, HTTPLogger{})) - }() - go func() { - log.Printf("launch iproxy (udid: %s)", strconv.Quote(udid)) - c := exec.Command("iproxy", strconv.Itoa(freePort), "8100") - if udid != "" { - c.Args = append(c.Args, udid) - } - errC <- c.Run() - }() - go func(udid string) { - if pWda == "" { - return - } - // device name - nameBytes, _ := exec.Command("idevicename", "-u", udid).Output() - deviceName := strings.TrimSpace(string(nameBytes)) - udidNames[udid] = deviceName - log.Printf("device name: %s", deviceName) - - log.Printf("launch WebDriverAgent(dir=%s)", pWda) - c := exec.Command("xcodebuild", - "-verbose", - "-project", "WebDriverAgent.xcodeproj", - "-scheme", "WebDriverAgentRunner", - "-destination", "id="+udid, "test-without-building") // test-without-building - c.Dir, _ = filepath.Abs(pWda) - // Test Suite 'All tests' started at 2017-02-27 15:55:35.263 - // Test Suite 'WebDriverAgentRunner.xctest' started at 2017-02-27 15:55:35.266 - // Test Suite 'UITestingUITests' started at 2017-02-27 15:55:35.267 - // Test Case '-[UITestingUITests testRunner]' started. - // t = 0.00s Start Test at 2017-02-27 15:55:35.270 - // t = 0.01s Set Up - pipeReader, writer := io.Pipe() - c.Stdout = writer - c.Stderr = writer - c.Stdin = os.Stdin - - bufrd := bufio.NewReader(pipeReader) - if err = c.Start(); err != nil { - log.Fatal(err) - } - - // close writers when xcodebuild exit - go func() { - c.Wait() - writer.Close() - }() - - lineStr := "" - for { - line, isPrefix, err := bufrd.ReadLine() - if isPrefix { - lineStr = lineStr + string(line) - continue - } else { - lineStr = string(line) - } - lineStr = strings.TrimSpace(string(line)) - - if debug { - fmt.Printf("[WDA] %s\n", lineStr) - } - if err != nil { - log.Fatal("[WDA] exit", err) - } - if strings.Contains(lineStr, "Successfully wrote Manifest cache to") { - log.Println("[WDA] test ipa successfully generated") - } - if strings.HasPrefix(lineStr, "Test Case '-[UITestingUITests testRunner]' started") { - log.Println("[WDA] successfully started") - } - lineStr = "" // reset str - } - }(udid) - - log.Printf("Open webbrower with http://%s:%d", LocalIP(), lisPort) - log.Fatal(<-errC) -} diff --git a/proxy/wdaproxy-master/wdaproxy-master/provider.go b/proxy/wdaproxy-master/wdaproxy-master/provider.go deleted file mode 100644 index 3c1c44ef..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/provider.go +++ /dev/null @@ -1,239 +0,0 @@ -package main - -import ( - "encoding/json" - "errors" - "fmt" - "html/template" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "time" - - "github.com/gorilla/mux" - "github.com/gorilla/websocket" - "github.com/openatx/wdaproxy/connector" - "github.com/openatx/wdaproxy/web" - "github.com/gobuild/log" -) - -var ( - upgrader = websocket.Upgrader{ - ReadBufferSize: 1024, - WriteBufferSize: 1024, - } -) - -func init() { - rt.HandleFunc("/devices/{udid}", func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, "/", 302) - // io.WriteString(w, "Not finished yet") - }) - - rt.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - t := template.Must(template.New("index").Parse(assetsContent("/index.html"))) - t.Execute(w, nil) - }) - - rt.HandleFunc("/packages", func(w http.ResponseWriter, r *http.Request) { - t := template.Must(template.New("pkgs").Delims("[[", "]]").Parse(assetsContent("/packages.html"))) - t.Execute(w, nil) - }) - - rt.HandleFunc("/remote", func(w http.ResponseWriter, r *http.Request) { - t := template.Must(template.New("pkgs").Delims("[[", "]]").Parse(assetsContent("/remote-control.html"))) - t.Execute(w, nil) - }) - - rt.PathPrefix("/res/").Handler(http.StripPrefix("/res/", http.FileServer(web.Assets))) - rt.PathPrefix("/recorddata/").Handler(http.StripPrefix("/recorddata/", http.FileServer(http.Dir("./recorddata")))) - - rt.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { - favicon, _ := web.Assets.Open("images/favicon.ico") - http.ServeContent(w, r, "favicon.ico", time.Now(), favicon) - }) - - v1Rounter(rt) -} - -func v1Rounter(rt *mux.Router) { - rt.HandleFunc("/api/v1/packages", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - pkgs, err := ListPackages(udid) - if err != nil { - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": false, - "description": err.Error(), - }) - return - } - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": true, - "value": pkgs, - }) - }).Methods("GET") - - rt.HandleFunc("/api/v1/packages/{bundleId}", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - bundleId := mux.Vars(r)["bundleId"] - output, err := UninstallPackage(udid, bundleId) - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": err == nil, - "description": output, - }) - }).Methods("DELETE") - - rt.HandleFunc("/api/v1/packages", func(w http.ResponseWriter, r *http.Request) { - r.ParseMultipartForm(0) - defer r.MultipartForm.RemoveAll() - w.Header().Set("Content-Type", "application/json; charset=utf-8") - - renderError := func(err error, description string) { - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": false, - "description": fmt.Sprintf("%s: %v", description, err), - }) - } - var reader io.Reader - url := r.FormValue("url") - if url != "" { - resp, err := http.Get(url) - if err != nil { - renderError(err, "download from url") - return - } - reader = resp.Body - defer resp.Body.Close() - } else { - file, _, err := r.FormFile("file") - if err != nil { - renderError(err, "parse form 'file'") - return - } - reader = file - defer file.Close() - } - os.Mkdir("uploads", 0755) - tmpfile, err := ioutil.TempFile("uploads", "tempipa-") - if err != nil { - renderError(err, "create tmpfile") - return - } - defer os.Remove(tmpfile.Name()) - - log.Println("[pkg] create tmpfile", tmpfile.Name()) - _, err = io.Copy(tmpfile, reader) - if err != nil { - renderError(err, "read upload file") - return - } - if err := tmpfile.Close(); err != nil { - renderError(err, "finish write tmpfile") - return - } - log.Println("[pkg] install ipa") - cmd := exec.Command("ideviceinstaller", "--udid", udid, "-i", tmpfile.Name()) - output, err := cmd.CombinedOutput() - if err != nil { - renderError(errors.New(string(output)), "install ipa") - return - } - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": true, - "description": "Successfully installed ipa", - "value": string(output), - }) - }).Methods("POST") - - rt.HandleFunc("/api/v1/records", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - if r.Method == "POST" { - os.MkdirAll("./recorddata/20170603-test", 0755) - err := launchXrecord("./recorddata/20170603-test/camera.mp4") - if err != nil { - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": false, - "description": "Launch xrecord failed: " + err.Error(), - }) - } else { - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": true, - "description": "Record started", - }) - } - } else { - if xrecordCmd != nil && xrecordCmd.Process != nil { - xrecordCmd.Process.Signal(os.Interrupt) - } - select { - case <-GoFunc(xrecordCmd.Wait): - case <-time.After(5 * time.Second): - xrecordCmd.Process.Kill() - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": false, - "description": "xrecord handle Ctrl-C longer than 5 second", - }) - return - } - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": true, - "description": "Record stopped", - }) - } - }).Methods("POST", "DELETE") -} - -func mockIOSProvider() { - c := connector.New(yosemiteServer, yosemiteGroup, lisPort) - go c.KeepOnline() - - device, err := GetDeviceInfo(udid) - if err != nil { - log.Fatal(err) - } - - c.AddDevice(device.Udid, device) - // c.WriteJSON(map[string]interface{}{ - // "type": "addDevice", - // "data": device, - // }) - rt.HandleFunc("/api/devices/{udid}/remoteConnect", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - if r.Method == "POST" { - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": true, - "description": "notice this is mock data", - "remoteConnectUrl": fmt.Sprintf("http://%s:%d/", c.RemoteIp, lisPort), - }) - } - if r.Method == "DELETE" { - json.NewEncoder(w).Encode(map[string]interface{}{ - "success": true, - "description": "Device remote disconnected successfully", - }) - } - }).Methods("POST", "DELETE") -} - -var xrecordCmd *exec.Cmd - -func launchXrecord(output string) error { - rpath, err := exec.LookPath("xrecord") - if err != nil { - return err - } - xrecordCmd = exec.Command(rpath, "-i", "0x14100000046d082d", "-o", output, "-f") - xrecordCmd.Stdout = os.Stdout - xrecordCmd.Stderr = os.Stderr - return xrecordCmd.Start() -} - -func GoFunc(f func() error) chan error { - errc := make(chan error) - go func() { - errc <- f() - }() - return errc -} diff --git a/proxy/wdaproxy-master/wdaproxy-master/revproxy.go b/proxy/wdaproxy-master/wdaproxy-master/revproxy.go deleted file mode 100644 index ff6e63f3..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/revproxy.go +++ /dev/null @@ -1,94 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "io" - "io/ioutil" - "log" - "net/http" - "net/http/httputil" - "net/url" - "strconv" - "strings" - - "github.com/gorilla/mux" -) - -type transport struct { - http.RoundTripper -} - -func (t *transport) RoundTrip(req *http.Request) (resp *http.Response, err error) { - // rewrite url - if strings.HasPrefix(req.RequestURI, "/origin/") { - req.URL.Path = req.RequestURI[len("/origin"):] - return t.RoundTripper.RoundTrip(req) - } - - // request - resp, err = t.RoundTripper.RoundTrip(req) - if err != nil { - return nil, err - } - - // rewrite body - if req.URL.Path == "/status" { - jsonResp := &statusResp{} - err = json.NewDecoder(resp.Body).Decode(jsonResp) - if err != nil { - return nil, err - } - resp.Body.Close() - jsonResp.Value["device"] = map[string]interface{}{ - "udid": udid, - "name": udidNames[udid], - } - data, _ := json.Marshal(jsonResp) - // update body and fix length - resp.Body = ioutil.NopCloser(bytes.NewReader(data)) - resp.ContentLength = int64(len(data)) - resp.Header.Set("Content-Length", strconv.Itoa(len(data))) - return resp, nil - } - return resp, nil -} - -func NewReverseProxyHandlerFunc(targetURL *url.URL) http.HandlerFunc { - httpProxy := httputil.NewSingleHostReverseProxy(targetURL) - httpProxy.Transport = &transport{http.DefaultTransport} - return func(rw http.ResponseWriter, r *http.Request) { - httpProxy.ServeHTTP(rw, r) - } -} - -type fakeProxy struct { -} - -func (p *fakeProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { - log.Println("FAKE", r.RequestURI) - log.Println("P", r.URL.Path) - io.WriteString(w, "Fake") -} - -func NewAppiumProxyHandlerFunc(targetURL *url.URL) http.HandlerFunc { - httpProxy := httputil.NewSingleHostReverseProxy(targetURL) - rt := mux.NewRouter() - rt.HandleFunc("/wd/hub/sessions", func(w http.ResponseWriter, r *http.Request) { - data, _ := json.MarshalIndent(map[string]interface{}{ - "status": 0, - "value": []string{}, - "sessionId": nil, - }, "", " ") - w.Header().Set("Content-Type", "application/json") - w.Header().Set("Content-Length", strconv.Itoa(len(data))) - w.Write(data) - }) - rt.HandleFunc("/wd/hub/session/{sessionId}/window/current/size", func(w http.ResponseWriter, r *http.Request) { - r.URL.Path = strings.Replace(r.URL.Path, "/current/size", "/size", -1) - r.URL.Path = r.URL.Path[len("/wd/hub"):] - httpProxy.ServeHTTP(w, r) - }) - rt.Handle("/wd/hub/{subpath:.*}", http.StripPrefix("/wd/hub", httpProxy)) - return rt.ServeHTTP -} diff --git a/proxy/wdaproxy-master/wdaproxy-master/web/assets/images/favicon.ico b/proxy/wdaproxy-master/wdaproxy-master/web/assets/images/favicon.ico deleted file mode 100644 index 23742c2edb86c8e51034e980ef20be64df3b59e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21662 zcmeI4dvp}nea9~bOl)HdERa@dTBm8C)NM}dMVnmB}6bdr*2xO*iDaP z6UQK40qg>{d+d|6=^yoJPis3(P3<%`5X*Y5-fyi|s}~?Jl1!YoBmo1u{r+Zl#A+=W zgpsix!};jmxpSYN`@17{4+qBP;E%_{@bk-TZ$4uwjIk8}MeGoua_!31lgapLHdnF) zZoz#T5Wyp0ANXf*7`z$FKZVo|l0ahn*nK&ri@<|``uPz!2CBfj;D=xpxEqY>V=~q` z(LODf5Hqk^t7v|yU^VzLXf~TeADYco7tQ8sZn4zHsMAuE4deM))GIcdE6Cp_kOh2z z`gk1WwEhY(p!ZXQw$#2}OU>pQjy`^k=j3V~SZK_L(wlX~&moroU5lmiyT~_MEL9h2 z4OVLtXaix;0U`-dSsT{b2*@2dq_$NTz-5cYaM6f*t$_M5`sj?yx5xUZM!U+xn1jt~ ztr^)jn%`%6#e5j!--i25pqbWVwKj8`Eetv*NCfpeVr{8CL1h!^hx|2=<3Y@48@L-7 z^ZZN{(HSzp*na?CftL%q7h2y$)-ySE^_Zl14E-G3XUvz<$-J(N6Cy`;P)GYk`);>K zKUe6nN9VG-%W4hfBb{T+e=;1|Yn~y*djTBLo_{(&c6$x8+x33nd>P!-Pfa(*UeddufgBalStCERzU#dV zKX!ZQPMfXfHM_lSip7lKB|g<0{T6P%?Q$K{{Lnf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ap(hi(@NJbl4XwC+G3|62D)@{?a~T-xpC6+IPO4Jw$m - - - - - WDAProxy Index - - - - -

WDA Proxy

-
- -

-  
- - - - - \ No newline at end of file diff --git a/proxy/wdaproxy-master/wdaproxy-master/web/assets/packages.html b/proxy/wdaproxy-master/wdaproxy-master/web/assets/packages.html deleted file mode 100644 index b9dee210..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/web/assets/packages.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - App Manager - - - - -

Packages

-
-
  • - {{v.name}} - -
  • -
    - - - - - - diff --git a/proxy/wdaproxy-master/wdaproxy-master/web/assets/remote-control.html b/proxy/wdaproxy-master/wdaproxy-master/web/assets/remote-control.html deleted file mode 100644 index 103c0b27..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/web/assets/remote-control.html +++ /dev/null @@ -1,629 +0,0 @@ - - - - - - Remote Control - - - - - - - - -
    -
    -
    -
    - - - -
    -
    -
    -

    {{device.name}}

    -
    -
    -
    -

    设备详情

    -
    - - - - - - - - - - - - - - - - - - - -
    UDID
    ScreenSizex
    SessionId - - -
    RefreshCount
    -
    -
    - -
    -
    -
    - - - - - -
    -
    - -
    -
    -
    - - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    - - - - - - - - - - \ No newline at end of file diff --git a/proxy/wdaproxy-master/wdaproxy-master/web/assets_dev.go b/proxy/wdaproxy-master/wdaproxy-master/web/assets_dev.go deleted file mode 100644 index bc05ef31..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/web/assets_dev.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !vfs -//go:generate go run assets_generate.go - -package web - -import "net/http" - -// Assets contains project assets. -var Assets http.FileSystem = http.Dir("web/assets") diff --git a/proxy/wdaproxy-master/wdaproxy-master/web/assets_generate.go b/proxy/wdaproxy-master/wdaproxy-master/web/assets_generate.go deleted file mode 100644 index 0dae7d0b..00000000 --- a/proxy/wdaproxy-master/wdaproxy-master/web/assets_generate.go +++ /dev/null @@ -1,23 +0,0 @@ -// +build ignore - -package main - -import ( - "log" - "net/http" - - "github.com/shurcooL/vfsgen" -) - -func main() { - var fs http.FileSystem = http.Dir("assets") - - err := vfsgen.Generate(fs, vfsgen.Options{ - PackageName: "web", - BuildTags: "vfs", - VariableName: "Assets", - }) - if err != nil { - log.Fatalln(err) - } -}