NOTE: THIS CODE IS NOT WORKING AS IS, I AM REVIEWING IT AND WILL PUSH CHANGES SOON.
A python module to update a dynamic IP address of a server on more clients.
I wrote this program to help a friend that needed to syncronize the IP address of a server on more clients around the country. One possible solution could be to buy a static IP addres from the provider but for me this was sort of a game to play so I wrote the program.
The idea is to have an application always running on the server that gets the IP address from an online service https://api.ipify.org/ and sends an email to a specified address, once every hour.
On the client side there should be a program that the staff can run when a certain condition shous up. I.e. when certain program shows "offline" status most probable reason is that the server is no more reachable thus the IP address changed.
As you know, your IP is logged on a lot of sites you visit and I do not consider it "higly confidential" indeed I do prefer not to store the history of my IP adresses on my Gmail that is openly harvested for informations by Google.
One observation I made is that if I send an email to myself Google is clever enough for not bouncing all over the world but, seen the header, is clear that uses a loopback IP. In this way therereal "tranmission", the email is sent through SSL connection to Google and that's it.
A IP address is clearly visible and can be identified with a simple regex while scanning through massive amount of data so I thought to sor of "encrypt" it.
My encryption works in this way:
- I divide the IP in 4 integer numbers, removing the dots.
- I sum every cypher of every number until I get a number thet is < 9 (one cipher number). This will be the key cipher.
- A random encryption factor is generated from a pool starting from -10 up to +10. This myst be known on both sides.
- Every integer number obtained in point 1 is divided in this way:
int * (key * factor)
- The key nombers are translated into letters following an array of random letters that must be nown on both sides.
- At the end of every float will be attached the "key" translated into a letter, and a "padding" letter.
This is an example of what is the aspect of '192.168.0.1' with the following parameters
alpha = ['o', 'd', 'z', 'm', 't', 'a', 'c', 'i', 'r', 'u']
paddingPool = 'befghjklnpqsvwxy'
encryptionFactor = -9.616013867352109
-5538.823987594815mn-9692.941978290926cq-0.0ox-9.616013867352109db
Because this program is meant to be used by "users" there must be some sort of communication with them and the best way I foun are simple windows.
Almost every function has a decorator with the purpose of execute that function for n times or until it returns and return its retur value or either fail or return False. All of this can be controlled by some arguments passed to the decorator.
- Complete docstrings
- Insert some comment lines
- Improve this README.md (language and clarity)
- Clean-up, reshape, improve the graphical part
- Anything could be done to improve stability and render the code more "pythonic"
- Add cli arguments parsing like calling the module with the --client or --server arguments
- Clear or shorten variables names