aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Williams2022-04-24 20:22:05 +0200
committerSimon Williams2022-04-24 20:22:05 +0200
commit4d3e1eea26b9f36752fc3ebf6b416da126c8d1cc (patch)
tree2ab3faea8aba7a96365033bb584a4791ba55f612
parentf846dc216c65f798f372baaa9d044c63fb71f93d (diff)
downloadaur-4d3e1eea26b9f36752fc3ebf6b416da126c8d1cc.tar.gz
Added --no-ping an --exclude arguments, blacklist config option
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD4
-rw-r--r--README.md15
-rwxr-xr-xnordquery.py24
4 files changed, 36 insertions, 11 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 32a87ed84c06..f33beb3754ac 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = nordquery
pkgdesc = A tool to choose NordVPN servers based on filters, written in Python
- pkgver = 1.0
- pkgrel = 4
+ pkgver = 1.1
+ pkgrel = 1
url = https://github.com/simonpw/nordquery
arch = any
license = GPL
diff --git a/PKGBUILD b/PKGBUILD
index 2932845f02e1..f85a89c265fd 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Simon Williams <simon@clockcycles.net>
pkgname=nordquery
-pkgver=1.0
-pkgrel=4
+pkgver=1.1
+pkgrel=1
epoch=
pkgdesc="A tool to choose NordVPN servers based on filters, written in Python"
arch=(any)
diff --git a/README.md b/README.md
index 7f486a5e5eb0..38766460e85f 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
usage: nordquery [-h] [-u] [-c country] [-f features] [-p protocols] [--list-protocols] [--server-url] [-v]
-A tool for choosing NordVPN servers, Version 1.0
+A tool for choosing NordVPN servers, Version 1.1
## Options:
@@ -11,8 +11,10 @@ A tool for choosing NordVPN servers, Version 1.0
`-c COUNTRY, --country COUNTRY` - Filter by country.
`-f FEATURES, --number FEATURES` - Filter by server features, see list below
`-p PROTOCOLS, --protocols PROTOCOLS` - Filter by server protocols, see list below
+ `-e EXCLUDE, --exclude EXCLUDE` - Exclude these servers from the list
`--list-protocols` - List the protocol options available
- `--server-url` - Override the default server database url (https://nordvpn.com/api/server)
+ `--server-url` - Override the default server database url (https://nordvpn.com/api/server)
+ `--no-ping` - Don't ping the server to check connectivity
`-v, --verbose` - Be verbose
## Countries:
@@ -62,6 +64,10 @@ The following protocols can be selected with the -p argument:
`--list-protcols` will list these options.
For details of these protocols and their usage consult the NordVPN documentation.
+## Exlude
+
+Servers can be manually exluded using the `-e` or `--exlude` option, enter the server with the short code e.g. `-e us1234`
+
## Configuration file:
A user configuration file can be used in this location: /home/[USER]/.config/nordquery/nordquery.conf
@@ -72,8 +78,9 @@ The structure is:
`always_update = yes/no` - forces an update of the server database with every query
`country = xx` or `any` - an ISO3166 code for the default country
`features = xxx xxx` or `any` - a list of the default features to use, e.g. `sta p2p`
-`db_path` - path to store the server database file, overrides the default (`/home/[USER]/.cache/nordquery`)
-`db_filename` - name for server database file, overrides the default (`server.db`)
+`db_path = /xxx/yyy` - path to store the server database file, overrides the default (`/home/[USER]/.cache/nordquery`)
+`db_filename = xxx` - name for server database file, overrides the default (`server.db`)
+`blacklist = xx1234 yy5678` - Never match these servers
These settings will be overriden by command line arguments.
diff --git a/nordquery.py b/nordquery.py
index 500fbe78b4c0..c5ec647c2abe 100755
--- a/nordquery.py
+++ b/nordquery.py
@@ -65,9 +65,11 @@ def main(argv):
'proxy_cybersec','proxy_ssl','proxy_ssl_cybersec','ikev2_v6','open_udp_v6','open_tcp_v6','wireguard_udp',
'openvpn_udp_tls_crypt','openvpn_tcp_tls_crypt','openvpn_dedicated_udp','openvpn_dedicated_tcp','skylark','mesh_relay'],
metavar='protocol')
+ parser.add_argument('-e', '--exclude' , help='Exclude these servers from the selection', type=str, default='', nargs='+')
parser.add_argument('--list-protocols', help='Show list of protocols', action='store_true')
parser.add_argument('-u', '--update', help='Update the server database', action='store_true')
parser.add_argument('--server-url', help='Override the default server info URL', type=str, default='https://nordvpn.com/api/server')
+ parser.add_argument('--no-ping', help='Don\'t ping the server to check connectivity', action='store_true')
parser.add_argument('-v', '--verbose', help='Be verbose', action='store_true')
args = parser.parse_args()
@@ -178,6 +180,16 @@ def main(argv):
#print(parsed_features)
if(args.verbose and args.protocol != ''): print('Protocols:', args.protocol)
+
+ ##Merge --exlude and blacklist lists
+ exclude_list = []
+ for e in args.exclude:
+ exclude_list.append(e)
+
+ for e in confparse.get('defaults','blacklist',fallback='').split(' '):
+ if((e != '') and (e not in exclude_list)): exclude_list.append(e)
+
+ if(args.verbose and exclude_list != ''): print("Exclude list:", exclude_list)
list_servers = []
@@ -196,7 +208,8 @@ def main(argv):
if((server[1]['flag'] == country_code or country_code == '') and # Match country code
(set(parsed_features).issubset(set(features)) or parsed_features == ['']) and # Match features
- (set(args.protocol).issubset(set(protocols)) or args.protocol == '')): # Match protocols
+ (set(args.protocol).issubset(set(protocols)) or args.protocol == '') and # Match protocols
+ (server[1]['domain'].split('.')[0] not in exclude_list)): # Filter out exluded servers
list_servers.append((server[1]['domain'],server[1]['load'],server[1]['ip_address'])) # Add matched server to list
if(args.verbose):
@@ -211,11 +224,16 @@ def main(argv):
port = 80 # Obfuscated servers don't open port 443
else:
port = 443
- pinged = ping(server[2],port)
+
+ if(not args.no_ping):
+ pinged = ping(server[2],port)
+ else:
+ pinged = 1
+
if(pinged != -1):
if(args.verbose): print('Recommended server: ')
print(server[0].split('.')[0])
- if(args.verbose): print('Ping:', pinged, 'ms')
+ if(args.verbose and not args.no_ping): print('Ping:', pinged, 'ms')
break
elif(args.verbose):
print(server[0], 'timed out')