Skip to content

herlon214/nordvpn

Repository files navigation

NordVPN

codecov Build Status

This lib uses the nordvpn servers endpoint to fetch data in order to make your life easier when using NordVPN servers.

$ go get github.com/herlon214/nordvpn

Usage

package main
import (
    "time"

    "github.com/herlon214/nordvpn"
    "github.com/sirupsen/logrus"
)

func main() {
    maxCacheTime := time.Hour * 1
    logger := logrus.New()
    nvpn := nordvpn.New(maxCacheTime, logger)
    nvpn.SetOperators(
    		nordvpn.FilterOnline(),
    		nordvpn.FilterByCountry("NL"),
    		nordvpn.FilterByTechnology("ikev2"),
    )
    
    nvpn.EnableAutoUpdate() // Optional, will auto update the server list when the cache is expired
    
    // Fetch the servers
    servers := nvpn.Get() // []Servers
    
    // do something with servers
}

Available operators

Function Args example Description
FilterOnline(), - Filter online servers
FilterByTechnology(technologies ...string) "proxy","ikev2" Filter by server's technology, you can specify many
FilterByCountry(code string) "BR" Filter by country code
SortByLoadAsc() - Sort servers by load in ascending order
SortByLoadDesc - Sort servers by load in descending order