Skip to content
Zap Internet

Zap Internet

Immerse Yourself in Gaming, Embrace the Realm of Smart Homes, and Explore the Universe of Gadgets

Primary Menu
  • Home
  • Gaming Corner
  • Smart Home & Internet
  • Gadgets For Life
  • Application Zone
  • Contact Us
  • Home
  • Latest
  • iOS Network monitor/interceptor framework written in Swift

iOS Network monitor/interceptor framework written in Swift

Ivan Perisic 3 min read

Building a network monitoring app isn’t a new idea. In fact, there are a lot of network monitoring/intercepting tools available, from the open source libpcap, to commercial solutions from firms like NetStumbler or CoreStumbler. All of these tools have a significant drawback: they rely on a command line interface to get the job done. The problem with a CLI is that it is very hard to maintain, and you have to install it on every computer that you need to monitor network traffic.

There are many things that make iOS great for productive development. From the Outline tab, to Pinned Tabs, to Split View and more. However, one of the most useful and most overlooked features of iOS is the networking functionality and APIs.

The only thing I know about this project is that it is a tool to intercept and monitor packet data on a network. I don’t know a lot about the tool itself, it’s purpose or even if it already exists. Anyways, this is a hypothetical project that I’m thinking of creating as a developer. I’m not really sure where I would want to use it. I guess it could be a tool to monitor Wifi traffic, maybe as a debugging tool for an app.

NetShears

NetShears is a Swift-based network interceptor framework.

NetShears has a Request interceptor method for modifying HTTP/HTTPS requests before they are delivered. This method may be used to add headers to a request, add a log trail, or even redirect requests.

Features

  • [x] Intercept request headers for HTTP/HTTPS
  • [x] Intercept endpoints for HTTP/HTTPS requests
  • [x] Examine the traffic records
  • [ ] Intercept the content of an HTTP/HTTPS response
  • [ ] Disallow HTTP requests

How does it work?

The URLProtocol is swizzled by NetShears.

How to Make Use of

In did, use startRecording() to start NetShears. FinishLaunchingWithOptions

import NetShears func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { NetShears.startRecording() }

Interceptor

Changes to the header:

if header = HeaderModifyModel; if header = HeaderModifyModel; if header (key: “API-Version”, value: “123”) requestEvaluatorModifierHeader(header: header) NetShears.shared.modify let headerModifier = RequestEvaluatorModifierHeader(header: header) (headerModifier is a modifier)

Modification of the endpoint:

if endpoint = RedirectedRequestModel(originalUrl: “/register”, redirectUrl: “/login”), then NetShears.shared.modify endpointModifier = RequestEvaluatorModifierEndpoint(redirectedRequest: endpoint) (endpointModifier) (modifier) (modifier) (modifier) (modifier) (modifier

To display network traffic in your app, just use the presentNetworkMonitor function, and a view with traffic logs will appear.

NetShears.shared.presentNetworkMonitor()

Icon

gRPC

By building the Request and Response using GRPC models, you can see gRPC calls:

addGRPC(url: String, host: String, request: String) is a public function. Object: Is it data?, or is it a response? success: Bool, statusCode: Int, status: Int, status: Int, status: Int, status: Int, status: Int, status: Int, status: In HPACKHeadersRequest: [String: String]?, HPACKHeadersResponse: [String: String]?) Message: String?, duration: Double?, HPACKHeadersRequest: [String: String]?, HPACKHeadersResponse: [String: String]?)

Example

// 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 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 is a program that allows you to manage your

Make a file called Package.swift.

import swift-tools-version:5.0 package = Package( name: “YourProject”, dependencies: [.package(url: “https://github.com/divar-ir/NetShears.git”, from: “1.0.0”), ], targets: [.target(name: “YourProject”, dependencies: [“NetShears”]) ] ) $ swift build

CocoaPods

use frameworks is a podfile! do pod ‘NetShears’ end target ‘YOUR TARGET NAME’

Replace YOUR TARGET NAME with YOUR TARGET NAME, and then type: in the Podfile directory:

$ install pod

GitHub

https://github.com/divar-ir/NetShears

Ever wanted to see what a user’s iPhone or iPad is doing behind the scenes on a network that uses a VPN? Well, it is possible, but not without some effort. For some time now I have had a solution that I have been using to extract the name of the VPN being used and the network interface being used.. Read more about continuously check internet connection swift and let us know what you think.

Related Tags

  • willpresentnotification not called in foreground
  • nwpathmonitor not working
  • nwpathmonitor swift
  • swift reachability ios 13
  • how to check internet connection in ios programmatically

Continue Reading

Previous: Ñ ñ | 5 Best Ways to Make Spanish n With a Tilde On Keyboard
Next: The Best Innovative Gadgets To Look Forward To In 2022

Tech Articles

Enable Themes on iMovie hearing exsolarwinds solarwinds 1

Enable Themes on iMovie

Emoji Cleanup and Removal for iPhone Users inside world wide consortiumlapowskyprotocol 2

Emoji Cleanup and Removal for iPhone Users

Take a video without a audio 3

Take a video without a audio

Why you should disable your iPhone hotspot 4

Why you should disable your iPhone hotspot

See who’s listening to your show on Spotify 5

See who’s listening to your show on Spotify

Airpods: the perfect audio experience for any activity 6

Airpods: the perfect audio experience for any activity

Related Stories

Triple 7 Treasures: Unlocking the Luckiest Slot Secrets
3 min read

Triple 7 Treasures: Unlocking the Luckiest Slot Secrets

The Role of a Crypto Market Maker
2 min read

The Role of a Crypto Market Maker

The Average True Range (ATR) – A Non-Directional Indicator for Market Volatility
2 min read

The Average True Range (ATR) – A Non-Directional Indicator for Market Volatility

Online Casino Mistakes to Avoid Making in 2023
3 min read

Online Casino Mistakes to Avoid Making in 2023

Kratom and Anxiety: Can This Herbal Supplement Help?
4 min read

Kratom and Anxiety: Can This Herbal Supplement Help?

How Can you Protect your Devices From the Blink Botnet Malware? the uk cyclops blink russianbacked arstechnica
7 min read

How Can you Protect your Devices From the Blink Botnet Malware?

  • Privacy Policy
  • About Us
  • Terms and Conditions
  • Contact Us
Zap Internet © 2023 All rights reserved.