Skip to content

Commit

Permalink
In '--connect profile-name' make the extension (.ovpn) optional
Browse files Browse the repository at this point in the history
Treat '--connect foo.ovpn' and '--connect foo' as the same. This matches
with the behaviour of '--command connect foo'.

Note: the argument is first compared against config file names and then
against config names.

Based on comment by larson0815 here:
selvanair#5

Signed-off-by: Selva Nair <selva.nair@gmail.com>
  • Loading branch information
selvanair committed Jan 20, 2018
1 parent eb52950 commit 10f3458
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
13 changes: 1 addition & 12 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,10 @@ static int
VerifyAutoConnections()
{
int i;
BOOL match;

for (i = 0; i < MAX_CONFIGS && o.auto_connect[i] != 0; i++)
{
int j;
match = FALSE;
for (j = 0; j < MAX_CONFIGS; j++)
{
if (_tcsicmp(o.conn[j].config_file, o.auto_connect[i]) == 0)
{
match = TRUE;
break;
}
}
if (match == FALSE)
if (GetConnByName(o.auto_connect[i]) == NULL)

This comment has been minimized.

Copy link
@drago2159

drago2159 Oct 25, 2018

(GetConnect_ByName(o.auto_connect[i]) == NULL)

This comment has been minimized.

Copy link
@selvanair

selvanair Oct 25, 2018

Author Collaborator

GetConnByName() is correct -- that function was added in commit 0f21030 that implemented the feature to send commands to a running instance.

{
/* autostart config not found */
ShowLocalizedMsg(IDS_ERR_AUTOSTART_CONF, o.auto_connect[i]);
Expand Down
3 changes: 2 additions & 1 deletion openvpn_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ AddConfigFileToList(int config, const TCHAR *filename, const TCHAR *config_dir)
/* Check if connection should be autostarted */
for (i = 0; i < MAX_CONFIGS && o.auto_connect[i]; ++i)
{
if (_tcsicmp(c->config_file, o.auto_connect[i]) == 0)
if (_tcsicmp(c->config_file, o.auto_connect[i]) == 0
|| _tcsicmp(c->config_name, o.auto_connect[i]) == 0)
{
c->auto_connect = true;
break;
Expand Down

0 comments on commit 10f3458

Please sign in to comment.