All Projects → Farfetch → network-monitor-ios

Farfetch / network-monitor-ios

Licence: MIT license
Network Monitor SDK for iOS

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to network-monitor-ios

Oknetworkmonitor
A network monitor for OkHttp.
Stars: ✭ 204 (+191.43%)
Mutual labels:  monitor, network-monitoring
gatus
⛑ Automated service health dashboard
Stars: ✭ 3,018 (+4211.43%)
Mutual labels:  monitor
NetworkAlarm
A tool to monitor local network traffic for possible security vulnerabilities. Warns user against possible nmap scans, Nikto scans, credentials sent in-the-clear, and shellshock attacks. Currently supports live monitoring and network capture (pcap) scanning.
Stars: ✭ 17 (-75.71%)
Mutual labels:  network-monitoring
MockAlamofire
A simple example showing how to override the URLProtocol to return mock data on Alamofire responses. Helpful if you are looking for a simple way to mock an Alamofire response, with out any additional dependencies.
Stars: ✭ 22 (-68.57%)
Mutual labels:  mock
site-monitor
监控网站的可访问性的监控系统
Stars: ✭ 48 (-31.43%)
Mutual labels:  monitor
redis-traffic-stats
Live monitor & analyze Redis queries on your client
Stars: ✭ 84 (+20%)
Mutual labels:  monitor
mock-data
Mock data in PostgreSQL/Greenplum databases
Stars: ✭ 115 (+64.29%)
Mutual labels:  mock
NodePingManage
可用于监控交换机/服务器/防火墙的存活状态的ping监控报警系统
Stars: ✭ 47 (-32.86%)
Mutual labels:  monitor
ivre
Network recon framework. Build your own, self-hosted and fully-controlled alternatives to Shodan / ZoomEye / Censys and GreyNoise, run your Passive DNS service, collect and analyse network intelligence from your sensors, and much more!
Stars: ✭ 2,712 (+3774.29%)
Mutual labels:  network-monitoring
community-id-spec
An open standard for hashing network flows into identifiers, a.k.a "Community IDs".
Stars: ✭ 137 (+95.71%)
Mutual labels:  network-monitoring
ping-exporter
Prometheus Ping exporter
Stars: ✭ 60 (-14.29%)
Mutual labels:  network-monitoring
RouterOS Useful Scripts
MikroTik RouterOS Useful Scripts for various use
Stars: ✭ 66 (-5.71%)
Mutual labels:  network-monitoring
jest-ts-auto-mock
Jest test utility with automatic mock creation for interfaces and classes
Stars: ✭ 150 (+114.29%)
Mutual labels:  mock
racket-mock
Mocking library for Racket
Stars: ✭ 22 (-68.57%)
Mutual labels:  mock
kb-proxy
kb-proxy 是一个可本地部署的、提供代理功能、接口测试管理、支持在线Mock、Host环境管理的在线工具平台。
Stars: ✭ 52 (-25.71%)
Mutual labels:  mock
chrome-extension-mocker
The most convenient tool to mock requests for axios, with built-in Chrome extension support.
Stars: ✭ 37 (-47.14%)
Mutual labels:  mock
masscanned
Let's be scanned. A low-interaction honeypot focused on network scanners and bots. It integrates very well with IVRE to build a self-hosted alternative to GreyNoise.
Stars: ✭ 50 (-28.57%)
Mutual labels:  network-monitoring
redis-healthy
It retrieves metrics, periodically, from Redis (or sentinel) and send them to Logstash
Stars: ✭ 62 (-11.43%)
Mutual labels:  monitor
IOS-CoreBluetooth-Mock
Mocking library for CoreBluetooth framework.
Stars: ✭ 142 (+102.86%)
Mutual labels:  mock
spydriver
🕵️ Lightweight utility to intercept WebDriver and WebElement method calls.
Stars: ✭ 24 (-65.71%)
Mutual labels:  mock

FNMNetworkMonitor

CocoaPods Compatible Supported languages Platform

What is this ?

FNMNetworkMonitor is a swift iOS networking framework that can be used to monitor the network of an iOS app. It makes debugging the network easy, allowing you to pinpoint the root cause of network related problems in your app and share those requests via email. it can also mock network requests, making it much easier to use incomplete APIs or model specific states for unit testing.

Supports Swift 5 and is bridged for Obj-C compatibility.

Preview:

Installation ⚙️

Cocoapods

  • Add pod 'FNMNetworkMonitor' to your Podfile

Swift Package Manager

Usage

There are a few ways to monitor the network:

  1. Monitoring URLSession.shared:
FNMNetworkMonitor.registerToLoadingSystem()
FNMNetworkMonitor.shared.startMonitoring()
  1. Monitoring custom URLSessions by supplying the FNMMonitor URL Protocol:
let sessionConfig = URLSessionConfiguration.ephemeral
sessionConfig.protocolClasses = FNMNetworkMonitor.normalizedURLProtocols()
self.customSession = URLSession(configuration: sessionConfig)
FNMNetworkMonitor.shared.startMonitoring()
  1. You can also take advantage of swizzling the URLSessionConfiguration creation to configure the URL Protocol to all sessions, allowing to monitor 3rd party SDKs too.

Additionally, you can mock certain requests using:

let request = FNMProfileRequest(urlPattern: .dynamicPattern(expression: "*farfetch.*robots"))
let profiles = [FNMProfile(request: request,
                           responses: [request.response(statusCode: 200,
                                            headers: [ "Content-Type": "application/json" ],
                                            responseHolder: .keyValue(value: [ "FieldA": 1 ])
                                            delay: 0.25)])]
FNMNetworkMonitor.shared.configure(profiles: profiles)
FNMNetworkMonitor.shared.startMonitoring()

You can also ignore domains using:

FNMNetworkMonitor.shared.configure(ignoredDomains: ["somedomain.com"])

This won't record nor intercept requests for this domain.

You can also assign priority values to each profile, so that in case of a tie, the profile with the highest priority will be used. Priority is a UInt, being 0 the highest priority and UInt.max the lowest.

let request = FNMProfileRequest(urlPattern: .dynamicPattern(expression: "*farfetch.*robots"))
let profiles = [FNMProfile(request: request,
                           responses: [request.response(statusCode: 200)],
                           priority: 123)]

Make sure to follow steps 1, 2 or 3, depending on the URLSession that runs that particular request.

How to see it all

A debug UI exists that can be used for easy inspection and export of the network:

FNMNetworkMonitor.shared.showDebugListingViewController(presentingNavigationController: self.navigationController)

Generally, the shake gesture is a great way to show/hide the debug view.

Also, different log levels can be applied to see how the requests are navigating through the monitor:

FNMNetworkMonitor.shared.logScope = [.export, .profile, .urlProtocol]

Finally, you can turn on the passive export and the requests will be exported to a json file inside a folder found the Documents application folder.

FNMNetworkMonitor.shared.passiveExportPreference = FNMRecordExporterPreference.on(setting: .unlimited)

Media payload recording

If you want to allocate less memory while using network monitor, you can disable media paylod recording:

FNMNetworkMonitor.shared.recordMediaPayload(false)

Sample app

The project contains a sample app where you can test the tool. You can run the Sample Target Scheme in NetworkMonitor.xcworkspace to see a working example of the framework.

Contributing

Read the Contributing guidelines

Disclaimer

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our Contributor Ownership Statement

Maintainers

List of Maintainers

License

The FNMNetworkMonitor is released under the MIT license. See the LICENSE file for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].