{"id":22951554,"url":"https://github.com/lifailon/vpnc","last_synced_at":"2026-02-05T10:33:16.641Z","repository":{"id":260579081,"uuid":"881735092","full_name":"Lifailon/vpnc","owner":"Lifailon","description":"A universal tool for automatic (local) and remote VPN connection management via a desktop application (system tray) and API","archived":false,"fork":false,"pushed_at":"2025-01-03T23:57:58.000Z","size":507,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T05:38:24.464Z","etag":null,"topics":["api","asp-net-core","cli","csharp","dotnet","hotspot","hotspot-shield-vpn","network","rest-api","sdk","tray","tray-application","vpn","vpn-manager","web-api","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lifailon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-01T05:42:01.000Z","updated_at":"2025-03-06T07:35:21.000Z","dependencies_parsed_at":"2024-11-01T06:26:29.583Z","dependency_job_id":"35f79102-a044-4c5f-938e-27d8b48f433c","html_url":"https://github.com/Lifailon/vpnc","commit_stats":null,"previous_names":["lifailon/vpnc"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Lifailon/vpnc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lifailon%2Fvpnc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lifailon%2Fvpnc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lifailon%2Fvpnc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lifailon%2Fvpnc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lifailon","download_url":"https://codeload.github.com/Lifailon/vpnc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lifailon%2Fvpnc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29119232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T09:40:36.738Z","status":"ssl_error","status_checked_at":"2026-02-05T09:36:49.977Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","asp-net-core","cli","csharp","dotnet","hotspot","hotspot-shield-vpn","network","rest-api","sdk","tray","tray-application","vpn","vpn-manager","web-api","windows"],"created_at":"2024-12-14T15:16:41.577Z","updated_at":"2026-02-05T10:33:16.624Z","avatar_url":"https://github.com/Lifailon.png","language":"C#","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg title=\"Ping Not Available\"src=\"img/ping-not-available.png\"\u003e\n  \u003cimg title=\"next\"src=\"img/next.png\"\u003e\n  \u003cimg title=\"Ping Available\"src=\"img/ping-available.png\"\u003e\n  \u003cimg title=\"next\"src=\"img/next.png\"\u003e\n  \u003cimg title=\"Ping Not Available\"src=\"img/vpn.png\"\u003e\n\u003c/a\u003e\n\n\u003ch1 align=\"center\"\u003e\nvpnc - VPN Control\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e\n    \u003cstrong\u003eEnglish\u003c/strong\u003e | \u003ca href=\"README_ru.md\"\u003eРусский\u003c/a\u003e\n\u003c/h4\u003e\n\nA universal tool for automatic (local) and remote VPN connection management via a desktop application (system tray) and `API`.\n\nIn fact, this tool can act as an `API` to control the start and stop of any processes on a remote Windows system.\n\n- [For what](#for-what)\n- [Functionality](#functionality)\n- [Installation and build](#installation-and-build)\n- [Configuration](#configuration)\n- [Usage](#usage)\n- [API](#api)\n  - [Get status](#get-status)\n  - [Process start](#process-start)\n  - [Process stop](#process-stop)\n- [Backlog](#backlog)\n- [Alternatives](#alternatives)\n\n## For what\n\nI am tired of the fact that the [Hotspot Shield](https://hotspotshield.com/vpn/vpn-for-windows) or [ProtonVPN](https://github.com/ProtonVPN/win-app) application can periodically disconnect the VPN connection, most often this happens due to a long connection to the VPN network (several dozen hours) or a long absence of an Internet connection. In this case, even if the automatic reconnection setting is enabled, the connection may not be re-established, or this may be regarded by the application as a manual disconnection.\n\nThis application performs exactly three functions - it terminates the process by name and starts the process along the path specified in the configuration file or passed in parameters via `API`, and also collects statistics for a reliable check of the VPN connection and Internet availability.\n\nIn addition, this approach can be useful if you need to remotely disable the VPN connection while a large volume of traffic is loading on the target machine, and also allows you to control this connection. This functionality is integrated into the [Kinozal-Bot](https://github.com/Lifailon/Kinozal-Bot) project in version `0.4.7` for remote control of processes via the **Telegram bot**.\n\n## Functionality\n\n![interface](/img/interface.jpg)\n\n- The `API` interface, which allows you to configure remote management of the VPN connection on the target host. For example, in my network this is a dedicated machine, where access to specific content from other machines is carried out by means of Proxy (for example, [froxy](https://github.com/Lifailon/froxy)), this is convenient so as not to limit all traffic to the Internet to a VPN connection and at the same time not to be limited to separate tunneling to the VPN network.\n\n- Monitoring the availability of the Internet connection. The check is performed every 5 seconds (by default, can be changed in the configuration file), if the connection is unavailable, a system notification will be sent (and the status of the application icon will also change) and the check will be performed every two seconds until the connection is stable (3 successful `icmp` requests in a row with an interval of 2 seconds), after which a second notification will be sent.\n\n- Monitoring the availability and automatic restoration of the VPN connection. If the Internet is available and the VPN process is running (excluding manual termination), but the VPN network interface is in the offline state, the application will be automatically restarted to reconnect to the VPN network until the connection is restored (by default, every 120 seconds, can be changed in the configuration file).\n\n- Record the history of pings and requests to `API` in a log file.\n\nThis approach is universal, so it can and will work with any VPN application. The only condition for this method to work is that your VPN client can automatically connect to the VPN network when you launch the application (most clients support this).\n\n## Installation and build\n\nA portable version of the application is available on the [releases](https://github.com/Lifailon/vpnc/releases/latest).\n\nIt is necessary that the platform [.NET Runtime 8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) be installed on the system to run .NET applications.\n\nTo build the application, clone the repository and install dependencies:\n\n```shell\ngit clone https://github.com/Lifailon/vpnc\ncd vpnc\ndotnet build\ndotnet publish\n```\n\nTo exclude installations of **.NET Runtime** on the target system, include it in the build:\n\n```shell\ndotnet publish -c Release -r win-x64 -p:PublishSingleFile=true --self-contained true\n```\n\nPackages used:\n\n```shell\ndotnet add package Newtonsoft.Json\ndotnet add package Microsoft.AspNetCore.App\ndotnet add package Swashbuckle.AspNetCore\n```\n\n## Configuration\n\nTo quickly access the configuration, use the **Open Configuration** button in the tray context menu. The configuration is located in the `vpnc.json` file, next to the executable file.\n\nConfiguration example:\n\n```json\n{\n    \"ProcessName\": \"ProtonVPN\",\n    \"ProcessPath\": \"C:\\\\Program Files\\\\Proton\\\\VPN\\\\v3.4.3\\\\ProtonVPN.exe\",\n    \"InterfaceName\": \"ProtonVPN TUN\",\n    \"ApiPort\": 1780,\n    \"ApiKey\": \"b1f8e72d-9c34-4a2e-a5f1-3d57b2a1c7f8\",\n    \"PingHost\": \"8.8.8.8\",\n    \"PingLog\": true,\n    \"PingStartup\": true,\n    \"VpnStartup\": false,\n    \"ApiStartup\": true,\n    \"PingTimeout\": 5,\n    \"VpnTimeout\": 5,\n    \"VpnRestartTimeout\": 120\n}\n```\n\nParameter description:\n\n- `ProcessName` - The name of the process to be terminated. Most often, this name corresponds to the executable file, it can also be determined in the Windows Task Manager.\n- `ProcessPath` - The full path to the executable file that is responsible for starting the VPN client.\n- `InterfaceName` - The name of the virtual VPN interface (created automatically when installing the VPN client). To determine the interface name, you can use the classic `ipconfig` command.\n- `ApiPort` - The port on which the `Web/REST API` interface will be launched.\n- `ApiKey` - Key for accessing `API` endpoints (access to Swagger is allowed without a key, and authorization via the interface has been added).\n- `PingHost` - The address that will act as a node for checking the availability of the Internet connection.\n- `PingLog` - Enable recording of pings to the log file.\n- `PingStartup/VpnStartup/ApiStartup` - Defines the initial state when starting the interface. Takes a Boolean value of `true` or `false`.\n- `PingTimeout/VpnTimeout` - The frequency of automatic checks in seconds.\n- `VpnRestartTimeout` - Delay before restarting the process again (works only when `\"VpnStartup\": false`) in seconds.\n\nTo quickly get all the parameters, use PowerShell:\n\n```PowerShell\n# Process name for partial match in name\nGet-Process *protonvpn*\n# Path to executable file by process name\nGet-Process *protonvpn* | Select-Object *path*\n# Network adapter name\n$(Get-NetIPConfiguration | Where-Object InterfaceAlias -match \"hotspot\").InterfaceAlias\n```\n\nThe remaining parameters can be left as default. To apply the settings, you must restart the application.\n\n## Usage\n\nRun the application in command line mode:\n\n```shell\ndotnet run [start|stop|status|api|tray|process]\n```\n\nThe `process` parameter is used to launch the application in the background process mode for control via the system tray (similar to `vpnc.exe tray`).\n\nTo launch the program at system boot, go to the startup directory (`Win+R` - `shell:startup`):\n\n```\n%USERNAME%\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\n```\n\nCreate a shortcut in the root of the `Startup` directory with the following content:\n\n```\n\"C:\\Users\\\u003cUserName\u003e\\Documents\\vpnc\\vpnc.exe\" process\n```\n\nReplace the path to the executable file with your own. If elevated rights are required to end processes, in the shortcut properties, select `Compatibility` and enable `Run this program as an administrator`.\n\n## API\n\nThe `API` interface can be launched in command line mode (cli), or from the context menu of the application in the tray. The automatic activation of the `API` when the application is started is defined by the parameter `ApiStartup` in the configuration file.\n\n**Swagger** documentation is available via the `Swashbuckle.AspNetCore` library at: http://localhost:1780/swagger\n\n![swagger](/img/swagger.jpg)\n\n### Get status\n\n`curl -s http://192.168.3.100:1780/api/status -H 'X-API-KEY: b1f8e72d-9c34-4a2e-a5f1-3d57b2a1c7f8' | jq`\n\n```json\n{\n  \"processName\": \"ProtonVPN\",\n  \"processStatus\": \"Running\",\n  \"processUptime\": \"0.0:8:2\",\n  \"systemUptime\": \"3.0:33:21\",\n  \"interfaceName\": \"ProtonVPN TUN\",\n  \"interfaceStatus\": \"Up\",\n  \"pingAddress\": \"8.8.8.8\",\n  \"pingStatus\": \"Connected\",\n  \"pingTimeout\": \"94 ms\",\n  \"country\": \"RO\",\n  \"timeZone\": \"Europe/Bucharest\",\n  \"region\": \"București\",\n  \"city\": \"Bucharest\",\n  \"externalIp\": \"185.XXX.XXX.XXX\"\n}\n```\n\nTo get data about the external connection (which is responsible for Internet access), the [ipinfo](https://ipinfo.io) service is used.\n\n### Process start\n\n```shell\ncurl -X 'POST' 'http://192.168.3.100:1780/api/start' \\\n  -H 'X-API-KEY: b1f8e72d-9c34-4a2e-a5f1-3d57b2a1c7f8' \\\n  -H 'path: C:\\Program Files\\Proton\\VPN\\v3.4.3\\ProtonVPN.exe' \\\n  -d ''\n```\n\nAt startup, a check is made of the passed parameter, the availability of the path, and that the process has been started.\n\n### Process stop\n\n```shell\ncurl -X 'POST' 'http://192.168.3.100:1780/api/stop' \\\n  -H 'X-API-KEY: b1f8e72d-9c34-4a2e-a5f1-3d57b2a1c7f8' \\\n  -H 'name: ProtonVPN' \\\n  -H 'wildcard: true' \\\n  -d ''\n```\n\nThe `wildcard` parameter is used to stop all processes based on a partial match in the passed name.\n\n## Backlog\n\nCurrently, this functionality covers my needs, but there are several things that may be implemented in the future.\n\n- [ ] Universal search for a process by its name in the system\n- [ ] Ping status in the system tray\n- [ ] Get a list of processes and services with running status information\n- [ ] Service management\n- [ ] New endpoints for obtaining system information (system metrics)\n\n## Alternatives\n\n[WinAPI](https://github.com/Lifailon/WinAPI) - `REST API` and Web server (frontend) based on `.NET HttpListener` and backend `PowerShell Core` for Windows remote managment via Web browser or `curl` from Linux.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifailon%2Fvpnc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flifailon%2Fvpnc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifailon%2Fvpnc/lists"}