FlyingDiver / Indigo-SMTPd

MIT License
0 stars 0 forks source link

Can't install twisted library #1

Closed whmoorejr closed 5 years ago

whmoorejr commented 5 years ago

Short Story: WHM-Server:~ williammoore$ sudo easy_install-2.6 pip Searching for pip Reading http://pypi.python.org/simple/pip/ Couldn't find index page for 'pip' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading http://pypi.python.org/simple/ No local packages or download links found for pip error: Could not find suitable distribution for Requirement.parse('pip')

Long Story: I'm sorry that I keep bugging you on different plugins... first twillio, then pushover, now this....

So... I've been trying to figure out a way to get instant notifications from network devices that have email notification capabilities (security cameras, DVRs, NVRs). I know I can use another gmail account and better email... but there is a lag that's no good for using camera motion to trigger a light.

So, I tried using a FakeSMTP [http://nilhcem.com/FakeSMTP/index.html] . That worked. Emails sent from my NVR on that port were picked up by that SMTP program and put in a folder.... but I couldn't get indigo to do anything with that and I got errors when I tried to incorporate better email with it.

FlyingDiver commented 5 years ago

Try just the plain vanilla pip command. Not sure why that calls for pip2.6. It was written a long time ago.

whmoorejr commented 5 years ago

Cool.. now for step 2. "no matching distribution found for twisted==15.4.0

is indigo still on python 2.6? can I go with a newer version of twisted?

FlyingDiver commented 5 years ago

Wow. I really need to update that. Try version 16.2.0.

FlyingDiver commented 5 years ago

I think I'll probably bundle it into the plugin just to avoid this issue. I did that with Twilio.

whmoorejr commented 5 years ago

That would be helpful for folks like me that freak out a little when messing around in terminal.... this is where I'm at now:

WHM-Server:~ williammoore$ sudo pip install twisted==16.2.0 Password: The directory '/Users/williammoore/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/williammoore/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting twisted==16.2.0 Could not fetch URL https://pypi.python.org/simple/twisted/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping Could not find a version that satisfies the requirement twisted==16.2.0 (from versions: ) No matching distribution found for twisted==16.2.0 WHM-Server:~ williammoore$

FlyingDiver commented 5 years ago

What version of MacOS are you running?

whmoorejr commented 5 years ago

10.10.5 (Yosemite) on an 2012 Mac mini

FlyingDiver commented 5 years ago

Then you can forget ever running pip. The servers now require a newer version of TLS which you won't get until High Sierra or later. Which also breaks a number of other plugins.

FlyingDiver commented 5 years ago

I'll take a look at bundling the libraries with the plugins, but a quick test on my development system failed miserably. Not sure what it's going to take to make it work.

whmoorejr commented 5 years ago

Ok. I may also experiment with your UDP Listener Plugin. Security Camera NVRs have a "Alarm Center" function which broadcasts something over a specified port. It utilizes what DVR/NVR manufactures refer to as the "Alarm Center Protocol". But I can't find documentation on that anywhere online. When I run into weirdness with that, I'll probably reach out to you on that thread. In the meantime, I'll finish installing the SMTP plugin so I'll get a update notification in Indigo if you are able to get it functioning with the library bundling.

FlyingDiver commented 5 years ago

Have you looked at the Security Camera plugin? If that's a standard ONVIF camera, it should work with it.

whmoorejr commented 5 years ago

Yep. But Amcrest (what I'm slowly replacing my Foscam cameras with) now uses digest authentication which isn't part of the plugin. I had a hell of a time figuring out the script just to get snapshots for some other actions & triggers.

whmoorejr commented 5 years ago

import requests from requests.auth import HTTPDigestAuth r = requests.get('http://192.168.1.141:8141/cgi-bin/snapshot.cgi?', auth=HTTPDigestAuth('myusername', 'mypassword')) r.raise_for_status()

with open('/Users/williammoore/Desktop/IPCamRotate/R.jpg', 'wb') as image_file: image_file.write(r.content)

FlyingDiver commented 5 years ago

Try https://github.com/FlyingDiver/Indigo-SMTPd/releases/tag/2.0.0

FlyingDiver commented 5 years ago

Oops. Try https://github.com/FlyingDiver/Indigo-SMTPd/releases/tag/2.0.1

whmoorejr commented 5 years ago

Working on it.... Got some error messages at first. Changed the port config, changed logging to debug and restarted the plugin. No errors, but not working. Restarting indigo server now. (sometimes needed after installing a new plugin)

FlyingDiver commented 5 years ago

Make sure you have 2.0.1. 2.0.0 was broken. It only worked if the email sender was the same machine. Which is how I was testing it. :(

whmoorejr commented 5 years ago

Nothing negative in the log... but nothing is happening....

SMTPd set to 1027

Fake SMTP server set to 1024

To test, I have my NVR email config page up and I'm toggling between test emails on 1024 (Fake SMTP Server) and 1027 (Plugin).

my 1024 tests are going through... but my 1027 tests fail with no blips on the log.

whmoorejr commented 5 years ago

for the SMTP server address, I'm using indigo's IP: 192.168.1.10

FlyingDiver commented 5 years ago

In a terminal window, try:

nc 192.168.1.10 1027

Then ctl-d to exit.

whmoorejr commented 5 years ago

reply was: 220 WHM-Server.local Python SMTP proxy version 0.2

FlyingDiver commented 5 years ago

Then it's connecting to the plugin ok. So the camera isn't sending email properly.

Or at least it's not sending what the plugin is expecting.

whmoorejr commented 5 years ago

Success-ish....

From an older Foscam camera, it worked. From a NVR or from a newer Amcrest camera, did not work.

Unfortunately, the working cameras are the ones I'm phasing out.

FlyingDiver commented 5 years ago

Is it possible the newer cameras are set up to require SSL or some authentication?

whmoorejr commented 5 years ago

Selecting "None" is an option for Authentication.... something I have to do to make it work with the FakeSMTP application. (which will work when I change the port on the camera email setting back to 1024)

whmoorejr commented 5 years ago

But I don't even get anything negative in the log file to copy/past to you.

If you want to give me your email... I can change my camera to use my google SMTP and send you a test email to see if that shows anything weird (like a pre-formatted character string) or something that might be gumming it up.

whmoorejr commented 5 years ago

Some additional weirdness on my end. I can add gmail and send a test message from the NVR to myself (email to email, no plugin stuff).

From the newer cameras with the same gmail settings I get the same "test email failed" notice I get with the plugin. But, when I do an internal email with the FakeSMTP, the email works and the message goes through.

sometimes technology annoys me.

FlyingDiver commented 5 years ago

It's got to be an SMTP handshaking problem, so having it send me an email won't do any good.

The fact that it fails with Gmail is telling.

This is an Amcrest? What firmware version? I have an Amcrest with 2.520.AC00.18.R, Build Date: 2017-06-29 on it. I just tried setting up the email sender on it, and it fails connecting to Gmail as well.

FlyingDiver commented 5 years ago

The FakeSMTP application has an "SMTP Log" tab. Copy the contents from that for ONE successful email and post it here.

whmoorejr commented 5 years ago

Tried the "update firmware" to resolve the email thing from the amorist forum... no luck there. Using 2.460.AC01.0.R, build: 2018-06-26

whmoorejr commented 5 years ago

11:57:44 PM - SMTP connection from 192.168.1.101/192.168.1.101, new connection count: 1 11:57:44 PM - Server: 220 192.168.1.10 ESMTP SubEthaSMTP null 11:57:44 PM - Client: EHLO localhost 11:57:44 PM - Server: 250-192.168.1.10 250-8BITMIME 250-AUTH LOGIN 250 Ok 11:57:44 PM - Client: AUTH LOGIN 11:57:44 PM - Server: 334 VXNlcm5hbWU6 11:57:44 PM - Server: 334 UGFzc3dvcmQ6 11:57:44 PM - Server: 235 Authentication successful. 11:57:44 PM - Client: MAIL From: <> 11:57:44 PM - Server: 250 Ok 11:57:44 PM - Client: RCPT To: bill.moore.jr@gmail.com 11:57:44 PM - Server: 250 Ok 11:57:44 PM - Client: DATA 11:57:44 PM - Server: 354 End data with . 11:57:44 PM - Server: 250 Ok 11:57:44 PM - Client: QUIT 11:57:44 PM - Server: 221 Bye

whmoorejr commented 5 years ago

That was a working one from an NVR.

whmoorejr commented 5 years ago

Working one from the amcrest camera:

12:02:46 AM - SMTP connection from 192.168.1.141/192.168.1.141, new connection count: 1 12:02:46 AM - Server: 220 192.168.1.10 ESMTP SubEthaSMTP null 12:02:46 AM - Client: EHLO localhost 12:02:46 AM - Server: 250-192.168.1.10 250-8BITMIME 250-AUTH LOGIN 250 Ok 12:02:46 AM - Client: AUTH LOGIN 12:02:46 AM - Server: 334 VXNlcm5hbWU6 12:02:46 AM - Server: 334 UGFzc3dvcmQ6 12:02:46 AM - Server: 235 Authentication successful. 12:02:46 AM - Client: MAIL FROM: bill.moore.jr@gmail.com 12:02:46 AM - Server: 250 Ok 12:02:46 AM - Client: RCPT TO: bill.moore.jr@gmail.com 12:02:46 AM - Server: 250 Ok 12:02:46 AM - Client: RCPT TO: whm.indigo@gmail.com 12:02:46 AM - Server: 250 Ok 12:02:46 AM - Client: DATA 12:02:46 AM - Server: 354 End data with . 12:02:46 AM - Server: 250 Ok 12:02:46 AM - Client: QUIT 12:02:46 AM - Server: 221 Bye

FlyingDiver commented 5 years ago

I figured out the problem. The Amcrest is insisting on logging into the SMTP server, even when Authentication is set to None or the username/password fields are blank. Well, actually, it says failed but doesn't even try when the fields are blank.

The original plugin did authentication. But the stripped down one I wrote yesterday does not. And adding authentication, or even stubs to handle the client requests, is not simple.

FlyingDiver commented 5 years ago

Well, not as bad as I thought.

This version works with my Amcrest camera:

https://github.com/FlyingDiver/Indigo-SMTPd/releases/tag/2.0.2

whmoorejr commented 5 years ago

Outstanding. I have it working on my end now. I am getting a response from old Foscam, new Amcrest and the Amcrest NVR. I kinda wish I had some more stuff to play with.

As soon as I matched the username and password on the plugin config to the email settings... presto.

I really love this.... I was dreading having another device or system (like blue iris or sighthound) to waste computing power on half-ass video analytics when the cameras are already doing the work themselves.

FlyingDiver commented 5 years ago

The only thing I currently use it for is my Cummins standby generator. One of these days I'll write a full plugin to control the darn thing.

FlyingDiver commented 5 years ago

Release version is 2.0.3.