New PIA servers support (#227)
* Adapt storage: SyncServers write to file option, export FlushToFile * CLI built-in updater for old and new PIA servers * Update hardcoded IP addresses for PIA old and new servers * Add PIA old to allServers struct and update timestamps * Adapt code to work with new and old PIA servers * Remove PIA subdomains (unneeded) from resolver tool
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/gluetun/internal/storage"
|
||||
"github.com/qdm12/gluetun/internal/updater"
|
||||
"github.com/qdm12/golibs/files"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
)
|
||||
@@ -56,7 +57,7 @@ func OpenvpnConfig() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
allServers, err := storage.New(logger).SyncServers(constants.GetAllServers())
|
||||
allServers, err := storage.New(logger).SyncServers(constants.GetAllServers(), false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -78,3 +79,28 @@ func OpenvpnConfig() error {
|
||||
fmt.Println(strings.Join(lines, "\n"))
|
||||
return nil
|
||||
}
|
||||
|
||||
func Update(args []string) error {
|
||||
var options updater.Options
|
||||
flagSet := flag.NewFlagSet("update", flag.ExitOnError)
|
||||
flagSet.BoolVar(&options.File, "file", false, "Write results to /gluetun/servers.json (for end users)")
|
||||
flagSet.BoolVar(&options.Stdout, "stdout", false, "Write results to console to modify the program (for maintainers)")
|
||||
flagSet.BoolVar(&options.PIA, "pia", false, "Update Private Internet Access post-summer 2020 servers")
|
||||
flagSet.BoolVar(&options.PIAold, "piaold", false, "Update Private Internet Access pre-summer 2020 servers")
|
||||
if err := flagSet.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
logger, err := logging.NewLogger(logging.ConsoleEncoding, logging.InfoLevel, -1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !options.File && !options.Stdout {
|
||||
return fmt.Errorf("at least one of -file or -stdout must be specified")
|
||||
}
|
||||
storage := storage.New(logger)
|
||||
updater := updater.New(storage)
|
||||
if err := updater.UpdateServers(options); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user