Compare commits

...

48 Commits
v1.1 ... master

Author SHA1 Message Date
4ab3c3df52 README.md 2024-05-01 10:59:22 +02:00
79186570a6 README.md (Update download links) 2022-10-22 17:18:20 +02:00
q3aql
df4d4b5a4a Remove bad quote (README.md) 2021-04-03 19:07:27 +02:00
q3aql
ac43c27945 Update README.md 2021-04-03 18:54:11 +02:00
q3aql
5d6d5aed58 Remove How-to-Use.txt 2021-04-03 18:52:17 +02:00
q3aql
aa97b3d5d2 README.md 2021-04-03 18:52:01 +02:00
q3aql
54c513c761 Update icon 2021-04-03 18:36:17 +02:00
q3aql
ce15cdbd33 Update installer/uninstaller for Windows 2021-04-03 18:21:14 +02:00
q3aql
84b88928dc Move .vbs file to src folder 2021-04-03 18:11:29 +02:00
q3aql
ee053eb1a2 Update Makefile for OS X 2021-04-03 18:10:41 +02:00
q3aql
a0f273f58f Update Makefile 2021-04-03 18:10:27 +02:00
q3aql
cfab0faf90 Move python scripts to src folder 2021-04-03 18:08:45 +02:00
q3aql
71ad0fd11c Image screenshots 2021-04-03 18:06:47 +02:00
q3aql
092a5799ca Better indent source code 2021-04-03 17:55:59 +02:00
q3aql
0e44d9be46 Rename Install/Uninstall.cmd 2021-04-03 17:40:00 +02:00
q3aql
017db96d9a Makefile (OS X) 2021-04-03 17:37:22 +02:00
q3aql
c18070ce04 Makefile 2021-04-03 17:36:57 +02:00
q3aql
947da1c60f Update email addresses 2016-03-01 19:10:55 +01:00
q3aql
6203ef05f1 README 2016-03-01 19:09:42 +01:00
clamsawd
a65b2367f5 Bump up version number to 1.3.2 2016-02-20 17:04:54 +01:00
clamsawd
8cc677266e Show 'STARTTLS' as only type of STMP server 2016-02-16 16:15:04 +01:00
clamsawd
317d575a90 Add Android (with QPython3) support 2016-02-16 15:53:39 +01:00
clamsawd
92a3e4c350 Fixed bug with permanent color after close the script on Unix systems (Posix) 2016-02-16 15:29:33 +01:00
clamsawd
8bbe08088f Bump up version number to 1.3.1 2015-12-01 19:07:37 +01:00
clamsawd
c490ce0888 Small changes in the command-line interface 2015-12-01 19:06:02 +01:00
clamsawd
9b61599699 Bump up version number to 1.3 2015-11-22 10:42:29 +01:00
clamsawd
f8d8c5865e Add instruction for Windows (README) 2015-11-16 21:10:25 +01:00
clamsawd
718bf32c21 Remove desktop shortcuts (for Windows) 2015-11-16 21:10:14 +01:00
clamsawd
e2fb3772b4 Create desktop shortcuts (for Windows) 2015-11-16 21:10:03 +01:00
clamsawd
0523193ac9 Function TimeSleep(N) 2015-11-16 15:28:43 +01:00
clamsawd
eba92fa9b4 Lock daemon to only one process running 2015-11-16 07:27:01 +01:00
clamsawd
d78491a1a7 Bump up version number to 1.2 2015-11-15 17:21:19 +01:00
clamsawd
b6ba9099d2 Windows Notes (How-to-Use.txt) 2015-11-15 17:18:20 +01:00
clamsawd
ef5df3bfb7 VBS Script for Windows 2015-11-15 17:17:47 +01:00
clamsawd
5e1d5931a1 README (Mac OS X instructions) 2015-11-15 16:57:35 +01:00
clamsawd
5ffa22a526 makefile.osx (for Mac OS X) 2015-11-15 16:49:34 +01:00
clamsawd
482e0c955e Updated makefile 2015-11-15 16:48:01 +01:00
clamsawd
c46dff6bcd PauseExit=input() 2015-11-15 16:42:14 +01:00
clamsawd
6d70d08bdc Added GNU/Linux desktop shortcuts 2015-11-15 16:33:59 +01:00
clamsawd
44a2b0eb8b Added Material Design icon 2015-11-15 13:15:15 +01:00
clamsawd
53cdf207aa Bump up version number to 1.1.2 2015-11-09 16:40:52 +01:00
clamsawd
1d6b982c5b Added comments 2015-11-09 11:21:01 +01:00
clamsawd
f921073835 Internal changes in the source code 2015-11-09 11:08:13 +01:00
clamsawd
ec0f4a61f4 Changed names and extensions of configuration files 2015-11-09 11:01:40 +01:00
clamsawd
66cf345f32 Check and test a previous configuration 2015-11-09 10:42:40 +01:00
clamsawd
a484ffe73d Bump up version number to 1.1.1 2015-11-06 17:45:59 +01:00
clamsawd
b930ce5fe9 Forcing to create the configuration file 2015-11-06 17:44:24 +01:00
clamsawd
363a101026 Fixed bug creating the first config.file 2015-11-06 17:41:41 +01:00
19 changed files with 716 additions and 462 deletions

View File

@ -1,23 +0,0 @@
ip2e - How to use
=================
STEPS TO USE:
-------------
* Create a valid configuration file:
- First, you must create the configuration file needed to run 'ip2e' correctly.
To do this, run the tool called 'ip2e-config.py':
$ ./ip2e-config.py
* Run the daemon:
- When are configured the necessary data of the email sender & receiver, you can
run the tool called 'ip2e-daemon.py':
$ ./ip2e-daemon.py
- When daemon is running you can see the log file running the 'ip2e-log.py' tool:
$ ./ip2e-log.py

57
Install.cmd Normal file
View File

@ -0,0 +1,57 @@
@echo off
echo.
echo ###################################
echo # Welcome to ip2e installer 1.3.2 #
echo ###################################
echo.
echo - This installer simply creates a shortcut to the
echo application on your desktop. We recommend that
echo before continuing, make sure you have left the
echo application folder in a place where no one can
echo delete it.
echo.
echo Examples:
echo - C:\ip2e
echo - C:\Program Files\ip2e
echo.
echo * Press ENTER to continue or Ctrl+C to exit
pause > nul
echo.
echo * Creating shortchut (%USERPROFILE%\Desktop\ip2e (daemon).lnk)
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\ip2e (daemon).lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%~d0%~p0\src\ip2e-daemon.py" >> %SCRIPT%
echo oLink.WorkingDirectory = "%~d0%~p0" >> %SCRIPT%
echo oLink.IconLocation = "%~d0%~p0\icon\ip2e.ico" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo * Creating shortchut (%USERPROFILE%\Desktop\ip2e (config).lnk)
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\ip2e (config).lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%~d0%~p0\src\ip2e-config.py" >> %SCRIPT%
echo oLink.WorkingDirectory = "%~d0%~p0" >> %SCRIPT%
echo oLink.IconLocation = "%~d0%~p0\icon\ip2e.ico" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo * Creating shortchut (%USERPROFILE%\Desktop\ip2e (background).lnk)
copy /Y src\ip2e-daemon.vbs ip2e-daemon.vbs
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\ip2e (background).lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%~d0%~p0\src\ip2e-daemon.vbs" >> %SCRIPT%
echo oLink.WorkingDirectory = "%~d0%~p0" >> %SCRIPT%
echo oLink.IconLocation = "%~d0%~p0\icon\ip2e.ico" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo * Shortcuts created!
echo Press ENTER to exit
pause > nul

27
Makefile Normal file
View File

@ -0,0 +1,27 @@
####################################################
# Installing ip2e #
####################################################
PREFIX=/usr
install:
cp src/ip2e-daemon.py $(PREFIX)/bin
cp src/ip2e-config.py $(PREFIX)/bin
cp src/ip2e-log.py $(PREFIX)/bin
cp src/ip2e.desktop $(PREFIX)/share/applications
cp src/ip2e-config.desktop $(PREFIX)/share/applications
cp icon/ip2e.png $(PREFIX)/share/icons
chmod +x $(PREFIX)/bin/ip2e-daemon.py
chmod +x $(PREFIX)/bin/ip2e-config.py
chmod +x $(PREFIX)/bin/ip2e-log.py
chmod +x $(PREFIX)/share/applications/ip2e.desktop
chmod +x $(PREFIX)/share/applications/ip2e-config.desktop
uninstall:
rm $(PREFIX)/bin/ip2e-daemon.py
rm $(PREFIX)/bin/ip2e-config.py
rm $(PREFIX)/bin/ip2e-log.py
rm $(PREFIX)/share/applications/ip2e.desktop
rm $(PREFIX)/share/applications/ip2e-config.desktop
rm $(PREFIX)/share/icons/ip2e.png

View File

@ -1,13 +1,13 @@
######################################## ########################################
# Installing ip2e # # Installing ip2e (Mac OS X) #
######################################## ########################################
PREFIX=/usr PREFIX=/usr
install: install:
cp ip2e-daemon.py $(PREFIX)/bin cp src/ip2e-daemon.py $(PREFIX)/bin
cp ip2e-config.py $(PREFIX)/bin cp src/ip2e-config.py $(PREFIX)/bin
cp ip2e-log.py $(PREFIX)/bin cp src/ip2e-log.py $(PREFIX)/bin
chmod +x $(PREFIX)/bin/ip2e-daemon.py chmod +x $(PREFIX)/bin/ip2e-daemon.py
chmod +x $(PREFIX)/bin/ip2e-config.py chmod +x $(PREFIX)/bin/ip2e-config.py
chmod +x $(PREFIX)/bin/ip2e-log.py chmod +x $(PREFIX)/bin/ip2e-log.py

36
README
View File

@ -1,36 +0,0 @@
ip2e - Receive your public IP (dynamic) by email when it is renewed
===================================================================
TOOLS
-----
* ip2e-daemon.py: Daemon to control & send by email your public IP.
* ip2e-log.py: Tool to see the log file when daemon is running.
* ip2e-config.py: Tool to create a valid configuration file.
HOW TO INSTALL
--------------
* Unix systems (GNU/Linux,*BSD, Mac OS X, etc..)
================================================
- Open the terminal and type the following comands:
$ git clone https://github.com/clamsawd/ip2e.git
$ cd ip2e
# make
Note: You must install git & python3 previously.
* Windows
=========
- Install Python 3.x from https://www.python.org/.
- Download https://github.com/clamsawd/ip2e/archive/master.zip
- Unzip the package in your system. For example in C:\Program Files\.
- Add the folder to PATH variable.
HOW TO USE
-----------
- Read 'How-to-Use.txt".

84
README.md Normal file
View File

@ -0,0 +1,84 @@
ip2e - Receive your public IP (dynamic) by email when it is renewed.
====================================================================
### Tools:
* [ip2e-daemon.py](https://git.q3aql.dev/q3aql/ip2e/src/branch/master/src/ip2e-daemon.py) - Daemon to control & send by email your public IP.
* [ip2e-log.py](https://git.q3aql.dev/q3aql/ip2e/src/branch/master/src/ip2e-log.py) - Tool to see the log file when daemon is running.
* [ip2e-config.py](https://git.q3aql.dev/q3aql/ip2e/src/branch/master/src/ip2e-config.py) - Tool to create a valid configuration file.
### Downloads:
* [ip2e-1.3.2-all.deb](https://drive.proton.me/urls/DVPCQ4208C#NxETtIilTDBF)
* [ip2e-1.3.2-all.rpm](https://drive.proton.me/urls/DVPCQ4208C#NxETtIilTDBF)
* [ip2e-1.3.2.tar.bz2](https://drive.proton.me/urls/DVPCQ4208C#NxETtIilTDBF)
* [ip2e-1.3.2.tar.gz](https://drive.proton.me/urls/DVPCQ4208C#NxETtIilTDBF)
_Dependence: `python3`._
### Installation:
* **Unix systems (GNU/Linux,BSD,etc..):**
* Open the terminal and type the following comands:
```shell
$ git clone https://git.q3aql.dev/q3aql/ip2e.git
$ cd ip2e
$ sudo make install
````
_Note: You must install `git` previously._
* **Mac OS X:**
* Open the terminal and type the following comands:
```shell
$ git clone https://git.q3aql.dev/q3aql/ip2e.git
$ cd ip2e
$ sudo make -f Makefile.OSX
````
_Note: You must install `git` previously._
* **Windows:**
* Install Python 3.x from https://www.python.org/.
* Download `ip2e` from [here](https://gitlab.com/q3aql/ip2e/-/archive/master/ip2e-master.zip).
* Unzip the package in your system. For example in `C:\Program Files\`.
* Double click on `Install.cmd`.
### How to use:
* **Create a valid configuration file:**
* First, you must create the configuration file needed to run `ip2e` correctly.
To do this, run the tool called `ip2e-config.py`:
```shell
$ ip2e-config.py
````
* **Run the daemon:**
* When are configured the necessary data of the email sender & receiver, you can
run the tool called `ip2e-daemon.py`:
```shell
$ ip2e-daemon.py
````
* When daemon is running you can see the log file running the `ip2e-log.py` tool:
```shell
$ ip2e-log.py
````
### Images (Screenshots):
<img src="https://git.q3aql.dev/q3aql/ip2e/raw/branch/master/img/ip2e-command.png" width="700" />
### External links:
* [Python3 homepage](https://www.python.org/downloads/)

13
Uninstall.cmd Normal file
View File

@ -0,0 +1,13 @@
@echo off
echo.
del %USERPROFILE%\Desktop\"ip2e (daemon).lnk"
echo * Removed shortchut (%USERPROFILE%\Desktop\ip2e (daemon).lnk)
del %USERPROFILE%\Desktop\"ip2e (config).lnk"
echo * Removed shortchut (%USERPROFILE%\Desktop\ip2e (config).lnk)
del %USERPROFILE%\Desktop\"ip2e (background).lnk"
echo * Removed shortchut (%USERPROFILE%\Desktop\ip2e (background).lnk)
echo.
echo * Shortcuts Removed!
echo + Press ENTER to exit
pause > nul

BIN
icon/ip2e.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
icon/ip2e.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/ip2e-command.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,107 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------
# ip2e (IP to email) - Create the configuration file. |
# Created by clamsawd (clamsawd@openmailbox.org) |
# Licensed by GPL v.3 |
# Last update: 01-11-2015 |
# |
# Compatible with Python 3.x |
# --------------------------------------------------------------
version="1.1"
#Import python-modules
import os
import sys
#Check if your system use Python 3.x
if sys.version_info<(3,0):
print ("")
print ("You need python 3.x to run this program.")
print ("")
exit(1)
#Function to clear screen
def ClearScreen():
if sys.platform == "cygwin":
print (300 * "\n")
elif os.name == "posix":
os.system("clear")
elif os.name == "nt":
os.system("cls")
else:
print ("Error: Unable clear screen")
#Detect system & PATH of user folder
if os.name == "posix":
os.chdir(os.environ["HOME"])
print ("POSIX detected")
elif os.name == "nt":
os.chdir(os.environ["USERPROFILE"])
print ("Windows detected")
if not os.path.exists(".ip2e"):
os.makedirs(".ip2e")
os.chdir(".ip2e")
if os.path.exists(".ip2e"):
os.chdir(".ip2e")
#Set variables of 'ip2e-conf.py'
ClearScreen()
print ("")
print ("ip2e-config v"+version+" - Create config.file")
print ("")
FromEmail=input("Type the email sender: ")
FromEmailUser=input("Type the user of email sender: ")
FromEmailPass=input("Type the pass of email sender: ")
SmtpFromEmail=input("Type the server STMP of email sender: ")
ToEmail=input("Type the email receiver: ")
#Create 'ip2e-conf.py'
os.remove("ip2e-conf.py")
ip2ecf=open('ip2e-conf.py','w')
ip2ecf.close()
ip2ecf=open('ip2e-conf.py','a')
ip2ecf.write('# sample configuration file of ip2e\n')
ip2ecf.write('\n')
ip2ecf.write('FromEmail="'+FromEmail+'"\n')
ip2ecf.write('FromEmailUser="'+FromEmailUser+'"\n')
ip2ecf.write('FromEmailPass="'+FromEmailPass+'"\n')
ip2ecf.write('SmtpFromEmail="'+SmtpFromEmail+'"\n')
ip2ecf.write('ToEmail="'+ToEmail+'"\n')
ip2ecf.close()
#Show the configuration
ClearScreen()
print ("")
print ("ip2e-config v"+version+" - Current config.file")
print ("")
readfile=open('ip2e-conf.py', 'r')
print(readfile.read())
readfile.close()
#Test connection with your configuration
print ("")
TestConnection=input("Test connection with your configuration (y/n): ")
if TestConnection == "y":
exec(open("ip2e-conf.py").read())
#Import smtplib
import smtplib
try:
server = smtplib.SMTP(SmtpFromEmail)
server.ehlo()
server.starttls()
server.ehlo()
server.login(FromEmailUser,FromEmailPass)
server.quit()
print ("")
print ("Test OK")
print ("")
except:
print ("")
print ("Failed to connect ("+SmtpFromEmail+")")
print ("")
else:
print ("Exiting...")
exit(0)

View File

@ -1,214 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------
# ip2e (IP to email) - Run ip2e daemon. |
# Created by clamsawd (clamsawd@openmailbox.org) |
# Licensed by GPL v.3 |
# Last update: 01-11-2015 |
# |
# Compatible with Python 3.x |
# --------------------------------------------------------------
version="1.1"
#Import python-modules
import urllib
import urllib.request
import os
import sys
import time
import smtplib
#Check if your system use Python 3.x
if sys.version_info<(3,0):
print ("")
print ("You need python 3.x to run this program.")
print ("")
exit(1)
#Function to clear screen
def ClearScreen():
if sys.platform == "cygwin":
print (300 * "\n")
elif os.name == "posix":
os.system("clear")
elif os.name == "nt":
os.system("cls")
else:
print ("Error: Unable clear screen")
#Detect system & PATH of user folder
if os.name == "posix":
os.chdir(os.environ["HOME"])
print ("POSIX detected")
elif os.name == "nt":
os.chdir(os.environ["USERPROFILE"])
print ("Windows detected")
if not os.path.exists(".ip2e"):
os.makedirs(".ip2e")
os.chdir(".ip2e")
if os.path.exists(".ip2e"):
os.chdir(".ip2e")
#Check if exists 'ip2e-conf.py'
if os.path.isfile("ip2e-conf.py"):
print ("ip2e-conf.py exists")
else:
print ("ip2e-conf.py created")
ip2ecf=open('ip2e-conf.py','w')
ip2ecf.close()
ip2ecf=open('ip2e-conf.py','a')
ip2ecf.write('# sample configuration file of ip2e\n')
ip2ecf.write('\n')
ip2ecf.write('FromEmail="ip2e@daemon"\n')
ip2ecf.write('FromEmailUser="unknown"\n')
ip2ecf.write('FromEmailPass="password-here"\n')
ip2ecf.write('SmtpFromEmail="smtp.email.com"\n')
ip2ecf.write('ToEmail="unknown@email.com"\n')
ip2ecf.close()
#Check if exists 'current-ip.py'
if os.path.isfile("current-ip.py"):
print ("current-ip.py exists")
else:
print ("current-ip.py created")
ip2eIPcf=open('current-ip.py','w')
ip2eIPcf.close()
ip2eIPcf=open('current-ip.py','a')
ip2eIPcf.write('CurrentIP="0.0.0.0"\n')
ip2eIPcf.close()
#Import variables from ip2e-conf.py
exec(open("ip2e-conf.py").read())
#Import native OS color scheme
try:
def GreenColor():
if os.name == "posix":
GreenColor = (chr(27)+"[1;32m")
print (GreenColor+"", end="")
elif os.name == "nt":
os.system("color 2")
def RedColor():
if os.name == "posix":
RedColor = (chr(27)+"[1;31m")
print (RedColor+"", end="")
elif os.name == "nt":
os.system("color 4")
def OrangeColor():
if os.name == "posix":
OrangeColor = (chr(27)+"[1;33m")
print (OrangeColor+"", end="")
elif os.name == "nt":
os.system("color 6")
except:
print ("Error importing native color scheme")
exit(1)
#Check if exists a previous log.file.
if os.path.isfile("ip2e.log"):
os.remove("ip2e.log")
createlog=open('ip2e.log','w')
createlog.close()
#Run ip2e daemon
ClearScreen()
editlog=open('ip2e.log','a')
CurrentTime = time.strftime("%H:%M")
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Initialized ip2e-daemon v"+version+" (Ctrl+C to stop)")
if os.name == "posix":
print ("[ip2e-daemon] ["+CurrentTime+"] Log in "+os.environ["HOME"]+"/.ip2e/ip2e.log")
elif os.name == "nt":
print ("[ip2e-daemon] ["+CurrentTime+"] Log in "+os.environ["USERPROFILE"]+"\.ip2e\\ip2e.log")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Initialized ip2e-daemon v"+version+"\n")
OrangeColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Waiting 60 seconds...")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Waiting 60 seconds...\n")
editlog.close()
time.sleep(60)
PublicIP = 1
while PublicIP <= 2:
GetCurrentIP = 1
while GetCurrentIP <= 2:
CurrentTime = time.strftime("%H:%M")
OrangeColor()
print ("[ip2e-daemon] ["+CurrentTime+"] IP Updating...")
editlog=open('ip2e.log','a')
editlog.write("[ip2e-daemon] ["+CurrentTime+"] IP Updating...\n")
try:
response = urllib.request.urlopen('http://icanhazip.com')
#response = urllib.request.urlopen('http://ip.appspot.com/')
#response = urllib.request.urlopen('http://ident.me')
NewIPRaw = response.read()
NewIP = NewIPRaw.strip().decode('utf-8')
GetCurrentIP += 2
except:
CurrentTime = time.strftime("%H:%M")
RedColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Error getting IP")
print ("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Error getting IP\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n")
time.sleep(10)
exec(open("current-ip.py").read())
if CurrentIP == NewIP:
CurrentTime = time.strftime("%H:%M")
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] IP has not changed")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] IP has not changed\n")
else:
CurrentTime = time.strftime("%H:%M")
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] New IP - From "+CurrentIP+" to "+NewIP)
editlog.write("[ip2e-daemon] ["+CurrentTime+"] New IP - From "+CurrentIP+" to "+NewIP+"\n")
SendEmailOK = 1
while SendEmailOK <= 2:
CurrentTime = time.strftime("%H:%M")
#Sending email using smtplib
SmtpSubject = "[ip2e-daemon] ["+CurrentTime+"] IP has changed"
SmtpHeader = "From: "+FromEmail+"\n"+"To: "+ToEmail+"\n"+"Subject: "+SmtpSubject+"\n"
SmtpBodyMessage = SmtpHeader+"\n"+"[ip2e] New IP is "+NewIP+"\n\n"
#Check sending errors
try:
server = smtplib.SMTP(SmtpFromEmail)
server.ehlo()
server.starttls()
server.ehlo()
server.login(FromEmailUser,FromEmailPass)
server.sendmail(FromEmail, ToEmail, SmtpBodyMessage)
server.quit()
CurrentTime = time.strftime("%H:%M")
MailMessage="[ip2e-daemon] ["+CurrentTime+"] Email was sent successfully"
GreenColor()
print (MailMessage+" ("+ToEmail+")")
editlog.write(MailMessage+" ("+ToEmail+")\n")
SendEmailOK += 2
except:
CurrentTime = time.strftime("%H:%M")
RedColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Failed to connect ("+SmtpFromEmail+")")
print ("[ip2e-daemon] ["+CurrentTime+"] Check your settings or your connection")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Failed to connect ("+SmtpFromEmail+")\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Check your settings or your connection\n")
MailMessage="[ip2e-daemon] ["+CurrentTime+"] Failed to send email"
print (MailMessage+" ("+ToEmail+")")
print ("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...")
editlog.write(MailMessage+" ("+ToEmail+")\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n")
time.sleep(10)
os.remove("current-ip.py")
ip2eIPcf=open('current-ip.py','w')
ip2eIPcf.close()
ip2eIPcf=open('current-ip.py','a')
ip2eIPcf.write('CurrentIP="'+NewIP+'"\n')
ip2eIPcf.close()
CurrentTime = time.strftime("%H:%M")
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Next update in 10 minutes...")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Next update in 10 minutes...\n")
editlog.close()
time.sleep(600)

View File

@ -1,78 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------
# ip2e (IP to email) - See the log file. |
# Created by clamsawd (clamsawd@openmailbox.org) |
# Licensed by GPL v.3 |
# Last update: 01-11-2015 |
# |
# Compatible with Python 3.x |
# --------------------------------------------------------------
version="1.1"
#Import python-modules
import os
import sys
#Check if your system use Python 3.x
if sys.version_info<(3,0):
print ("")
print ("You need python 3.x to run this program.")
print ("")
exit(1)
#Function to clear screen
def ClearScreen():
if sys.platform == "cygwin":
print (300 * "\n")
elif os.name == "posix":
os.system("clear")
elif os.name == "nt":
os.system("cls")
else:
print ("Error: Unable clear screen")
#Detect system & PATH of user folder
if os.name == "posix":
os.chdir(os.environ["HOME"])
print ("POSIX detected")
elif os.name == "nt":
os.chdir(os.environ["USERPROFILE"])
print ("Windows detected")
if not os.path.exists(".ip2e"):
os.makedirs(".ip2e")
os.chdir(".ip2e")
if os.path.exists(".ip2e"):
os.chdir(".ip2e")
#Check if exists 'ip2e-conf.py'
if os.path.isfile("ip2e-conf.py"):
print ("ip2e-conf.py exists")
else:
print ("ip2e-conf.py created")
ip2ecf=open('ip2e-conf.py','w')
ip2ecf.close()
ip2ecf=open('ip2e-conf.py','a')
ip2ecf.write('# sample configuration file of ip2e\n')
ip2ecf.write('\n')
ip2ecf.write('FromEmail="ip2e@daemon"\n')
ip2ecf.write('FromEmailUser="unknown"\n')
ip2ecf.write('FromEmailPass="password-here"\n')
ip2ecf.write('SmtpFromEmail="smtp.email.com"\n')
ip2ecf.write('ToEmail="unknown@email.com"\n')
ip2ecf.close()
#See the log file
if os.path.isfile("ip2e.log"):
print ("ip2e.log exists")
ClearScreen()
readfile=open('ip2e.log', 'r')
print(readfile.read())
readfile.close()
else:
ClearScreen()
print ("")
print ("ip2e.log doesn't exist.")
print ("")

11
src/ip2e-config.desktop Executable file
View File

@ -0,0 +1,11 @@
[Desktop Entry]
Name=ip2e (config)
GenericName=ip2e (config)
X-GNOME-FullName=ip2e (config)
Comment=Receive your public IP by email when it is renewed
Exec=ip2e-config.py
Icon=/usr/share/icons/ip2e.png
Terminal=true
Type=Application
StartupNotify=true
Categories=Network;FileTransfer;

150
src/ip2e-config.py Executable file
View File

@ -0,0 +1,150 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------
# ip2e (IP to email) - Create the configuration file. |
# Created by q3aql (q3aql@protonmail.ch) |
# Licensed by GPL v.3 |
# Last update: 03-04-2021 |
# |
# Compatible with Python 3.x |
# --------------------------------------------------------------
version="1.3.2"
#Import python-modules
import os
import sys
#Check if your system use Python 3.x
if sys.version_info<(3,0):
print ("")
print ("* You need python 3.x to run this program.")
print ("")
exit()
#Function to clear screen
def ClearScreen():
if sys.platform == "cygwin":
print (300 * "\n")
elif os.name == "posix":
os.system("clear")
elif os.name == "nt":
os.system("cls")
else:
print ("* Error: Unable clear screen")
#Detect system & PATH of user folder
if os.path.exists("/storage/sdcard0"):
HOMESCARD0="/storage/sdcard0/Android/data"
os.chdir(HOMESCARD0)
print ("Android (Posix) detected")
elif os.name == "posix":
os.chdir(os.environ["HOME"])
print ("Unix (Posix) detected")
elif os.name == "nt":
os.chdir(os.environ["USERPROFILE"])
print ("Windows detected")
if not os.path.exists(".ip2e"):
os.makedirs(".ip2e")
os.chdir(".ip2e")
if os.path.exists(".ip2e"):
os.chdir(".ip2e")
if os.path.isfile("ip2e.conf"):
ClearScreen()
print ("")
print ("** ip2e-config v"+version+" **")
print ("")
print (" - Detected a previous configuration file.")
print (" - Do you want to overwrite or check the current configuration?")
print ("")
print (" * (o) - overwrite (create new configuration)")
print (" * (c) - check and test the current configuration")
print ("")
OverWriteOrCheck=input("- [Default: check and test] Choose an option; ")
if OverWriteOrCheck == "o" or OverWriteOrCheck == "O":
print ("Create new configuration")
else:
exec(open("ip2e.conf").read())
#Import smtplib
import smtplib
try:
server = smtplib.SMTP(SmtpFromEmail)
server.ehlo()
server.starttls()
server.ehlo()
server.login(FromEmailUser,FromEmailPass)
server.quit()
print ("")
print ("* Test OK")
print ("")
PauseExit=input("+ Press ENTER to exit ")
except:
print ("")
print ("* Failed to connect ("+SmtpFromEmail+")")
print ("")
PauseExit=input("+ Press ENTER to exit ")
exit()
#Set variables of 'ip2e.conf'
ClearScreen()
print ("")
print ("** ip2e-config v"+version+" - Create config.file **")
print ("")
FromEmail=input("- Type the email sender: ")
FromEmailUser=input("- Type the user of email sender: ")
FromEmailPass=input("- Type the pass of email sender: ")
SmtpFromEmail=input("- Type the server STMP (STARTTLS) of email sender: ")
ToEmail=input("- Type the email receiver: ")
#Create 'ip2e.conf'
if os.path.isfile("ip2e.conf"):
os.remove("ip2e.conf")
ip2ecf=open('ip2e.conf','w')
ip2ecf.close()
ip2ecf=open('ip2e.conf','a')
ip2ecf.write('# sample configuration file of ip2e\n')
ip2ecf.write('\n')
ip2ecf.write('FromEmail="'+FromEmail+'"\n')
ip2ecf.write('FromEmailUser="'+FromEmailUser+'"\n')
ip2ecf.write('FromEmailPass="'+FromEmailPass+'"\n')
ip2ecf.write('SmtpFromEmail="'+SmtpFromEmail+'"\n')
ip2ecf.write('ToEmail="'+ToEmail+'"\n')
ip2ecf.close()
#Show the configuration
ClearScreen()
print ("")
print ("** ip2e-config v"+version+" - Current config.file **")
print ("")
readfile=open('ip2e.conf', 'r')
print(readfile.read())
readfile.close()
#Test connection with your configuration
print ("")
TestConnection=input("- [Default: y] Test connection with your configuration (y/n): ")
if TestConnection == "n":
print ("Exiting...")
exit()
else:
exec(open("ip2e.conf").read())
#Import smtplib
import smtplib
try:
server = smtplib.SMTP(SmtpFromEmail)
server.ehlo()
server.starttls()
server.ehlo()
server.login(FromEmailUser,FromEmailPass)
server.quit()
print ("")
print ("* Test OK")
print ("")
PauseExit=input("+ Press ENTER to exit ")
except:
print ("")
print ("* Failed to connect ("+SmtpFromEmail+")")
print ("")
PauseExit=input("+ Press ENTER to exit ")

291
src/ip2e-daemon.py Executable file
View File

@ -0,0 +1,291 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------
# ip2e (IP to email) - Run ip2e daemon. |
# Created by q3aql (q3aql@protonmail.ch) |
# Licensed by GPL v.3 |
# Last update: 03-04-2021 |
# |
# Compatible with Python 3.x |
# --------------------------------------------------------------
version="1.3.2"
#Import python-modules
import urllib
import urllib.request
import os
import sys
import time
import smtplib
import random
#Check if your system use Python 3.x
if sys.version_info<(3,0):
print ("")
print ("You need python 3.x to run this program.")
print ("")
exit()
#Function to clear screen
def ClearScreen():
if sys.platform == "cygwin":
print (300 * "\n")
elif os.name == "posix":
os.system("clear")
elif os.name == "nt":
os.system("cls")
else:
print ("Error: Unable clear screen")
#Detect system & PATH of user folder
if os.path.exists("/storage/sdcard0"):
HOMESCARD0="/storage/sdcard0/Android/data"
os.chdir(HOMESCARD0)
LogFile=HOMESCARD0+"/ip2e/ip2e.log"
LockFile=HOMESCARD0+"/ip2e/ip2e.lock"
print ("Android (Posix) detected")
elif os.name == "posix":
os.chdir(os.environ["HOME"])
LogFile=os.environ["HOME"]+"/.ip2e/ip2e.log"
LockFile=os.environ["HOME"]+"/.ip2e/ip2e.lock"
print ("Unix (Posix) detected")
elif os.name == "nt":
os.chdir(os.environ["USERPROFILE"])
LogFile=os.environ["USERPROFILE"]+"\\.ip2e\\ip2e.log"
LockFile=os.environ["USERPROFILE"]+"\\.ip2e\\ip2e.lock"
print ("Windows detected")
if not os.path.exists(".ip2e"):
os.makedirs(".ip2e")
os.chdir(".ip2e")
if os.path.exists(".ip2e"):
os.chdir(".ip2e")
#Check if exists 'ip2e.conf'
if os.path.isfile("ip2e.conf"):
print ("ip2e.conf exists")
else:
ClearScreen()
print ("")
print ("* The configuration file doesn't exist")
print ("")
print ("* You can create it if you run 'ip2e-config.py'")
print ("")
PauseExit=input("+ Press ENTER to exit ")
exit()
#Check if exists 'IP.log'
if os.path.isfile("IP.log"):
print ("IP.log exists")
else:
print ("IP.log created")
ip2eIPcf=open('IP.log','w')
ip2eIPcf.close()
ip2eIPcf=open('IP.log','a')
ip2eIPcf.write('0.0.0.0')
ip2eIPcf.close()
#Import variables from ip2e.conf
exec(open("ip2e.conf").read())
#Import native OS color scheme
try:
def GreenColor():
if os.name == "posix":
GreenColor = (chr(27)+"[1;32m")
print (GreenColor+"", end="")
elif os.name == "nt":
os.system("color 2")
def RedColor():
if os.name == "posix":
RedColor = (chr(27)+"[1;31m")
print (RedColor+"", end="")
elif os.name == "nt":
os.system("color 4")
def OrangeColor():
if os.name == "posix":
OrangeColor = (chr(27)+"[1;33m")
print (OrangeColor+"", end="")
elif os.name == "nt":
os.system("color 6")
def EndColor():
if os.name == "posix":
EndColor = (chr(27)+"[0m")
print (EndColor+"", end="")
elif os.name == "nt":
print ("", end="")
except:
print ("")
print ("* Error importing native color scheme")
print ("")
PauseExit=input("+ Press ENTER to exit ")
exit()
#Check if ip2e-daemon is running.
if os.path.isfile("ip2e.lock"):
readLock=open('ip2e.lock', 'r')
LockN=readLock.read()
readLock.close()
ClearScreen()
print ("Checking "+LockFile+"...")
time.sleep(4)
readLock2=open('ip2e.lock', 'r')
LockN2=readLock2.read()
readLock2.close()
if LockN != LockN2:
ClearScreen()
print ("")
print ("* ip2e-daemon is already running.")
print ("")
PauseExit=input("+ Press ENTER to exit ")
exit()
if not os.path.isfile("ip2e.lock"):
createLock=open('ip2e.lock','w')
createLock.write(str(random.randrange(135790)))
createLock.close()
#Function to lock process.
def LockProcess():
createLock=open('ip2e.lock','w')
createLock.write(str(random.randrange(135790)))
createLock.close()
#Function to sleep 'N' seconds.
def TimeSleep(N):
Time=1
while Time < N:
createLock=open('ip2e.lock','w')
createLock.write(str(random.randrange(135790)))
createLock.close()
time.sleep(1)
Time=Time + 1
#Check if exists a previous log.file
if os.path.isfile("ip2e.log"):
createlog=open('ip2e.log','w')
createlog.close()
#Run ip2e daemon
ClearScreen()
LockProcess()
editlog=open('ip2e.log','a')
CurrentTime = time.strftime("%H:%M")
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Initialized ip2e-daemon v"+version+" (Ctrl+C to stop)")
print ("[ip2e-daemon] ["+CurrentTime+"] Log in "+LogFile)
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Initialized ip2e-daemon v"+version+"\n")
OrangeColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Waiting 60 seconds...")
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Waiting 60 seconds...\n")
editlog.close()
TimeSleep(60)
PublicIP = 1
while PublicIP <= 2:
GetCurrentIP = 1
while GetCurrentIP <= 2:
CurrentTime = time.strftime("%H:%M")
LockProcess()
OrangeColor()
print ("[ip2e-daemon] ["+CurrentTime+"] IP Updating...")
EndColor()
editlog=open('ip2e.log','a')
editlog.write("[ip2e-daemon] ["+CurrentTime+"] IP Updating...\n")
#Check & get the new IP
try:
LockProcess()
response = urllib.request.urlopen('http://icanhazip.com')
#response = urllib.request.urlopen('http://ip.appspot.com/')
#response = urllib.request.urlopen('http://ident.me')
NewIPRaw = response.read()
NewIP = NewIPRaw.strip().decode('utf-8')
GetCurrentIP += 2
except:
CurrentTime = time.strftime("%H:%M")
LockProcess()
RedColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Error getting IP")
print ("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...")
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Error getting IP\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n")
TimeSleep(10)
#Read IP log file & get the current IP
readfileIP=open('IP.log', 'r')
CurrentIPRaw=readfileIP.read()
CurrentIP=CurrentIPRaw.strip()
readfileIP.close()
LockProcess()
#Check if the IP has been renewed
if CurrentIP == NewIP:
CurrentTime = time.strftime("%H:%M")
LockProcess()
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] IP has not changed")
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] IP has not changed\n")
else:
CurrentTime = time.strftime("%H:%M")
LockProcess()
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] New IP - From "+CurrentIP+" to "+NewIP)
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] New IP - From "+CurrentIP+" to "+NewIP+"\n")
SendEmailOK = 1
while SendEmailOK <= 2:
LockProcess()
CurrentTime = time.strftime("%H:%M")
#Sending email using smtplib
SmtpSubject = "[ip2e-daemon] ["+CurrentTime+"] IP has changed"
SmtpHeader = "From: "+FromEmail+"\n"+"To: "+ToEmail+"\n"+"Subject: "+SmtpSubject+"\n"
SmtpBodyMessage = SmtpHeader+"\n"+"[ip2e] New IP is "+NewIP+"\n\n"
#Check sending errors
try:
server = smtplib.SMTP(SmtpFromEmail)
server.ehlo()
server.starttls()
server.ehlo()
server.login(FromEmailUser,FromEmailPass)
server.sendmail(FromEmail, ToEmail, SmtpBodyMessage)
server.quit()
CurrentTime = time.strftime("%H:%M")
MailMessage="[ip2e-daemon] ["+CurrentTime+"] Email was sent successfully"
LockProcess()
GreenColor()
print (MailMessage+" ("+ToEmail+")")
EndColor()
editlog.write(MailMessage+" ("+ToEmail+")\n")
SendEmailOK += 2
except:
CurrentTime = time.strftime("%H:%M")
LockProcess()
RedColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Failed to connect ("+SmtpFromEmail+")")
print ("[ip2e-daemon] ["+CurrentTime+"] Check your settings or your connection")
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Failed to connect ("+SmtpFromEmail+")\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Check your settings or your connection\n")
MailMessage="[ip2e-daemon] ["+CurrentTime+"] Failed to send email"
RedColor()
print (MailMessage+" ("+ToEmail+")")
print ("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...")
EndColor()
editlog.write(MailMessage+" ("+ToEmail+")\n")
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Retrying in 10 seconds...\n")
TimeSleep(10)
#Remove the previous IP log file & create a new.
ip2eIPcf=open('IP.log','w')
ip2eIPcf.write(NewIP)
ip2eIPcf.close()
#Wait 10 minutes until the next checking
CurrentTime = time.strftime("%H:%M")
LockProcess()
GreenColor()
print ("[ip2e-daemon] ["+CurrentTime+"] Next update in 10 minutes...")
EndColor()
editlog.write("[ip2e-daemon] ["+CurrentTime+"] Next update in 10 minutes...\n")
editlog.close()
TimeSleep(600)

3
src/ip2e-daemon.vbs Normal file
View File

@ -0,0 +1,3 @@
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "ip2e-daemon.py" & Chr(34), 0
Set WshShell = Nothing

65
src/ip2e-log.py Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# --------------------------------------------------------------
# ip2e (IP to email) - See the log file. |
# Created by q3aql (q3aql@protonmail.ch) |
# Licensed by GPL v.3 |
# Last update: 03-04-2021 |
# |
# Compatible with Python 3.x |
# --------------------------------------------------------------
version="1.3.2"
#Import python-modules
import os
import sys
#Check if your system use Python 3.x
if sys.version_info<(3,0):
print ("")
print ("You need python 3.x to run this program.")
print ("")
exit()
#Function to clear screen
def ClearScreen():
if sys.platform == "cygwin":
print (300 * "\n")
elif os.name == "posix":
os.system("clear")
elif os.name == "nt":
os.system("cls")
else:
print ("* Error: Unable clear screen")
#Detect system & PATH of user folder
if os.path.exists("/storage/sdcard0"):
HOMESCARD0="/storage/sdcard0/Android/data"
os.chdir(HOMESCARD0)
print ("Android (Posix) detected")
elif os.name == "posix":
os.chdir(os.environ["HOME"])
print ("Unix (Posix) detected")
elif os.name == "nt":
os.chdir(os.environ["USERPROFILE"])
print ("Windows detected")
if not os.path.exists(".ip2e"):
os.makedirs(".ip2e")
os.chdir(".ip2e")
if os.path.exists(".ip2e"):
os.chdir(".ip2e")
#See the log file
if os.path.isfile("ip2e.log"):
print ("ip2e.log exists")
ClearScreen()
readfile=open('ip2e.log', 'r')
print(readfile.read())
readfile.close()
else:
ClearScreen()
print ("")
print ("* ip2e.log doesn't exist.")
print ("")

11
src/ip2e.desktop Executable file
View File

@ -0,0 +1,11 @@
[Desktop Entry]
Name=ip2e (daemon)
GenericName=ip2e (daemon)
X-GNOME-FullName=ip2e (daemon)
Comment=Receive your public IP by email when it is renewed
Exec=ip2e-daemon.py
Icon=/usr/share/icons/ip2e.png
Terminal=true
Type=Application
StartupNotify=true
Categories=Network;FileTransfer;