Skip to content

Commit

Permalink
Save PIA auth config before.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Sep 4, 2023
1 parent 1fdda76 commit e22fd60
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/vpn/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vpn

import (
"context"
"fmt"

"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/vpn"
Expand Down Expand Up @@ -40,6 +41,17 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
vpnRunner, serverName, err = setupOpenVPN(ctx, l.fw,
l.openvpnConf, providerConf, settings, l.ipv6Supported, l.starter, subLogger)
} else { // Wireguard
// save auth in case of PIA for port forwarding and getting the wg config
if *settings.Provider.Name == "private internet access" {
if *settings.OpenVPN.User != "" {
err := l.openvpnConf.WriteAuthFile(*settings.OpenVPN.User, *settings.OpenVPN.Password)
if err != nil {
l.crashed(ctx, fmt.Errorf("writing auth to file: %w", err))
continue
}
}
}

vpnInterface = settings.Wireguard.Interface
vpnRunner, serverName, err = setupWireguard(ctx, l.netLinker, l.fw,
providerConf, settings, l.ipv6Supported, subLogger)
Expand Down

0 comments on commit e22fd60

Please sign in to comment.