mirror of
https://github.com/blacktop/ipsw.git
synced 2026-06-07 12:27:36 +00:00
43 lines
693 B
Go
43 lines
693 B
Go
package pcap
|
|
|
|
import (
|
|
"context"
|
|
"encoding/hex"
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/blacktop/ipsw/pkg/usb"
|
|
)
|
|
|
|
func TestClient_ReadOPacket(t *testing.T) {
|
|
conn, err := usb.NewConn()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer func(conn *usb.Conn) {
|
|
_ = conn.Close()
|
|
}(conn)
|
|
|
|
devices, err := conn.ListDevices()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
for _, device := range devices {
|
|
cli, err := NewClient(device.SerialNumber)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
err = cli.ReadPacket(context.Background(), "", os.Stdout, func(hdr IOSPacketHeader, data []byte) {
|
|
fmt.Println("\n----")
|
|
fmt.Println(hex.Dump(data))
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_ = cli.Close()
|
|
}
|
|
}
|