# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['connord', 'connord.parser', 'connord.wrappers']

package_data = \
{'': ['*'], 'connord': ['config/*', 'db/*', 'scripts/*']}

install_requires = \
['cachetools>=4.2.4,<5.0.0',
 'jinja2>=3,<4',
 'netaddr>=0.8,<0.9',
 'netifaces>=0.11.0,<0.12.0',
 'progress>=1.6,<2.0',
 'python-iptables>=1.0.0,<2.0.0',
 'pyyaml>=6.0,<7.0',
 'requests>=2.26.0,<3.0.0',
 'setuptools>=57.4.2,<58.0.0']

entry_points = \
{'console_scripts': ['connord = connord.connord:main']}

setup_kwargs = {
    'name': 'connord',
    'version': '0.7.0',
    'description': 'Connect to NordVPN servers',
    'long_description': '<h1 align="center">C&#xF8;nN&#xF8;rD</h1>\n<h2 align="center">Connect to NordVPN servers secure and fast</h2>\n\n<p align="center">\n<a href="https://github.com/ambv/black"><img alt="Code Style: Black" src="https://img.shields.io/badge/code%20style-black-black.svg?style=flat-square"></a>\n<a href="https://choosealicense.com/licenses/gpl-3.0/"><img alt="License" src="https://img.shields.io/badge/license-GPL--3.0--or--later-green.svg?style=flat-square"></a>\n<a href="https://docs.python.org/"><img alt="Python Version" src="https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9%20%7C%203.10-blue.svg?style=flat-square"></a>\n<a href="https://github.com/MaelStor/connord"><img alt="GitHub tag (latest SemVer)" src="https://img.shields.io/github/tag/MaelStor/connord.svg?style=flat-square"></a>\n<a href="https://travis-ci.com/MaelStor/connord/"><img alt="Travis (.com) branch" src="https://img.shields.io/travis/com/MaelStor/connord/master.svg?style=flat-square"></a>\n<a href="https://github.com/MaelStor/connord"><img alt="Coveralls github" src="https://img.shields.io/coveralls/github/MaelStor/connord.svg?style=flat-square"></a>\n</p>\n\n---\n\nConnord connects to NordVPN servers by wrapping\n[OpenVPN](https://openvpn.net/community-resources/#articles) and iptables. Most\ntools, including the official nordvpn app do not allow customising iptables\nproperly. Often, iptables rules are left in a mess when finished and may even\nlead to unexpected behaviour. Additionally, the native openvpn application lacks\nkind of connection profiles, to easily switch between configurations depending\non your network you are currently using, for example on your laptop. Connord\nconnects you to NordVPN servers, wrapping openvpn and iptables to provide a\nrich, powerful and simple to use tool chain orchestrated from the command line.\n\nThis tool is not for you, if you want to connect to nordvpn servers via NordLynx\nor use other special nordvpn technologies. Connord connects you via openvpn over\nthe udp port 1196 or tcp port 443. If openvpn is patched correctly it connects\nyou to obfuscated servers. This should cover the most use cases, but it won\'t do\nanything more... Use the official nordvpn tool instead if you wish to use\nCyberSec etc.\n\nHowever, compared to other tools, connord can deliver more information about\nservers, areas, countries etc., easily accessible from the command line, with\nits extensive filters. It also uses a powerful and yet simple mechanism to\ndetermine the fastest NordVPN server for your location without gathering any\ninformation about your exact place. It is less intrusive than other tools\nbecause there is no need to install systemd services per default and just works\nwithin your terminal.\n\n## Version/Change notes\n\nIf you\'re already using connord and want to update from an earlier version it is\nbest to completely uninstall connord first. Then follow the Installation\ninstructions from this document. Connord is still under development and each\nminor version (the `x` in `0.x.y`) difference is not backwards compatible. Save\nyour configuration files and adjust them to the new ones if necessary.\nCurrently, (as of `0.6.0`) only the `/etc/connord/config.yml` file has\nadditional configuration options. Iptables rules and fallback files still follow\nthe same scheme but the variables exposed to `.rules` and `.fallback` files\nhave changed. The \'lan\' and \'gateway\' dictionaries were removed. Instead, there\nis the new \'gateways\' dictionary available. For a complete description see the\nchanged [Variables](#Variables) section. The default `.rules` and `.fallback`\ncoming with connord have changed to support a wider range of systems and an\neasy start with connord.\n\n## Dependencies\n\n- iptables\n- openvpn\n- Either resolvconf or systemd-resolved to correctly route the dns traffic\n- and the python package dependencies of connord. See Installation section.\n\n## Quick start guide\n\n- Follow Installation instructions below\n- Download or update the openvpn configuration files for nordvpn with\n  `$ sudo connord update`.\n- Execute `$ sudo connord connect -c YOUR_COUNTRY_CODE` and replace\n  YOUR_COUNTRY_CODE with the country code of your current country. List all\n  country codes with `$ connord list countries`. You will be asked for your\n  username and password which are stored safely in\n  `/etc/connord/openvpn/nordvpn/credentials`.\n\n## Installation\n\nInstall the system dependencies depending on your distribution with\n\n### Ubuntu/Debian\n\n    $ sudo apt-get update\n    $ sudo apt-get install iptables openvpn\n\n### Archlinux\n\n    $ sudo pacman -Sy iptables openvpn\n\nFor the up down scripts of openvpn there needs either `resolvconf` or\n`systemd-resolved` to be installed and configured on your system. Connord\nautomatically detects which one is used. Other systems are currently not\nnatively supported, but by providing own `openvpn_up_down` scripts this can be\ncircumvented.\n\n#### Installation from source\n\nThis is currently the recommended method to install connord, because it creates\nall the directories needed in `/etc/connord` to get the most out of connord.\n\n    $ git clone https://github.com/MaelStor/connord\n    $ cd connord\n    $ sudo make install\n\nRemark, that this doesn\'t install the dependencies of connord, since your\ndistribution most likely offers packages for them, and this is usually the best\nway to go, so you are best advised to install the dependencies of connord with\nyour distribution\'s package manager. In case you don\'t want to manage python\ndependencies with the distribution\'s package manager, you can still install\nconnord with `pip` (See below). Installation of the python packages:\n\n###### Ubuntu/Debian\n\n    $ sudo apt-get install python3-cachetools python3-jinja2 python3-netaddr \\\n        python3-netifaces python3-progress python3-iptables python3-yaml \\\n        python3-requests python3-setuptools\n\n###### Archlinux\n\nYou need to install the `python-iptables` package from the aur repository. So\nfor example with pacaur execute:\n\n    $ sudo pacaur -Sy python-cachetools python-jinja python-netaddr \\\n        python-netifaces python-progress python-iptables python-yaml \\\n        python-requests python-setuptools\n\nYou can start right off or customize connord in `/etc/connord/config.yml` and\nadjust the iptables rules in `/etc/connord/iptables/*`.\n\n#### Installation of connord with pip\n\n    $ pip install --user --upgrade connord\n\nYou need to run commands that need root access with\n\n    $ sudo $(which connord) connect -c de\n\ninstead. Global installation although not recommended since this also installs\nthe dependencies of connord globally:\n\n    $ sudo pip install --upgrade connord\n\n## Configuration\n\nAll configuration files since version 0.5.0 reside in the `/etc/connord`\nhierarchy. The configuration files are documented with the most recent\nconfiguration values. Here just a quick overview to get started. \n\nThe main configuration file is `/etc/connord/config.yml`. Iptables rules can be\nadjusted in `/etc/connord/iptables/`.\n\n#### The main configuration file: config.yml\n\nThe main configuration file in [YAML](https://yaml.org/) format. Every variable\nset within this configuration file is exposed to .rules and .fallback \niptables templates.\n\n###### config.yml: iptables section\n\nThis section may look like this:\n\n<pre>\niptables\n  dns:\n    # NordVPN\n    - \'103.86.99.100/32\'\n    - \'103.86.96.100/32\'\n</pre>\n\nUse these variables for example in 01-filter.rules:\n\n<pre>\nOUTPUT:\n  policy: ACCEPT\n  action: None\n  rules:\n{% for server in iptables.dns %}\n  - dst: "{{ server }}"\n    protocol: udp\n    udp:\n      dport: \'53\'\n    target: ACCEPT\n{% endfor %}\n</pre>\n\nwhat creates the following after rendering:\n\n<pre>\nOUTPUT:\n  policy: ACCEPT\n  action: None\n  rules:\n  - dst: \'103.86.99.100/32\'\n    protocol: udp\n    udp:\n      dport: \'53\'\n    target: ACCEPT\n  - dst: \'103.86.96.100/32\'\n    protocol: udp\n    udp:\n      dport: \'53\'\n    target: ACCEPT\n</pre>\n\nRendering is happening automatically, so no user side intervention is required.\n\n###### config.yml: openvpn section\n\nThe settings which are used to start openvpn can be found in `config.yml`. For\nan overview of all possible options see `$ man openvpn`. You just need to strip\noff the leading \'--\' and place it somewhere in the openvpn section. Arguments\nare written after `:` or if the option doesn\'t take any arguments place `True`\nafter `:`. Further reading\nabout [YAML Syntax](https://yaml.org/spec/1.1/spec.html). There\'s the special\nkeyword\n`built-in`, which can be applied to:\n\n- auth-user-pass\n- scripts paths\n    - name: up\n    - name: down\n    - name: ipchange\n\nif you like to use the built-in paths, what is the default behaviour. If you\ndon\'t like to run a script say when openvpn goes down delete or comment out\n\n<pre>\n    - name: "down"\n      path: "built-in"\n      stage: "down"\n      creates: "down.env"\n</pre>\n\n#### Iptables rules\n\nThe iptables rules reside in `/etc/connord/iptables`.\n\n###### rules and fallback files\n\nThese files are [jinja2](http://jinja.pocoo.org/docs/2.10/) templates which are\nrendered with the `config.yml` file and `.env` files created by the built-in\n`up`, `down` and `ipchange` scripts when openvpn starts running.\n\n###### Naming scheme\n\nLet\'s take for example the rules file which shall be applied to netfilter\'s\n`filter` table. `01-filter.rules`. The leading number isn\'t necessary, but that\nway you can control the order when to apply the files. After the optional dash\nfollows the table name. The dash isn\'t needed when there is no leading number.\nThe suffix `.rules` causes the rules to be applied after successfully\nestablishing a connection to a server. The suffix `.fallback` causes the rules\nto be applied when disconnecting from a server or after invocation of `connord\niptables flush`. If you\'re writing ipv6 rules for the `filter` table place them\nin a file like `01-filter6.rules` or `01-filter6.fallback`.\n\n#### Variables\n\nEvery variable you define or is already defined in `config.yml` is available in\niptables rules files. In addition to that the connord instance exposes the\nfollowing variables to `.rules` and `.fallback` files:\n\n<pre>\nvpn_remote      # the remote server ip address\nvpn_protocol    # the protocol in use: udp or tcp\nvpn_port        # may be 1194 (udp) or 443 (tcp)\n\n# Furthermore there\'s the \'gateways\' dictionary consisting of\ngateways.default = (ip_address, interface)\n#  a tuple of ip_address and interface name of the default gateway. Note that\n#  the default gateway in rules files is the VPN gateway (most often \'tun0\')\n#  and in fallback files it is the LAN interface.\ngateways.default_inet6\n#  like above a tuple of ip_address and interface name but in case the default\n#  gateway has ipv6 nature.\ngateways.other = [(ip_address, interface), ... ]\n#  with a list of ip_address, interface tuples which are not the default\n#  gateway. The list may be empty if there are no other interfaces.\ngateways.other_inet6\n#  like above but if the interface has ipv6 nature.\n</pre>\n\nIn `fallback` files `vpn_remote` is `0.0.0.0/0`, `vpn_protocol` is `udp` and\n`vpn_port` is set to `1194`.\n\nVariables exposed from OpenVPN scripts can be seen when starting connord not in\ndaemon mode. The list given here may be incomplete or too exhaustive for your\nnetwork and is therefore just an incomplete preview. Look at the output of\nconnord for your environment. For example here the variables from `up.env` when\nthe connection is started by openvpn.\n\n<pre>\nconnord \'up\' environment variables: \'/var/run/connord/up.env\'\nup_args:\n  - \'init\'\n  - \'255.255.255.0\'\n  - \'10.8.1.10\'\n  - \'1590\'\n  - \'1500\'\n  - \'tun1\'\n  - \'/var/run/connord/up.env\'\ndhcp_option:\n  dns:\n    - \'103.86.99.100\'\n    - \'103.86.96.100\'\ndev: \'tun1\'\nifconfig_broadcast: \'10.8.1.255\'\nifconfig_local: \'10.8.1.10\'\nifconfig_netmask: \'255.255.255.0\'\nlink_mtu: \'1590\'\nroute_net_gateway: \'200.200.200.200\'\nroute_vpn_gateway: \'10.8.1.1\'\nscript_context: \'init\'\ntun_mtu: \'1500\'\ntrusted_ip: \'100.100.100.100\'\ntrusted_port: \'1194\'\nuntrusted_ip: \'100.100.100.100\'\nuntrusted_port: \'1194\'\nredirect_gateway: 1\n</pre>\n\nVariables from OpenVPN scripts are only available in `.rules` files, not\n`.fallback` files.\n\n## Usage\n\nCommand-line options overwrite the configuration in `config.yml`. This is mostly\nimportant for the openvpn command line options passed through to openvpn. To\nconnect to nordvpn servers and alter iptables rules connord needs to be executed\nas root. Most subcommands, especially the list subcommand, do not need root\naccess.\n\n#### Subcommands\n\nFirst, list all possible commands with `$ connord --help`. Any sub command has a\nhelp and can be accessed with `$ connord SUBCOMMAND --help`. Before connecting\nto a server and execute connord with root rights, you may wish to play around\nwith connord commands and start with listing servers `$ connord list servers`.\nSee below for more information about the list subcommand.\n\n#### Connect to NordVPN servers\n\nConnecting to nordvpn servers is done with `$ sudo connord connect`. No further\noptions are required, but limiting the possible servers may be what you want if\nyou want a faster connection. However, connord tries its best to figure out the\nbest server. Internally it sorts the servers by load and then by their ping. \nThen it tries to connect to the server with the lowest load and lowest ping.\n\nFor instance, if limiting servers to the country you\'re living in is what you\nwant, pass the `--country COUNTRY_CODE` to the connect command. The country code\nis a two letter abbreviation of a country. All possible country codes can be\nlisted with `$ connord list countries`.\n\nThere are many other options to filter the servers connord tries to connect to.\nSee `$ connord connect --help` for all possible options.\n\n#### Manage Iptables\n\nManaging iptables with connord can be done with `$ connord iptables ACTION`\nwhere valid ACTIONs can be listed with `$ connord iptables --help`. Before\ntaking any action make sure to save your original iptables rules. This can be\ndone for example with `$ sudo iptables-save > /etc/iptables/iptables.rules`. For\nyour safety any connord command modifying system files and iptables rules needs\nroot access for example with sudo.\n\n#### Listings\n\nList all possible countries, features, categories (types), servers, iptables\nrules etc. See what is possible with `$ connord list --help`. All sub commands\nto the list command try to help with the usage of connord or provide additional\ninformation about a topic.\n\n###### Servers\n\nListing servers can be done with `$ connord list servers`. As with the connect\ncommand, there are a lot of options to limit the servers in the output. The\noutput of the list command may help in figuring out which servers are available\nor help with the connect command. Most options here are also available in the\nconnect command, so running the `list servers` command beforehand helps to\nreduce the servers to the servers you really want to wish to connect to. More\nhelp can be seen with `$ connord list servers --help`.\n\n#### Update NordVPN server configuration files and the location database\n\nUpdating the configuration files and database must be done once after\ninstallation and after that on a regular basis to ensure connord uses the latest\npossible servers and correct openvpn configuration.\n\nTo do so, just execute `$ connord update`\n\n## Supported FEATUREs:\n\nHave a look at the output of `$ connord list features`\n\n## Supported TYPEs:\n\nAll supported types are listed with `$ connord list categories`. The term\n`types` and `categories` are used interchangeably\n\n## General section\n\nIf you experience problems running connord, first try the same command in\nverbose mode with\n\n    connord -v COMMAND\n\nor\n\n    connord --verbose COMMAND\n\nYou should see in most cases where the error occurred. There may be still hard\nto track bugs, please report them to the Issue board on\n[Github](https://github.com/MaelStor/connord/issues).\n\nError messages are written to stderr in your shell. You can suppress error\nmessages with `-q` or `--quiet` if you like to.\n\nVerbose mode of `openvpn` can be set in `config.yml` in the openvpn section or\nat the command-line when using `connord connect` adding it to the openvpn\ncommand with `-o \'--verb 3\'`.\n\n## Obfuscated servers\n\nIn order to be able to connect to obfuscated servers you need to\n[patch](https://github.com/clayface/openvpn_xorpatch) OpenVPN. For example the\nrepository of [Tunnelblick](https://github.com/Tunnelblick/Tunnelblick) includes\nthe patches in third_party/sources/openvpn. How this can be done is described\n[here](https://www.reddit.com/r/nordvpn/comments/bsbxt6/how_to_make_nordvpn_obfuscated_servers_work_on/)\n. I haven\'t patched my openvpn client, so I can\'t share experiences but above\nsolution is reported to work.\n\nYou can list obfuscated servers with `$ connord list servers -t obfuscated`.\nSame scheme to finally connect to an obfuscated server for example located in\nHongKong: `$ sudo connord connect -c hk -t obfuscated`.\n\n## Development\n\nMake sure to have `poetry` installed. Clone the repo and install the development\nenvironment:\n\n    $ git clone git@github.com:MaelStor/connord.git\n    $ cd connord\n    $ make develop\n\n## Thanks\n\nThanks to Jonathan Wright @ https://github.com/jonathanio for his great\nupdate-systemd-resolved\nscript (https://github.com/jonathanio/update-systemd-resolved)',
    'author': 'Mael Stor',
    'author_email': 'maelstor@posteo.de',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/MaelStor/connord',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
