edgd1er / nordvpn-proxy

NordVPN openVPN socks
26 stars 8 forks source link

Need NORDVPN_SERVER #9

Closed quyeticb closed 2 years ago

quyeticb commented 2 years ago

Hello, can you add option configure NORDVPN_SERVER? (now only NORDVPN_COUNTRY)

edgd1er commented 2 years ago

Hello, I'm not sure the api has a filter to select server. What would be a value for NORDVPN_SERVER ?

edgd1er commented 2 years ago

Queries with hostname or name have not the expected results:

https://api.nordvpn.com/v1/servers/recommendations?filters[hostname]=lt10.nordvpn.com&limit=1 https://api.nordvpn.com/v1/servers/recommendations?filters[name]=xxxxx&limit=1

as the implementation is not public I have no idea how to find the proper way to query a hostname ?

A way to have a similar feature would be to try to download a configuration with the fqdn of the server given in the NORDVPN_SERVER parameter.

NORDVPN_SERVER=nl542.nordvpn.com config url would be https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/nl542.nordvpn.com.tcp.ovpn if NORDVPN_PROTOCOL is set to tcp or not set.

edgd1er commented 2 years ago

commit https://github.com/edgd1er/nordvpn-proxy/commit/3811966983e41825ee3ee5ffccc8d7b5ad06d566 is based on these remarks.

A build is in progress. In a few minutes, the new image will be available from docker's hub.

quyeticb commented 2 years ago

Thank you, but seem it's not working.

- NORDVPN_SERVER=sg460.nordvpn.com
- NORDVPN_COUNTRY=Singapore #Optional, by default, servers in user's coyntry.

Logs:

2022-01-05 06:56:53 PING: ok, configurations download site reachable
2022-01-05 06:56:53 Removing existing configs in /etc/service/openvpn/nordvpn
2022-01-05 06:56:53 Selecting the best server...
2022-01-05 06:56:53 Searching for country : Singapore (195)
2022-01-05 06:56:53 Searching for group: legacy_p2p
2022-01-05 06:56:53 Searching for technology: openvpn_tcp
crond: USER root pid  75 cmd /etc/service/openvpn/resolvcheck.sh
2022-01-05 06:57:00: RESOLVCHECK: ERROR: Not using unbound.restarting it.
2022-01-05 06:57:00: INFO: UNBOUND: set configuration dns unbound
2022-01-05 06:57:00: INFO: UNBOUND : copy original resolv conf
2022-01-05 06:57:00: INFO: UNBOUND : check unbound conf
unbound-checkconf: no errors in /config/unbound.conf
2022-01-05 06:57:00: INFO: UNBOUND : start unbound
[1641387420] unbound[92:0] notice: Start of unbound 1.13.2.
ok: run: unbound: (pid 83) 0s, normally down
2022-01-05 06:56:53 Best server : sg466.nordvpn.com, load: 18
2022-01-05 06:56:53 Downloading config: sg466.nordvpn.com.ovpn
2022-01-05 06:56:53 Downloading from: https://downloads.nordcdn.com/configs/files/ovpn_tcp/servers/sg466.nordvpn.com.tcp.ovpn

Server: sg466 is selected not sg460

And, Can you add local .ovpn if exists (.ovpn from local folder)

edgd1er commented 2 years ago

I'm afraid you don't have the latest container's image. When setting NORDVPN_SERVER, all calls to nordvpn api are bypassed to download the given server's configuration.

You shouldn't see :

2022-01-05 06:56:53 Selecting the best server...
2022-01-05 06:56:53 Searching for country : Singapore (195)
2022-01-05 06:56:53 Searching for group: legacy_p2p
2022-01-05 06:56:53 Searching for technology: openvpn_tcp

but rather:

nordvpn-proxy-proxy-1  | PING: ok, configurations download site reachable
nordvpn-proxy-proxy-1  | Removing existing configs in /etc/service/openvpn/nordvpn
nordvpn-proxy-proxy-1  | server : sg460.nordvpn.com, load: 19
nordvpn-proxy-proxy-1  | Downloading config: sg460.nordvpn.com.ovpn
nordvpn-proxy-proxy-1  | Downloading from: https://downloads.nordcdn.com/configs/files/ovpn_udp/servers/sg460.nordvpn.com.udp.ovpn
nordvpn-proxy-proxy-1  | 
nordvpn-proxy-proxy-1  | 2022-01-06 08:18:14: INFO: OVPN: Files found: 1
nordvpn-proxy-proxy-1  | 2022-01-06 08:18:14: INFO: OVPN: Current load: 75
nordvpn-proxy-proxy-1  | 2022-01-06 08:18:14: INFO: OVPN: config: /etc/service/openvpn/nordvpn/sg460.nordvpn.com.ovpn

please pull latest version.

alpe12 commented 2 years ago

@edgd1er I don't use this option and I'm having problems with the newest version.

Removing existing configs in /etc/service/openvpn/nordvpn
/etc/service/openvpn/nordvpn/configure-openvpn.sh: line 248: NORDVPN_SERVER: unbound variable
2022-01-06 18:56:23: ########################################################
2022-01-06 18:56:23: INFO: openvpn: stopping
2022/01/06 18:56:23 socat[628] E connect(5, AF=1 "/run/openvpn.sock", 19): No such file or directory
Checking curl installation
DNS: resolution ok
PING: ok, configurations download site reachable
Removing existing configs in /etc/service/openvpn/nordvpn
/etc/service/openvpn/nordvpn/configure-openvpn.sh: line 248: NORDVPN_SERVER: unbound variable
2022-01-06 18:56:25: ########################################################
2022-01-06 18:56:25: INFO: openvpn: stopping
2022/01/06 18:56:25 socat[642] E connect(5, AF=1 "/run/openvpn.sock", 19): No such file or directory
Checking curl installation
DNS: resolution ok
version: '3.8'
services:
  nordvpn-proxy:
    image: edgd1er/nordvpn-proxy:latest
    container_name: nordvpn-proxy
    restart: unless-stopped
    ports:
      - "8119:1080"
      - "8118:8118/tcp"
    sysctls:
      - net.ipv4.conf.all.rp_filter=2
    cap_add:
      - NET_ADMIN
    environment:
      - TZ=America/Sao_Paulo
      - NORDVPN_USER=myuser
      - NORDVPN_COUNTRY=Brazil
      - NORDVPN_PROTOCOL=udp
      - NORDVPN_LOGIN=myuser
      - NORDVPN_PASS=mypass
      - OPENVPN_PARAMETERS=--auth-nocache
      - LOCAL_NETWORK=mynetwork/24
      - TINYPORT=8118
      - TINYLOGLEVEL=Error
      - DANTE_LOGLEVEL="error"
      - DANTE_ERRORLOG=/dev/stdout
      - DEBUG=0
      - CRON=30 * * * *

See this for possible solution: https://unix.stackexchange.com/a/463037

edgd1er commented 2 years ago

@alpe12 , I see the problem. I'll have a look. sorry for the trouble.

as a temporary fix you could add a line - NORDVPN_SERVER= in your compose file. the container will start based on other parameters, define all of them as a add set -uin the bash that forbid unbound variables, hence the errors.

alpe12 commented 2 years ago

@edgd1er Now this:

Checking NORDPVN API responses
grep: unrecognized option: P
BusyBox v1.33.1 () multi-call binary.

Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H        Add 'filename:' prefix
        -h        Do not add 'filename:' prefix
        -n        Add 'line_no:' prefix
        -l        Show only names of files that match
        -L        Show only names of files that don't match
        -c        Show only count of matching lines
        -o        Show only the matching part of line
        -q        Quiet. Return 0 if PATTERN is found, 1 otherwise
        -v        Select non-matching lines
        -s        Suppress open and read errors
        -r        Recurse
        -R        Recurse and dereference symlinks
        -i        Ignore case
        -w        Match whole words only
        -x        Match whole lines only
        -F        PATTERN is a literal (not regexp)
        -E        PATTERN is an extended regexp
        -m N        Match up to N times per file
        -A N        Print N lines of trailing context
        -B N        Print N lines of leading context
        -C N        Same as '-A N -B N'
        -e PTRN        Pattern to match
        -f FILE        Read pattern from file
2022-01-06 19:25:26: ########################################################
2022-01-06 19:25:26: INFO: openvpn: stopping
2022/01/06 19:25:26 socat[1504] E connect(5, AF=1 "/run/openvpn.sock", 19): No such file or directory

Possibly this line: https://github.com/edgd1er/nordvpn-proxy/blame/a2af76846461818eaa1bfa1987400871609f2ba8/app/openvpn/nordvpn/configure-openvpn.sh#L263

edgd1er commented 2 years ago

arf, this is unfortunate. I 've already fixed those unbound errors, I cannot test anymore the problem. I did not experience that with the very fast test I v done before giving you the advice. Could alpine distribution may differ between two architecture. At the time being, i'm testing it on a amd64. what is your cpu architecture ?

I have build and push a new image. Could git it a try ?

alpe12 commented 2 years ago

Could alpine distribution may differ between two architecture.

Probably.

what is your cpu architecture ?

arm64.

I have build and push a new image. Could git it a try ?

Same grep error. :/

edgd1er commented 2 years ago

Ok, i ll look for a solution tomorrow ( grep - E might be a candidate ).

alpe12 commented 2 years ago

i ll look for a solution tomorrow

No problem, thanks. You can get the architecture with apk --print-arch and run different commands depending if it's arm or not.

edgd1er commented 2 years ago

added in commit https://github.com/edgd1er/nordvpn-proxy/commit/d91e70663adc549e86a583f718a24f886bc5f9d4