Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopting iOS 9 network extension points #124

Open
clowwindy opened this issue Jun 9, 2015 · 555 comments
Open

Adopting iOS 9 network extension points #124

clowwindy opened this issue Jun 9, 2015 · 555 comments
Assignees

Comments

@clowwindy
Copy link
Contributor

Network extension points:
Use the Packet Tunnel Provider extension point to implement the client side of a custom VPN tunneling protocol.
Use the App Proxy Provider extension point to implement the client side of a custom transparent network proxy protocol.
Use the Filter Data Provider and the Filter Control Provider extension points to implement dynamic, on-device network content filtering.
Each of the network extension points requires special permission from Apple.

@conradev
Copy link

conradev commented Jun 9, 2015

Each of the network extension points requires special permission from Apple :(

@clowwindy
Copy link
Contributor Author

Now that Apple allows anyone to run the code on their own devices, we don't have to publish the app on the App Store.

No, it still requires some entitlements to run on the devices.

@conradev
Copy link

conradev commented Jun 9, 2015

Totally, but - the API documentation is hard to piece together and there is no template in Xcode for the extension point. Gonna have to do some reverse engineering.

@clowwindy
Copy link
Contributor Author

There's no documentation at all at the moment. The headers of NetworkExtension.framework are public, so we can figure out how to implement the proxy.

I guess we need to subclass NEAppProxyProvider to handle both NEAppProxyTCPFlow and NEAppProxyUDPFlow. And somehow activate the proxy.

Or we can subclass NEPacketTunnelProvider to create a VPN tunnel that handles NEPacketTunnelFlow.

@conradev
Copy link

Totally. We need to find the extension point identifier, too. Cisco and OpenVPN need to update their apps...

@clowwindy
Copy link
Contributor Author

I guess it works just like an app that controls IPSec VPN settings. Before calling manager.connection.startVPNTunnelAndReturnError, we should register our own protocol with

[NETunnelProviderManager loadAllFromPreferencesWithCompletionHandler:(void (^)(NSArray<NETunnelProviderManager *> * __nullable managers, NSError * __nullable error))completionHandler]

I'll give it a try when I have time.

@conradev
Copy link

I'm going to wait for the single WWDC session before diving in

@clowwindy
Copy link
Contributor Author

NEAppProxyProvider is actually per-app exclusive. Good news is we can use NEPacketTunnelProvider to create global VPN services.

I'm writing to Apple to see if we can get permission for the API.

@blackgear
Copy link

@icodesign
Copy link

Have you made any progress on packet tunnel?

@clowwindy
Copy link
Contributor Author

Still no reply from Apple.

@icodesign
Copy link

I'm writing to Apple to see if we can get permission for the API.

So does this mean only those who have grant permissions from Apple can develop global proxy apps?

@clowwindy
Copy link
Contributor Author

I'm afraid yes.

@icodesign
Copy link

I'm afraid yes.

Sad but reasonable. Good luck with SS. 🙏

@muenzpraeger
Copy link

The NEAppProxyProvider API only require a MDM deployed app. That can be "simulated" as described in the video.

@angelovAlex
Copy link

There're actually templates for Xcode. You need to install them from

/System/Library/Frameworks/NetworkExtension.framework/Versions/A/Resources/NEProviderTargetTemplates.pkg

But I have not found the way of how to activate a vpn. As there's no shared instance for NETunnelProviderManager I think we need to create a new one.

[NETunnelProviderManager loadAllFromPreferencesWithCompletionHandler:^(NSArray<NETunnelProviderManager *> * __nullable managers, NSError * __nullable error) {

        if (managers.count <= 0){
            NETunnelProviderProtocol *protocol = [[NETunnelProviderProtocol alloc] init];
            protocol.providerConfiguration = @{ @"some parameter" : @"some value" };
            protocol.providerBundleIdentifier = @"com.example.vpn.vpntunnel";

            NETunnelProviderManager *manager = [[NETunnelProviderManager alloc] init];
            [manager setProtocol:protocol];
            [manager setLocalizedDescription:@"My VPN"];
            [manager setOnDemandEnabled:NO];
            [manager setEnabled:YES];

            [manager loadFromPreferencesWithCompletionHandler:^(NSError * __nullable error) {
                NSLog(@"%@", error);
            }];
        }
    }];

On the line NETunnelProviderManager *manager = [[NETunnelProviderManager alloc] init];, the following message appears in the console app:

6/27/15 5:31:13.845 PM VPNOSX[1403]: Application does not have the required entitlements.

It doesn't say which entitlements and there's no any documentation about it.
I want to try this api on MAC OS 10.11. I understand the reason why I need to ask apple for some permission to publish the app with this api to app store, but I can't believe that I have to ask them for permission to run this api on my development machine.
Sorry, that's a little bit off topic, but that is the only thread that I found in the internet so far.

@clowwindy
Copy link
Contributor Author

Yes. You need to send an email to Apple to get the entitlements. And I'm waiting for their reply.

@manjonn
Copy link

manjonn commented Jul 8, 2015

Any luck on this yet? I am looking at NEAppProxyProvider for a project for a client. I think I do understand some things, but can't be sure till I can run it on the device.

@EkkoG
Copy link

EkkoG commented Jul 9, 2015

@clowwindy
Copy link
Contributor Author

let newManager = NETunnelProviderManager()

You'll get a warning complaining about missing entitlements when you execute this line of code.

@angelovAlex
Copy link

In README.md it says:

The NEProvider family of APIs require the following entitlement:
<key>com.apple.developer.networking.networkextension</key>
<array>
    <string>packet-tunnel-provider</string>
    <string>app-proxy-provider</string>
    <string>content-filter-provider</string>
</array>
</plist>
The SimpleTunnel.app and the provider extensions will not run if they are not code signed with this entitlement.
You can request this entitlement by sending an email to networkextension@apple.com.

If you try to compile the app with this entitlement, your app will be killed by taskgated daemon. If you like to move com.apple.taskgated.plist from /System/Library/LaunchDaemons with root permission, you will get a nice response:

sudo mv com.apple.taskgated-helper.plist ~
mv: rename com.apple.taskgated-helper.plist to /Users/alex/com.apple.taskgated-helper.plist: Operation not permitted

means that you are not admin now, you are nothing and you are in sandbox:

7/9/15 12:37:27.138 PM sandboxd[113]: ([3711]) mv(3711) System Policy: deny file-write-unlink /System/Library/LaunchDaemons/com.apple.taskgated-helper.plist

@muenzpraeger
Copy link

We just received the entitlements.

@clowwindy
Copy link
Contributor Author

Got the entitlements, too.

@jedisct1
Copy link

Yipee!

@jedisct1
Copy link

Did you apply as an individual or as a company?

I didn't dare filling the form because it seemed like you had to apply as a company.

@clowwindy
Copy link
Contributor Author

I applied as an open source organization. I explained a bit about this project in the Company name and address field.

@clowwindy
Copy link
Contributor Author

Update:

Now I can get a virtual tun device running and route packets through UDP. While I find it a little hard to debug as I can't attach to the extension.

@jianpx
Copy link

jianpx commented Aug 11, 2016

Thanks , and good luck!

@jianpx
Copy link

jianpx commented Aug 12, 2016

Can Network Extension support to implement OpenVPN protocol ?

@tahasiddiqui123
Copy link

I have the same question like jianpx.

@Liwink
Copy link

Liwink commented Oct 8, 2016

Thank you.

@WordlessEcho
Copy link

Thanks.

@b9AobJ
Copy link

b9AobJ commented Feb 13, 2017

You are a hero in china.Thanks a lot.
We will never forget your great work.
Take care of yourself.🙃

@xiaochunyong
Copy link

thanks

@angrykub
Copy link

I just want to ask a question, how can I get the tun fd on ios9.x?
I can't find tun devices in "/dev/" folder, Do anyone tell me how to do?
@clowwindy @linusyang @conradev @chrisballinger

@angrykub
Copy link

thanks man!!!

@Azarealice
Copy link

Thank you.

@nevermoreluo
Copy link

Thank you so much for all you have done

@ghost
Copy link

ghost commented Feb 17, 2018

Thank you

@SiqingYu
Copy link

Thanks for your great work.

@ztdexter
Copy link

ztdexter commented Jul 1, 2018

thank you !

@halilemreozen
Copy link

Thanks a lot!

@ablebodied
Copy link

Great job for Chinese people and for a better China.

@ButcherOfBlaviken
Copy link

Thank you, you are our hero!

@SMR
Copy link

SMR commented Apr 8, 2019

Thanks

@keepthethink
Copy link

Thank you.

@daydreamzzz
Copy link

Thanks

@flyco2016
Copy link

路过,这里我谁也不认识

@lyhong508
Copy link

感谢, 牛逼!

@Yoomin233
Copy link

pay the respect to you, the pioneer of anti-sensorship!

@wwwlookformetop
Copy link

fighting!!!

@Project-Magenta
Copy link

Thank you.

@ghost
Copy link

ghost commented Jul 26, 2021

Two days ago the police came to me and wanted me to stop working on this. Today they asked me to delete all the code from GitHub. I have no choice but to obey.

I hope one day I'll live in a country where I have freedom to write any code I like without fearing.

I believe you guys will make great stuff with Network Extensions.

Cheers!

When will there be the Anti Great Firewall Movement?

@cross-hello
Copy link

Just a late letter: Thank you

@Andy17269
Copy link

Thank you !

@Tommyeth
Copy link

Thx

@Sancho-Z
Copy link

Sancho-Z commented Sep 7, 2023

great software

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests