Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiimrz committed Jul 12, 2021
1 parent 294491c commit 1521f50
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ NetShears adds a Request interceptor mechanisms to be able to modify the HTTP/HT

- [x] Intercept HTTP/HTTPS request header
- [x] Intercept HTTP/HTTPS request endpoint
- [x] View traffic logs
- [ ] Intercept HTTP/HTTPS response body
- [ ] View traffic logs
- [ ] Block HTTP requets

## How it works
Expand All @@ -32,6 +32,9 @@ func application(_ application: UIApplication, didFinishLaunchingWithOptions lau

}
```

## Interceptor

Header Modification:

```swift
Expand All @@ -48,6 +51,51 @@ let endpointModifier = RequestEvaluatorModifierEndpoint(redirectedRequest: endpo
NetShears.shared.modify(modifier: endpointModifier)
```

# Traffic Monitoring

In order to show network traffics in your app simply call presentNetworkMonitor method and then a view will presented containing traffic logs.

<p align="center">
<img src="https://raw.githubusercontent.com/divar-ir/NetShears/master/traffic_screen.png" alt="Icon"/>
</p>

## gRPC

You can view gRPC calls by constructing the Request and Response from GRPC models:

```swift
public func addGRPC(url: String,
host: String,
requestObject: Data?,
responseObject: Data?,
success: Bool,
statusCode: Int,
statusMessage: String?,
duration: Double?,
HPACKHeadersRequest: [String: String]?,
HPACKHeadersResponse: [String: String]?)
```
Example

```swift
// Your GRPC services that is generated from SwiftGRPC
private let client = NoteServiceServiceClient.init(address: "127.0.0.1:12345", secure: false)


func insertNote(note: Note, completion: @escaping(Note?, CallResult?) -> Void) {
_ = try? client.insert(note, completion: { (createdNote, result) in

// Add to atlantis and show it on Proxyman app
NetShears.shared.addGRPC(url: "https://test.com/grpc",
requestObject: try? note.jsonUTF8Data(),
responseObject: try? createdNote.jsonUTF8Data(),
success: result.success,
statusCode: result.statusCode.rawValue,
statusMessage: result.statusMessage)
})
}
```

## Installation

### [Swift Package Manager](https://github.com/apple/swift-package-manager)
Expand Down
Binary file added traffic_screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1521f50

Please sign in to comment.