A toolkit for Network Extension Framework

Last update: Jun 15, 2022

NEKit

NEKit is deprecated.

It should still work but I'm not intent on maintaining it anymore. It has many flaws and needs a revamp to be a high-quality library.

The architecture of NEKit is not ideal due to my lack of experience when I was writing it. To make it worse, it's not in its most efficient form as there wasn't a good async io library while people abuse it for simple features that should be just implemented directly or use other lightweight libraries.

NEKit is not, was never intended, and probably will never become a library that simply works correctly out-of-the-box without understanding what it is doing under the hook. Through all these years, one thing I learned is for some function this low level, the developer should understand what oneself is doing. I'm always concerned that people are creating apps that slowing down users' phones unnecessarily because of this library and I feel responsible.

Thanks for everyone who has contributed, used or interested in this library.

License

Copyright (c) 2016, Zhuhao Wang All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of NEKit nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

GitHub

https://github.com/zhuhaow/NEKit
Comments
  • 1. carthage update --no-use-binaries --platform mac,ios 报错

    Task failed with exit code 65: /usr/bin/xcrun xcodebuild -workspace /Users/admin/Desktop/NEKit-master-2/Carthage/Checkouts/CocoaLumberjack/Framework/Lumberjack.xcworkspace -scheme CocoaLumberjackSwift-macOS -configuration Release -derivedDataPath /Users/admin/Library/Caches/org.carthage.CarthageKit/DerivedData/CocoaLumberjack/3.3.0 ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build (launched in /Users/admin/Desktop/NEKit-master-2/Carthage/Checkouts/CocoaLumberjack)

    Reviewed by aishuidedabai at 2017-10-09 03:32
  • 2. Task failed with exit code 65:

    *** Building scheme "iOS Framework" in CocoaAsyncSocket.xcodeproj *** Building scheme "CocoaLumberjack-iOS" in Lumberjack.xcworkspace *** Building scheme "CocoaLumberjackSwift-iOS" in Lumberjack.xcworkspace *** Building scheme "MMDB-iOS" in MMDB.xcodeproj Build Failed Task failed with exit code 65: /usr/bin/xcrun xcodebuild -project /Users/dahewang/Desktop/NEKit-master/Carthage/Checkouts/MMDB-Swift/MMDB.xcodeproj -scheme MMDB-iOS -configuration Release -derivedDataPath /Users/dahewang/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B55/MMDB-Swift/0.2.7 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath ./ SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO (launched in /Users/dahewang/Desktop/NEKit-master/Carthage/Checkouts/MMDB-Swift)

    This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/_2/csd853850yl_5cdlh0bv44d40000gn/T/carthage-xcodebuild.kOfuH7.log

    Reviewed by zhuwudan at 2017-11-16 06:24
  • 3. iOS 12 support

    hey zhuhaow,

    i am using nekit within my app and just installed the ios 12 beta. idk if its my app or nekit (i have devs working on it) but the tunnel crashes from time to time. did you had a chance to check if apple changed something and if its needed to optimize nekit towards it?

    best,

    keKs

    Reviewed by itskeKs at 2018-06-07 21:44
  • 4. How can I share wifi with other smartphones while nekit running.

    P1: Phone with nekit running. P2: Phone needs proxy.

    I have try out many times.

    1. Turn on p1 hotspot and then p2 join the network, didn't work.
    2. P1 and p2 join the same wifi, set p2 proxy in wifi settings to p1's ip address (172.16.x.x for me), port of proxy server(9090 for me), didn't work.
    3. Same as [2], but replace p1's ip address to NEIPv4Settings address first (and only, 192.169.89.1 for me)

    I dont set exceptionList, set [""] to matchDomains. And the configuration rule has set

          - 10.0.0.0/8
          - 172.16.0.0/12
          - 192.168.0.0/16
          - 127.0.0.0/8
          - 224.0.0.0/8
          - 169.254.0.0/16
          localhost
    

    with direct.

    Reviewed by chinsyo at 2018-02-08 03:50
  • 5. NSCocoaErrorDomain Code=4097 OC工程导入的nekit报错,帮忙看一下,谢谢了

    我们的项目是用OC 开发的,然后我在我们的项目中使用swift新建了PacketTunnel target,使用Cartfile导入nekit 框架。

    当我在host app中调用 [self.vpnManager.connection startVPNTunnelWithOptions:@{} andReturnError:&connectError];这个方法的时候,报错 There are the error logs

       connection to plug-in <private>(283BAAB5-BE93-42D1-A222-408B36BFAD40) lost
    
       Hub connection error Error Domain=NSCocoaErrorDomain Code=4097 "connection to 
       service named com.tyria.supplyCrate.PacketTunnel" UserInfo= 
       {NSDebugDescription=connection to service named 
       com.tyria.supplyCrate.PacketTunnel}
    
       Failed to start extension com.tyria.supplyCrate.PacketTunnel: Error 
       Domain=NSCocoaErrorDomain Code=4097 "connection to service named 
       com.tyria.supplyCrate.PacketTunnel" UserInfo={NSDebugDescription=connection to 
       service named com.tyria.supplyCrate.PacketTunnel}
    

    我不知道是什么原因导致了这个问题。检查了 info.plist、 entitlements 是没有问题的

    我尝试在host app(OC工程) 中添加了nekit,MMDB,yaml 等全部框架,运行之后工程crash。必须要把这些linklibrary选择成optional才能运行工程,然而也是这个错误

    随后我用swift创建了另外一个项目,用了相同的BundleID、 info.plist and entitlements. 完美运行,vpn连接成功

    能告诉我什么原因吗?谢谢了。在 host app 和tunnel target里面添加了全部的frameworks都没能解决问题 I confused。 Please help me! Thanks! @zhuhaow

    Reviewed by harveyHW at 2018-04-20 06:32
  • 6. Reject rule takes too many time

    Hello

    I am now trying to use this framework. Btw, when i use reject rule for blocking some hosts, it takes too many time.

    Specially, Youtube video loading is very slow. Can you investigate about this?

    Reviewed by devstar1988 at 2017-05-19 11:59
  • 7. 关于dns转发的疑问

    先说下我目前的配置情况:

    proxySettings,没有配置,不走http代理 NEDNSSettings(servers: ["8.8.8.8"])设置了dns配置 TUNInterface只配置了udp和tcp,没有配置DNSServer udp类是改的一个类,这个类可以发送udp数据到代理服务器,然后代理服务器返回数据写入在iOS

    目前的情况:

    打开网页的时候,需要解析域名,那么就需要通过dns,dns会发送udp包,这个时候,udp类会收到包并且做了代理服务器的握手协议,转发到代理服务器,代理服务器再发送udp给APP,写入到iOS中 按照情况来说dns解析了域名拿到IP,开始走tcp包来访问,但是目前的情况是没有走。

    ps:在进行udp的普通转发,比如游戏使用了udp,是正常的,能够正常转发接收并且应用也能解析。 目前不清楚问题出在哪里,希望大佬能够给点思路或者探讨下,我不清楚是否我的这个流程有没有问题

    Reviewed by chenfengfeng at 2019-09-30 10:47
  • 8. http URL不兼容问题,估计是代码小bug

    http://xxxx.com/preview/iframe?id=xxx&cache=| 该域名规则为直连,出错的原因关键在于 cache=| ,这里不是数字1,是符号| , 这会导致直接没法发送请求,请求日志里面也没有任何信息,但是surge和charles是没有此问题的,麻烦作者看一下。

    Reviewed by android0276 at 2018-09-30 09:06
  • 9. 工程紧急!!!!!求助!!!!!1导入包出错

    /bin/sh -c /Users/dream1024/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/MMDB-Swift/0.2.7/Build/Intermediates.noindex/ArchiveIntermediates/MMDB-OSX/IntermediateBuildFilesPath/MMDB.build/Release/MMDB-OSX.build/Script-366F5FDE1F0515CD00DE3883.sh /Users/dream1024/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/MMDB-Swift/0.2.7/Build/Intermediates.noindex/ArchiveIntermediates/MMDB-OSX/IntermediateBuildFilesPath/MMDB.build/Release/MMDB-OSX.build/Script-366F5FDE1F0515CD00DE3883.sh: line 2: [: /Users/dream1024/Desktop/C++: binary operator expected /Users/dream1024/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/MMDB-Swift/0.2.7/Build/Intermediates.noindex/ArchiveIntermediates/MMDB-OSX/IntermediateBuildFilesPath/MMDB.build/Release/MMDB-OSX.build/Script-366F5FDE1F0515CD00DE3883.sh: line 3: /Users/dream1024/Desktop/C++: No such file or directory

    ** ARCHIVE FAILED **

    The following build commands failed: PhaseScriptExecution Run\ Script /Users/dream1024/Library/Caches/org.carthage.CarthageKit/DerivedData/9.2_9C40b/MMDB-Swift/0.2.7/Build/Intermediates.noindex/ArchiveIntermediates/MMDB-OSX/IntermediateBuildFilesPath/MMDB.build/Release/MMDB-OSX.build/Script-366F5FDE1F0515CD00DE3883.sh (1 failure)

    看了 好几个 关于这个方面的问题 各种方法都试了 还是这个错误 工程紧急 求助!!!!!!!!!!!

    Reviewed by 502885507 at 2018-04-02 16:51
  • 10. pac file limitation

    Hello @zhuhaow,

    i am running into some issues when i am using a pac file within NEKit on iOS 10.2.1. I dont know if it is related to NEKit or an Apple limitation but maybe you can help.

    proxySettings.autoProxyConfigurationEnabled = true proxySettings.proxyAutoConfigurationJavaScript = local.pacJSCode() //proxySettings.proxyAutoConfigurationJavaScript = nil //proxySettings.proxyAutoConfigurationURL = URL(string: "https://some/address/to/pac.js")

    The error appears on both versions of code (local or remote pac). If i send a lot of requests either from an App or from Safari i have some kind of loading hang. It starts to load then the loading freezes and it takes the system something like 10-20s to load further.

    For clarification: the pac file forwards to the proxy running on port 9090 so thats nit the issue. Requests are also forwarded to remote server when i am sing one.

    Thanks for any help you can provide.

    Best,

    keKs

    Reviewed by itskeKs at 2017-03-05 11:01
  • 11. xcode 10.1 carthage fails

    *** Building scheme "CocoaLumberjackSwift" in Demos.xcworkspace Build Failed Task failed with exit code 65: /usr/bin/xcrun xcodebuild -workspace /Users/yangqin/iosworkspace/RabbitVpnDemo/Carthage/Checkouts/CocoaLumberjack/Demos/Demos.xcworkspace -scheme CocoaLumberjackSwift -configuration Release -derivedDataPath /Users/yangqin/Library/Caches/org.carthage.CarthageKit/DerivedData/10.1_10B61/CocoaLumberjack/3.5.3 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/d8/mm07v3pd5qg_prnrfrv4qbh80000gn/T/CocoaLumberjack SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/yangqin/iosworkspace/RabbitVpnDemo/Carthage/Checkouts/CocoaLumberjack)

    This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/d8/mm07v3pd5qg_prnrfrv4qbh80000gn/T/carthage-xcodebuild.qIIc0e.log

    Reviewed by candiceatwb at 2019-06-12 09:08
  • 12. 连接几次后,打开网络或者请求VPN就会断开,请问什么原因

    nw_socket_handle_socket_event [C3.1:2] Socket SO_ERROR [61: Connection refused] Connection 3: received failure notification Connection 3: failed to connect 1:61, reason -1 Connection 3: encountered error(1:61) Task <6C7C1EAA-643B-4B2A-8430-436E4B2B7485>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])

    Reviewed by yuzhijiang at 2020-04-04 12:32
Related tags
NWReachability - a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

NWReachability is a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

Mar 4, 2022
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Jan 21, 2022
Say goodbye to the Fat ugly singleton Network Manager with this Network Layer

MHNetwork Protocol Oriented Network Layer Aim to avoid having bloated singleton NetworkManager Philosophy the main philosophy behind MHNetwork is to h

Apr 6, 2022
Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder
Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Jun 7, 2022
Swift Paging is a framework that helps you load and display pages of data from a larger dataset from local storage or over network.

Swift Paging is a framework that helps you load and display pages of data from a larger dataset from local storage or over network. This approach allows your app to use both network bandwidth and system resources more efficiently. It's built on top of Combine, allowing you to harness its full power, handle errors easily, etc.

Feb 7, 2022
iOS Network monitor/interceptor framework written in Swift
iOS Network monitor/interceptor framework written in Swift

NetShears NetShears is a Network interceptor framework written in Swift. NetShears adds a Request interceptor mechanisms to be able to modify the HTTP

Jun 10, 2022
Dratini is a neat network abstraction layer.

Dratini Dratini is a neat network abstraction layer. If you are looking for a solution to make your network layer neat, Dratini is your choice. Dratin

Jan 29, 2022
Network abstraction layer written in Swift.
Network abstraction layer written in Swift.

Moya 14.0.0 A Chinese version of this document can be found here. You're a smart developer. You probably use Alamofire to abstract away access to URLS

Jun 23, 2022
A lightweight, one line setup, iOS / OSX network debugging library! 🦊
A lightweight, one line setup, iOS / OSX network debugging library! 🦊

Netfox provides a quick look on all executed network requests performed by your iOS or OSX app. It grabs all requests - of course yours, requests from

Jun 18, 2022
Elegant network abstraction layer in Swift.
Elegant network abstraction layer in Swift.

Elegant network abstraction layer in Swift. 中文 Design Features Requirements Communication Installation Usage Base Usage - Target - Request - Download

Jan 29, 2022
Lightweight network abstraction layer, written on top of Alamofire
Lightweight network abstraction layer, written on top of Alamofire

TRON is a lightweight network abstraction layer, built on top of Alamofire. It can be used to dramatically simplify interacting with RESTful JSON web-

Jun 17, 2022
iOS network debugging, like a wizard 🧙‍♂️
iOS network debugging, like a wizard 🧙‍♂️

Start debugging iOS network calls like a wizard, without extra code! Wormholy makes debugging quick and reliable. What you can do: No code to write an

Jun 16, 2022
A generic network layer written in swift

SwiftyNet 1.0.0 A generic network layer written in swift. you can use it as an abstraction layer above Alamofire with generic returned types. Installa

Oct 11, 2021
Automatically sets the network activity indicator for any performed request.

BigBrother BIG BROTHER IS WATCHING YOU. BigBrother is a Swift library made for iOS that automatically watches for any performed request and sets the n

Apr 23, 2022
Generic Network Layer created using Swift.

Generic-Network-Layer_iOS Generic Network Layer created using URLSession. Networking is an essential element in app development, and you'll need API c

Jun 16, 2022
Make it easier to observe network connectivity in SwiftUI.

ReachabilityX ReachabilityX is built using NWPathMonitor from Apple's Network framework to provide an easy way to observe the network changes for Swif

Feb 4, 2022
NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. ⚙️🚀
NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. ⚙️🚀

SONetworking NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. Project Folder and File Struc

Jan 28, 2022
Alamofire network layer

NVNetworkRequest Alamofire network layer Installation Add this to your Package dependencies: dependencies: [ .package(url: "https://github.com/vin

Nov 19, 2021
SwiftCANLib is a library used to process Controller Area Network (CAN) frames utilizing the Linux kernel open source library SOCKETCAN.

SwiftCANLib SwiftCANLib is a library used to process Controller Area Network (CAN) frames utilizing the Linux kernel open source library SOCKETCAN. Th

Oct 25, 2021