Coder Social home page Coder Social logo

uwpvpnpluginsample's Introduction

page_type languages products description urlFragment
sample
csharp
dotnet
UWP VPN sample code demonstrates creating a plugin-style VPN app
update-this-to-unique-url-stub

Official Microsoft UWP VPN Sample

Sample code for the Universal Windows Platform (UWP) Virtual Private Network (VPN) plugin API. The VPN Plugin API lets developers create new VPN apps that use otherwise-unsupported VPN encryption algorithmns. The VPN apps in Windows are curated: VPN apps will need the "networkingVpnProvider" restricted capability.

Contents

Outline the file contents of the repository. It helps users navigate the codebase, build configuration and any related assets.

File/folder Description
CSharp Sample C# source code.
CppWinRT Sample C++ source code.
SimpleVpnServer Debugging and validation VPN server.
SimpleUdpListener UDP listener that can receive packets from the VPN client.
.gitignore Define what to ignore at commit time.
CODE_OF_CONDUCT.md Expectations for people participating in this repo.
LICENSE The license for the sample.
README.md This README file.
SECURITY.md Security aspects of the sample.

Prerequisites

This sample works with Visual Studio 2019 (or later) and Windows 11. You will need a copy of a matching Platform SDK.

Setting up and running the sample

To run the sample, you'll need two computers: one to run the SimpleVpnServer and the other to run the client code.

  • On the "server" computer, compile and run the server.
  • Note the server's IP address.
  • On your main development computer, compile and run the client (either C# or C++). When you do, you'll be asked for the server IP address.

In Windows 11, the VPN UI is connected to the Quick Actions menu. The user may have to use the 'Edit' feature to add VPN UI.

Code organization

Code organization by directory

The VPN UWP sample code is divided into a server and two clients, one for C# and the other for C++. The C# code is often best for studying how the the UWP VPN platform APIs work together to create a full VPN client solution.

Directory Contents
SimpleVpnServer C# code for a simple VPN server. The "protocol" is a custom protocol designed to be trivial to implement and debug
SimpleUdpListener C# code for a simple UDP listener. The listener sends back whatever payload it receives. Useful with the "send udp packet/stream" from UWP client
CSharp/TestVpnPluginApp Foreground UI code for the VPN client
CSharp/TestVpnPluginAppBg Background VPN UWP code for the VPN client; handles creating sockets to the server and encapsulation/decapsulation of VPN packets
CppWinRT Demonstration of writing C++ code for VPN; the code matches the C# structure.

Code organization by feature

The UWP VPN Platform supports all of the features needed to build a complete VPN client solution.

Feature Location in code
System Tray VPN client is automatically visible in the system tray. The user may need to manually add the VPN widget.
Custom XML configuration TestVpnPluginAppBg/CustomConfiguration.cs parses custom XML that can be configured from Intune or other MDM management servers.
Configure network routes Routes are passed into StartWithTrafficFilter.
Send/Receive packets Network buffers are handed to the TestVpnPluginAppBg/VpnPlugin.cs Encapsulate and Decapsulate method and then handed to a seperate thread.
Start web authentication TestVpnPluginAppBg/VpnPlugn.cs in the Connect method with the call to channel.ActivateForeground to call into the UX app.
Handle web authentication TestVpnPluginApp/App.cs OnActivated is called when activated with type VpnForegroundActivatedEventArgs.
Connect socket to server TestVpnPluginAppBg/VpnPlugin.cs in the Connect method.

The Windows UWP VPN platform handles all aspects of creating a virtual network adapter and adding it to the system along with appropriate metrics and Name Resolution Policy8 Table (NRPT) entries, DNS servers, and more.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

uwpvpnpluginsample's People

Contributors

microsoft-github-operations[bot] avatar microsoftopensource avatar petersmithredmond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

uwpvpnpluginsample's Issues

How to debug?

How can I put debug statements, etc. in this to print out various aspects of my custom vpn application that I am building? Is that even possible?

What to fill into ServerUris property for Windows UWP vpn profile

n CreateAppProfile() part function as bellow.

// Hard coding parameters for the profile
VpnPlugInProfile profile = new VpnPlugInProfile();
...

        **profile.ServerUris.Add(new Uri("http://10.137.192.135"));**
        var returnedStatus = await agent.AddProfileFromObjectAsync(profile);
        ...

I don't kown what url to fill into "ServerUris" property, and what content should be provide in that url.

And :

var connectStatus = await agent.ConnectProfileAsync(pluginProfile);

the connectStatus always return Other or CannotFindProfile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.