Skip to content

Commit

Permalink
Make vpn-server a package and onboard to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Jan 10, 2022
1 parent d9efeca commit 618ac8f
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 84 deletions.
232 changes: 232 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
Change Log
==========

0.4.6 (01/09/2022)
------------------
- Make `vpn-server` a package and onboard to pypi

0.4.5 (01/09/2022)
------------------
- Automate onboarding to pypi

0.4.4 (01/09/2022)
------------------
- Remove `os.system` usage and introduce hybrid logger

0.4.3 (01/09/2022)
------------------
- Add a note on firewall configuration ports

0.4.2 (01/02/2022)
------------------
- Change sensitive values to a list to hide from logs
- Do not log server info

0.4.1 (01/02/2022)
------------------
- Hide port number and password from the logs
- Add timeout and display options as arguments
- Add one more option to test/update existing connection

0.4.0 (01/01/2022)
------------------
- Add more logging and remove unnecessary args
- Pass the initial 'yes' as part of the configuration dict
- Bump timeout to 30 seconds

0.3.9 (01/01/2022)
------------------
- Restructure static methods into a single module

0.3.8 (01/01/2022)
------------------
- Use paramiko for interactive ssh commands
- Get rid of the OS limitation
- Improve the overall speed of configuration
- Add an option to reconfigure

0.3.7 (12/31/2021)
------------------
- Upgrade gmailconnector version
- Update year in LICENSE file

0.3.6 (10/04/2021)
------------------
- Strip https from notification URL
- Distinguish attempt wise notification
- Log a warning message if env vars for notification is missing

0.3.5 (09/24/2021)
------------------
- FEATURE::Sends a notification when a second instance is triggered
- Swap delete security group and sleeper

0.3.4 (09/24/2021)
------------------
- Simplify notification process
- Add logs to .gitignore

0.3.3 (09/23/2021)
------------------
- Write only to file when triggered by Jarvis
- Remove root logger
- Move sleeper within class

0.3.2 (09/23/2021)
------------------
- Add `loggingWrapper` for file and console logging
- Create log files when triggered by `Jarvis`
- Add datetime to email subject to avoid threads

0.3.1 (09/22/2021)
------------------
- Add optional email notification upon vpn startup

0.3.0 (09/21/2021)
------------------
- Fix buggy walrus operator which kept failing notifications
- Reduce file IO operations
- Strip https from url in notification
- Increase wait time while shutting down vpn
- Modify sleeper in _instance_info
- Remove optional arguments

0.2.9 (09/21/2021)
------------------
- Split sleep time as its own function to avoid redundancy

0.2.8 (09/21/2021)
------------------
- Log results of notification
- Change method name to avoid conflict with module
- Add waiting time for file IO to finish

0.2.7 (09/20/2021)
------------------
- Add a feature to send login details via SMS
- Update requirements.txt and docstrings

0.2.6 (09/20/2021)
------------------
- Add custom `PORT` number feature

0.2.5 (09/20/2021)
------------------
- Add `VPN_USERNAME` option for custom login info
- Write region name in `server_info.json`
- Add a color to terminal
- Update README.md and docstrings

0.2.4 (09/20/2021)
------------------
- Update styling in `README.md` to populate in sphinx docs

0.2.3 (09/20/2021)
------------------
- Use region specific AMI IDs
- Add more info on env vars to README.md
- Clean up and update docstrings

0.2.2 (09/20/2021)
------------------
- Redirect client traffic via VPN automatically
- Update README.md and add applescript in docstring

0.2.1 (09/20/2021)
------------------
- Optionally load `env-vars` from `.env` file

0.2.0 (09/20/2021)
------------------
- Make script to initiate only from `commandline`
- Don't exit script until `SecurityGroup` is deleted
- Update requirements.txt and docs

0.1.9 (09/16/2021)
------------------
- Change branch name to `main` to pick up page build

0.1.8 (09/16/2021)
------------------
- Add manual config info for `Windows OS`
- Clean up
- Update README.md and docs

0.1.7 (09/16/2021)
------------------
- FEATURE::Spins up a VPN Server on EC2 with a single click
- Add all the automation bits
- Add time converter to calculate run time
- Add an apple script for the automation
- Add functionality to re-use AWS resources

0.1.6 (09/16/2021)
------------------
- Setup github action for docs

0.1.5 (09/15/2021)
------------------
- Add features to create and delete `SecurityGroups`
- Reconfigure flow of code
- Update docstrings and docs

0.1.4 (09/15/2021)
------------------
- Proceed to terminate instance even when `KeyPair` deletion fails
- Add access key and secret id as optional arguments during class initialization

0.1.3 (09/15/2021)
------------------
- First automation to add `ip` and `host` entry in known_hosts file

0.1.2 (09/15/2021)
------------------
- Delete recent instance if an instance id is not provided to terminate
- Delete instance_info.json while terminating an instance

0.1.1 (09/14/2021)
------------------
- Onboard sphinx auto docs
- Add pre-commit and sync up with doc generation
- Rename repo from openvpn to vpn-server

0.1.0 (09/14/2021)
------------------
- Update README.md

0.0.9 (09/14/2021)
------------------
- Wrap everything inside a class and add docstrings

0.0.8 (09/14/2021)
------------------
- Add exception handlers where necessary

0.0.7 (09/14/2021)
------------------
- Get public dns name and public ip address and write as JSON

0.0.6 (09/14/2021)
------------------
- Add functions to delete keypair and terminate instance

0.0.5 (09/14/2021)
------------------
- Add logging instead of print statements

0.0.4 (09/14/2021)
------------------
- Create pem file while spinning up an instance

0.0.3 (09/14/2021)
------------------
- Base script to create an instance using an AMI ID
- Add `requirements.txt`

0.0.2 (09/14/2021)
------------------
- Update LICENSE, README.md and add .gitignore

0.0.1 (09/14/2021)
------------------
- Initial commit
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
recursive-include vpnserver *
recursive-exclude venv *
recursive-exclude docs *
recursive-exclude doc_generator *
exclude gen_docs.sh .gitignore .pre-commit-config.yaml
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<br>

[![Python 3.8](https://img.shields.io/badge/python-3.8-orange.svg)](https://www.python.org/downloads/release/python-385/)
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-391/)

Expand Down Expand Up @@ -47,16 +45,23 @@ Defaults to `openvpn`
Optionally `env vars` for AWS config (`ACCESS_KEY`, `SECRET_KEY`, `REGION_NAME`) can be setup.
</details>

### Setup and Configuration
1. `git clone https://github.com/thevickypedia/vpn-server.git`
2. `cd vpn-server && python3 -m venv venv`
3. `source venv/bin/activate`
4. `pip install -r requirements.txt`
5. Trigger VPN Server - Can be run only via `commandline` since, the script requires arguments as follows.
- `python vpn.py START` to initiate the `VPN Server`
- `python vpn.py STOP` to delete all resource spun up for the `VPN Server`
- `python vpn.py CONFIG` to reconfigure an existing `VPN Server`.
6. `Runtime: ~2 minutes`
### Install
`pip install vpn-server`

### Usage
```python
from vpn.controller import VPNServer

vpn_server = VPNServer()

vpn_server.create_vpn_server() # Create a VPN Server

vpn_server.reconfigure_vpn() # Re-configure an existing VPN Server

vpn_server.test_vpn() # Test an existing VPN Server

vpn_server.delete_vpn_server() # Delete the VPN Server
```

<details>
<summary><strong>Manual Configuration</strong></summary>
Expand Down
3 changes: 3 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from version import version_info

version = '.'.join(str(c) for c in version_info)
30 changes: 30 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[metadata]
name = vpn-server
version = attr: version
description = 'Create on demand VPN Server running with OpenVPN using AWS EC2 and Python',
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
url = https://github.com/thevickypedia/vpn-server

[bdist_wheel]
universal = 1

[options]
packages = find:

[flake8]
ignore = D100
max_line_length = 100
exclude =
# this is generally an empty file.
doc_generator
docs
venv

# install flake8-docstrings
docstring_convention = google

# install flake8-sfs
extend_ignore=SFS3,D107,SFS301,D100,D104,D401

[isort]
64 changes: 64 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from os.path import dirname, isfile, join, realpath, sep

from setuptools import setup

from version import version_info

classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Information Technology',
'Operating System :: MacOS :: MacOS X',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.9',
'Topic :: System :: Networking :: Firewalls'
]


def read(name):
"""Reads the file that was received as argument.
Args:
name: Name of the file that has to be opened and read.
Returns:
Content of the file that was read.
References:
https://pythonhosted.org/an_example_pypi_project/setuptools.html#setting-up-setup-py
"""
with open(join(dirname(__file__), name)) as file:
content = file.read()
return content


def dependencies() -> list:
"""Gathers dependencies from requirements file.
Returns:
List of dependencies to be installed.
"""
requirement_file = dirname(realpath(__file__)) + f'{sep}vpn{sep}requirements.txt'
if isfile(requirement_file):
with open(requirement_file) as requirements:
install_requires = requirements.read().splitlines()
return install_requires


setup(
name='vpn-server',
version='.'.join(str(c) for c in version_info),
description='Create an on demand VPN Server running with OpenVPN using AWS EC2.',
long_description=read('README.md') + '\n\n' + read('CHANGELOG'),
url='https://github.com/thevickypedia/vpn-server',
author='Vignesh Sivanandha Rao',
author_email='svignesh1793@gmail.com',
License='MIT',
classifiers=classifiers,
keywords='openvpn-server, vpn-server, aws-ec2',
packages=['.vpn'],
install_requires=dependencies(),
project_urls={
'Docs': 'https://thevickypedia.github.io/vpn-server',
'Bug Tracker': 'https://github.com/thevickypedia/vpn-server/issues'
},
)
1 change: 1 addition & 0 deletions version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version_info = (0, 4, 6)
Loading

0 comments on commit 618ac8f

Please sign in to comment.