This is a demo application for Windows Desktop Applications with basic usage of ATOM VPN SDK which will help the developers to create smooth applications over ATOM SDK quickly.
- Connection with Parameters
- Connection with Dedicated IP
- Connection with Multiple Protocols (Auto-Retry Functionality)
- Connection with Real-time Optimized Servers (Countries based on latency from user in Real-time)
- Connection with Smart Dialing (Use GetCountriesForSmartDialing() to get the Advanced VPN Dialing supported countries)
- Split Tunneling
- Internet Kill Switch
- Compatible with Microsoft Visual Studio 2015 and onwards
- Minimum .Net Framework 4.5 required
- Compatible with ATOM SDK Version 3.0 and onwards
- IKEv2
- TCP
- UDP
- WireGuard
Install the latest version of Atom Network SDK through NuGet.
NuGet\Install-Package Atom.SDK.Net -Version 5.1.0
Run Atom.SDK.Installer.exe to install supporting services and drivers on any system. The same Installer should be accompanied with your application setup to get the required files installed on your customer's system.
Atom.SDK.Net.dll.config file should be copied to the output directory where Atom.SDK.Net.dll is present (only if the config file is not already there) since AtomSDK will read the name of your RAS VPN Adapter mentioned in this config against RAS_ADAPTER_NAME key.
ATOM SDK needs to be initialized using an instance of AtomConfiguration. It should have a VpnInterfaceName which will be used to create the Network Interface for VPN connection.
var atomConfiguration = new AtomConfiguration(“SECRETKEY_GOES_HERE”, “INSTALLED_SERVICE_NAME_GOES_HERE”, “INSTALLED_DIRECTORY_FOLDER_NAME_GOES_HERE”, “CUSTOM_VPN_INTERFACE_NAME_GOES_HERE”);
atomConfiguration.VpnInterfaceName = "AtomDemo";
atomConfiguration.BaseUrl = new Uri("YOUR_BASE_URL"); // Optional
var atomManagerInstance = AtomManager.Initialize(atomConfiguration);
PS: ATOM SDK is a singleton, and must be initialized before accessing its methods, otherwise NullObjectReference Exception will be thrown.
ATOM SDK offers a feature to enable the local inventory support. This can help Application to fetch Countries and Protocols even when device network is not working.
- To enable it, Log In to the Atom Console
- Download the local data file in json format
- File name should be localdata.json. Please rename the file to localdata.json if you find any discrepancy in the file name.
- Paste the file in the output directory of your application
ATOM SDK offers few events to register for the ease of the developer.
- StateChanged
- Connected
- Disconnected
- DialError
- Redialing
- OnUnableToAccessInternet
- AtomInitialized
- AtomDependenciesMissing
- PacketsTransmitted
Details of these events can be seen in the inline documentation or method summaries. You need to register these events to get notified about what’s happening behind the scenes
atomManagerInstance.Connected += AtomManagerInstance_Connected;
atomManagerInstance.DialError += AtomManagerInstance_DialError;
atomManagerInstance.Disconnected += AtomManagerInstance_Disconnected;
atomManagerInstance.StateChanged += AtomManagerInstance_StateChanged;
atomManagerInstance.Redialing += AtomManagerInstance_Redialing;
atomManagerInstance.OnUnableToAccessInternet+= AtomManagerInstance_OnUnableToAccessInternet;
atomManagerInstance.AtomInitialized += AtomManagerInstance_AtomInitialized;
atomManagerInstance.AtomDependenciesMissing += AtomManagerInstance_AtomDependenciesMissing;
Events will be registered with the respective EventArgs customized for the ease of the developer.
Atom SDK offers VPN Credentials directly to the SDK which you may create through the Admin Panel provided by ATOM.
atomManagerInstance.Credentials = new Credentials("VPNUsername","VPNPassword");
You need to declare an object of VPNProperties class to define your connection preferences. Details of all the available properties can be seen in the inline documentation of VPNProperties Class. For the least, you need to give Country and Protocol with which you want to connect.
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
You can get the Countries list through ATOM SDK.
var countries = atomManagerInstance.GetCountries();
You can get the Countries those support Smart Dialing through ATOM SDK.
var countries = AtomManagerInstance.GetCountriesForSmartDialing();
You can get the Recommended Country for user's location through ATOM SDK.
var recommendedCountry = AtomManagerInstance.GetRecommendedCountry();
Protocols can be obtained through ATOM SDK as well.
var protocols = atomManagerInstance.GetProtocols();
For VPN connection speed you need to registor PacketsTransmitted event from AtomManager class to get the VPN connection speed in bytes per second. This callback is recieve only in VPN connected state.
atomManagerInstance.PacketsTransmitted
You can enable or disable protocol switch from VPNProperties class. By default its value is set to true.
VPNPorperties.EnableProtocolSwitch = false;
or
VPNPorperties.EnableProtocolSwitch = true;
If you didn't specify the protocol in case of Country, City and Channel dailing then Atom SDK dialed with recommended protocol according to the specified country, city and channel. It did not work in PSK, Smart connect dialing and dedicated IP.
Failover is a mechanism in which Atom dialed with nearest server if requested server is busy or not found for any reason. You can control this mechanism from VPNPorperties class. By default its value is set to true.
VPNPorperties.UseFailover = false;
or
VPNPorperties.UseFailover = true;
As soon as you call Connect method, the events you were listening to will get the updates about the states being changed and Dial Error (if any occurs as well).
After initializing the VPNProperties, just call Connect method of ATOM SDK.
It is the simplest way of connection which is well explained in the steps above. You just need to provide the Country and the Protocol objects and call the Connect method.
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
atomManagerInstance.Connect(properties);
From version 3.0 onwards, Atom has introduced connection with Cities and Channels. You can found their corresponding VPNProperties constructors in the Demo Application.
When connecting with parameters, a server can be included or excluded with its Nas Identifier
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
vpnProperties.ServerFilter = new ServerFilter { FilterType = SDK.Core.Enumerations.ServerFilterType.Include, NASIdentifier = "nas-identifier-here" };
vpnProperties.ServerFilter = new ServerFilter { FilterType = SDK.Core.Enumerations.ServerFilterType.Exclude, NASIdentifier = "nas-identifier-here" };
You can also make your user comfortable with this type of connection by just providing them with a Dedicated DNS Host and they will always connect to a dedicated server! For this purpose, ATOM SDK provides you with the following constructor.
var vpnProperties = new VPNProperties(string hostName, Protocol protocol);
atomManagerInstance.Connect(properties);
This one is same as the first one i.e. "Connection with Parameters" with a slight addition of using Real-time optimized servers best from your user’s location. You just need to set this property to TRUE and rest will be handled by the ATOM SDK.
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
vpnProperties.UseOptimization= true;
atomManagerInstance.Connect(properties);
For more information, please see the inline documentation of VPNProperties Class.
If you want to show your user the best location for him on your GUI then ATOM SDK have it ready for you as well! ATOM SDK has a method exposed namely GetOptimizedCountries() which adds a property Latency in the country object which has the real-time latency of all countries from your user’s location (only if ping is enabled on your user’s system and ISP doesn’t blocks any of our datacenters). You can use this property to find the best speed countries from your user’s location.
“Connection with Parameters” with a slight addition of using smart dialing to connect. You just need to set UseSmartDialing property of VPNProperties true and rest will handled by the ATOM SDK.
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
vpnProperties.UseSmartDialing= true;
atomManagerInstance.Connect(properties);
For more information, please see the inline documentation of VPNProperties Class.
You can provide THREE Protocols at max so ATOM SDK can attempt automatically on your behalf to get your user connected with the Secondary or Tertiary protocol if your primary Protocol fails to connect.
vpnProperties.SecondaryProtocol = ProtocolObject;
vpnProperties.TertiaryProtocol = ProtocolObject;
For more information, please see the inline documentation of VPNProperties Class.
You can cancel connection between dialing process by calling the Cancel method.
atomManagerInstance.Cancel();
To disconnect, simply call the Disconnect method of AtomManager.
atomManagerInstance.Disconnect();
This section outlines the steps required to establish an OpenVPN connection using the Wintun adapter. It involves enabling the UseTunnelAdapterForOpenVPNDialing property within the VPNProperties class.
-
Initialize VPN Properties Begin by instantiating the
VPNProperties
class. This class contains the necessary properties to configure the VPN connection. -
Enable Tunnel Adapter for OpenVPN Dialing Set the
UseTunnelAdapterForOpenVPNDialing
property totrue
within theVPNProperties
class. This enables the use of the Wintun adapter for OpenVPN connections.Example Code:
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
vpnProperties.UseTunnelAdapterForOpenVPNDialing = true;
- Create the Connection After enabling the property, proceed to establish the OpenVPN connection. With the configuration set, the connection will automatically use the new Wintun adapter.
Note: This property will only work with UDP and TCP protocols.
This section details about the VPN Pause and Resume feature using the Atom SDK, enabling users to temporarily pause VPN connections manually or for a specific duration. This is useful when users need to suspend VPN activity without a full disconnect.
- Manual Pause: Indefinitely pauses the VPN until resumed manually.
- Timed Pause: Pauses the VPN for a predefined duration, automatically resuming afterward. Users can also resume manually before the timer ends.
- VPN can only be paused if in a Connected state.
- VPN can only be resumed if in a Paused state.
- A paused VPN can still be disconnected using the SDK's
Disconnect
method. - During a timed pause, users can manually resume the VPN using the
Resume
method.
Triggered when the VPN is paused (manually or timed).
atomManagerInstance.OnVPNPaused += AtomManager_OnVPNPaused;
private void AtomManager_OnVPNPaused(object sender, PausedEventArgs e)
{
// Handle pause state
}
public class PausedEventArgs
{
public ConnectionDetails ConnectionDetails { get; set; }
public VPNState State { get; private set; }
}
enum PauseVPNTimer
{
MANUAL,
MINUTES_5,
MINUTES_10,
MINUTES_15,
MINUTES_30,
MINUTES_60
}
async Task Pause(PauseVPNTimer pauseInterval)
{
await AtomManagerInstance.Pause(pauseInterval);
}
atomManagerInstance.Connected += AtomManager_Connected;
atomManagerInstance.DialError += AtomManager_DialError;
void Resume()
{
AtomManagerInstance.Resume();
}
private void AtomManager_Connected(object sender, ConnectedEventArgs e)
{
// VPN resumed successfully
}
private void AtomManager_DialError(object sender, DialErrorEventArgs e)
{
// Handle resume error
}
The SDK provides a VPNState
enum for current state:
public enum VPNState
{
PAUSING, // VPN is in the process of pausing
PAUSED, // VPN is currently paused
RESUMING // VPN is resuming
}
Subscribe to state changes:
atomManagerInstance.StateChanged += AtomManagerInstance_StateChanged;
private void AtomManagerInstance_StateChanged(object sender, StateChangedEventArgs e)
{
// Handle state changes: PAUSING, PAUSED, RESUMING, etc.
}
The Atom SDK’s VPN Pause functionality provides powerful control over connection management, with both manual and timed pause options. By following the integration steps above, developers can enhance user experience with smooth, responsive VPN control.
This section outlines the deatils about the Tracker and Ad Blocker feature in the Atom VPN SDK. This feature allows VPN applications built using the Atom SDK to block tracking scripts and advertisements for enhanced privacy and performance.
As a VPN service provider, we offer a powerful SDK that our clients can use to build custom VPN applications. In our latest release, we’ve introduced support for Tracker and Ad Blocker functionality.
When enabled, this feature will actively block trackers and advertisements during a VPN session. It is supported across all connection types provided by the SDK:
- Connect with Param
- Connect with Dedicated IP
- Connect with Multiple Dedicated IPs
- Connect with Dedicated VPS
Use these constants to specify the features you want to enable:
AtomShieldFeatureType.TRACKER
AtomShieldFeatureType.AD_BLOCKER
Specify the desired features in the VPNProperties
object:
properties.AtomShieldFeatures = new List<SDK.Core.Enumerations.AtomShield.AtomShieldFeatureType>
{
SDK.Core.Enumerations.AtomShield.AtomShieldFeatureType.TRACKER,
SDK.Core.Enumerations.AtomShield.AtomShieldFeatureType.AD_BLOCKER
};
Subscribe to the following events to monitor status and blocked data:
atomManagerInstance.AtomShieldStatusChanged += AtomManagerInstance_AtomShieldStatusChanged;
atomManagerInstance.AtomShieldDataRecieved += AtomManagerInstance_AtomShieldDataRecieved;
The AtomShieldStatus
object represents the state of the feature:
Establishing(String)
: Connecting the Tracker/Ad BlockerEstablished(String)
: Tracker/Ad Blocker connected successfullyDisconnected(String)
: Tracker/Ad Blocker disconnectedError(AtomException)
: An error occurred (refer to error codes for details)
Monitor the number of blocked trackers or ads using:
(int) AtomShieldData.BlockerCount
Verify if features were requested using the following properties:
ConnectionDetails.IsTrackerBlockerRequested
ConnectionDetails.IsAdBlockerRequested
The Tracker and Ad Blocker feature in the Atom SDK enables clients to provide users with enhanced privacy and a better browsing experience. This feature seamlessly integrates with all supported VPN connection types, ensuring consistent functionality across diverse configurations.
Our VPN SDK now includes a new feature that allows users to access their locally connected devices over the internet while maintaining a VPN connection. This functionality ensures seamless connectivity to local resources without compromising security.
By default, VPN connections restrict access to locally connected devices. However, our SDK introduces the BYPassLocalLanConnection property within the VPNProperties class, which allows users to toggle this capability on or off.
- When enabled, the user's locally connected devices remain accessible while using the VPN.
- When disabled, the standard VPN restrictions apply, blocking access to local network devices.
To enable or disable Local LAN Access, set the BYPassLocalLanConnection property in your VPN configuration:
var vpnProperties = new VPNProperties(Country country, Protocol protocol);
vpnProperties.BYPassLocalLanConnection = true; // Enable access to local network devices
- Access network printers, shared drives, or IoT devices while connected to the VPN.
- Maintain a secure VPN connection while still using local services.
- Ideal for remote workers needing access to both VPN-protected resources and local network devices.
In case any dependency conflict is faced while building/running ATOM SDK with your application e.g. different version of Newtonsoft.Json used in your application, define the binding redirect in your app configuration like following:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
where "0.0.0.0-11.0.0.0" is the minimum and maximum version range of Newtonsoft.Json.