OpenFortiVPN Connector
OpenFortiVPN Connector is an extension that allows you to easily manage Fortinet VPN connections within Visual Studio Code. This extension uses the openfortivpn
command-line tool to set up and manage VPN connections directly from the VS Code editor.
Key Features
- Manage multiple VPN profiles with different configurations
- Simple one-click VPN connection/disconnection with dedicated buttons
- Visual connection status indicators in Profile Explorer (green/red icons)
- VPN status monitoring in VS Code status bar
- Secure password storage for each profile
- Profile explorer in the activity bar
- Automatic connection status monitoring
- Auto-reconnect when connection is lost (New in 1.2.0)
- Configurable reconnection attempts and intervals (New in 1.2.0)
- Connection metrics and statistics monitoring
- Real-time speed, data usage, and connection time tracking
- Interactive graphs and historical session data
- Background connections without terminal windows
- Detailed connection logs in output panel
- Secure password handling that prevents exposure
Requirements

- Linux or macOS operating system
openfortivpn
command-line tool must be installed
- Ubuntu/Debian:
sudo apt install openfortivpn
- macOS:
brew install openfortivpn
- Administrator privileges (sudo) are required
Installation
Install by searching for "OpenFortiVPN Connector" in the VS Code extension marketplace or download directly from the Visual Studio Code Marketplace.
How to Use
Managing VPN Profiles

- Click on the OpenFortiVPN icon in the activity bar (shield icon)
- Click the "+" button to create a new VPN profile
- Enter a name, VPN gateway host, port, and username
- Click on a profile to set it as active
- Use the context menu (right-click on a profile) for more options:
- Connect to profile
- Edit profile
- Delete profile
- Set as active profile
- Manage profile password
Connecting to VPN
There are multiple ways to connect to VPN:
- Click the "VPN: Disconnected" icon in the status bar to toggle using the active profile
- Click the play (▶) icon in the Profile Explorer title bar to connect using the active profile
- When connected, click the stop (■) icon in the Profile Explorer title bar to disconnect
- Right-click on a profile in the profile explorer and select "Connect to Profile"
- Enter your password when prompted (or use a saved password)
- The status bar and profile explorer will show the connection status with visual indicators
Auto-Reconnect Feature (New in 1.2.0)
The extension can automatically attempt to reconnect if your VPN connection is unexpectedly lost:
Enable auto-reconnect in settings:
- Open VS Code settings (File > Preferences > Settings)
- Search for "openfortivpn"
- Check "Auto Reconnect" to enable the feature
- Configure "Auto Reconnect Max Retries" (1-10 attempts)
- Configure "Auto Reconnect Interval" (5-60 seconds between attempts)
When the connection is lost:
- The extension will automatically attempt to reconnect
- Status bar will show "VPN: Reconnecting... (attempt count)"
- If reconnection succeeds, normal connection is restored
- If all reconnection attempts fail, status changes to "VPN: Reconnect Failed"
Control auto-reconnect:
- Click the stop icon during reconnection to cancel the process
- Click the retry icon after max retries to manually try again
- Manual disconnection will not trigger auto-reconnect
Saving Passwords
- Right-click on a profile in the profile explorer
- Select "Manage Profile Password"
- Choose "Save Password" and enter your VPN password
- The password will be securely stored in your OS keychain
Viewing Connection Logs
- Click the "Output" icon in the Profile Explorer title bar
- View detailed connection logs in the Output panel
- Connection attempts, status changes, errors, and other events are recorded
- Logs include timestamps for better tracking
Monitoring Connection Metrics
- Click the "VPN Connection Metrics" section in the OpenFortiVPN activity bar
- View real-time connection metrics in a clear tree format:
- Current connection status (Active/Inactive)
- Current upload and download speeds
- Total data usage (upload/download)
- Total combined data transferred
- Connection duration
- Metrics are automatically updated while connection is active
- Use the refresh button to manually update metrics data
- Export connection metrics data for analysis
- Clear metrics history using the clear button
The metrics view provides essential information about your VPN connection, allowing you to monitor:
- How long you've been connected
- Current network speeds
- Total amount of data transferred during the session
- Overall connection status
All metrics are collected locally and displayed in real-time for the current VPN session.
Using Scheduled VPN Connections (New in 1.2.0)

The extension allows you to schedule automatic VPN connections and disconnections:
Click on the "VPN Schedules" section in the OpenFortiVPN activity bar
Click the "+" icon to create a new schedule
Configure your schedule:
- Name: Enter a descriptive name for the schedule
- Type: Choose "Connect" or "Disconnect"
- Profile: (For connect schedules) Select the VPN profile to use
- Time: Enter the time in 24-hour format (e.g., 09:00)
- Repeat: Choose between "Once", "Daily", or "Weekly"
- Weekdays: (For weekly schedules) Select which days to run
Manage your schedules:
- Enable/Disable: Right-click and select "Enable/Disable Schedule"
- Edit: Right-click and select "Edit Schedule" to modify settings
- Delete: Right-click and select "Delete Schedule" to remove
The extension will automatically run your schedules in the background, even when you're not actively using the schedule view.
Visual Indicators
- In Profile Explorer:
- Green shield icon: Active profile that is connected
- Orange/yellow shield icon: Active profile that is connecting or reconnecting
- Red shield icon: Active profile that failed to reconnect
- Standard shield icon: Active profile that is not connected
- Lock icon: Inactive profile
- In Title Bar:
- Play (▶) button: Visible when VPN is disconnected, to connect with active profile
- Stop (■) button: Visible when VPN is connected, to disconnect the VPN
- Stop Circle button: Visible during auto-reconnect, to cancel reconnection attempts
- Restart button: Visible after reconnection failure, to retry connection manually
- Output button: View connection logs
- In Status Bar:
- "VPN: Connected" with highlight background: VPN is currently connected
- "VPN: Reconnecting... (1)" with highlight background: VPN is attempting to reconnect (with attempt count)
- "VPN: Reconnect Failed" with red background: VPN failed to reconnect after all attempts
- "VPN: Disconnected": No active VPN connection
Extension Settings
This extension provides the following settings:
openfortivpn-connector.host
: VPN gateway host address (Legacy setting - use profiles instead)
openfortivpn-connector.port
: VPN gateway port (default: 443) (Legacy setting - use profiles instead)
openfortivpn-connector.username
: VPN account username (Legacy setting - use profiles instead)
openfortivpn-connector.metricsRefreshInterval
: Interval in seconds for refreshing VPN connection metrics (default: 5)
openfortivpn-connector.autoReconnect
: Enable/disable automatic reconnection when connection is lost (default: false)
openfortivpn-connector.autoReconnectMaxRetries
: Maximum number of reconnection attempts (default: 3, range: 1-10)
openfortivpn-connector.autoReconnectInterval
: Interval in seconds between reconnection attempts (default: 10, range: 5-60)
Available Commands
OpenFortiVPN: Toggle Connection
- Connect/disconnect using active profile
OpenFortiVPN: Connect
- Connect using active profile
OpenFortiVPN: Disconnect
- Disconnect the active VPN connection
OpenFortiVPN: Configure
- Open profile management
OpenFortiVPN: Create New Profile
- Create a new VPN profile
OpenFortiVPN: Edit Profile
- Edit selected profile
OpenFortiVPN: Delete Profile
- Delete selected profile
OpenFortiVPN: Set as Active Profile
- Make selected profile active
OpenFortiVPN: Connect to Profile
- Connect using selected profile
OpenFortiVPN: Save Password
- Save password for active profile
OpenFortiVPN: Clear Saved Password
- Clear saved password for active profile
OpenFortiVPN: Manage Profile Password
- Save or clear password for selected profile
OpenFortiVPN: Show Connection Logs
- View detailed VPN connection logs
OpenFortiVPN: Show Connection Metrics
- View VPN connection metrics and statistics
OpenFortiVPN: Refresh Metrics
- Manually refresh metrics data display
OpenFortiVPN: Clear Connection Metrics
- Clear stored VPN connection metrics
OpenFortiVPN: Export Connection Metrics
- Export metrics data to JSON file
OpenFortiVPN: Cancel Auto-Reconnect
- Cancel the auto-reconnect process (New in 1.2.0)
OpenFortiVPN: Retry Connection
- Retry connection after reconnection failure (New in 1.2.0)
OpenFortiVPN: Create New Schedule
- Create a new VPN connection/disconnection schedule (New in 1.2.0)
OpenFortiVPN: Edit Schedule
- Edit an existing schedule (New in 1.2.0)
OpenFortiVPN: Delete Schedule
- Delete a schedule (New in 1.2.0)
OpenFortiVPN: Enable/Disable Schedule
- Toggle schedule active state (New in 1.2.0)
OpenFortiVPN: Refresh Schedules
- Refresh the schedules view (New in 1.2.0)
Troubleshooting
If Connection Fails
- Verify that the
openfortivpn
tool is properly installed.
- Test if the openfortivpn command runs directly in the terminal.
- Confirm that the host, port, and username in your profile are correct.
- Make sure you've entered the correct password as administrator privileges (sudo) are required.
- Check the connection logs using the "Show Connection Logs" command for more details about the error.
If VPN Status Is Not Displayed Correctly
- Try restarting VS Code.
- Check if the ppp0 interface exists using the
ip addr
or ifconfig
command in the terminal.
- View the connection logs to see if any errors were reported during connection attempts.
If Auto-Reconnect Is Not Working
- Verify that auto-reconnect is enabled in the extension settings.
- Make sure you have saved the password for the active profile (auto-reconnect requires a saved password).
- Check the connection logs for any errors during reconnection attempts.
- If reconnection fails after all attempts, use the "Retry Connection" command to try again manually.
License
This extension is distributed under the MIT license. See the LICENSE
file for details.
Contributing
Bug reports, feature requests, or code contributions can be made through the GitHub repository.
Author
Developed by Ruo Lee
👨💻 GitHub
📫 Contact: comsa333@gmail.com
Note: This extension is not affiliated with Fortinet and is not an official Fortinet product. openfortivpn
is a third-party open source tool.