opening my Pi up to the world. Because i can

Intel or AMD? nVidia or ATI? Lenovo or ASUS? All things computing hardware go here

opening my Pi up to the world. Because i can

Post by pretentious on Thu Oct 29, 2015 12:08 am
([msg=90339]see opening my Pi up to the world. Because i can[/msg])

So as some of you may or may not know, I have a raspberri pi in my room, with a 12v halogen lamp hooked up to it.
I also have a wifi dongle on the Pi, which seems to lose connection every time the dhcp lease expires, but that's another thread that I'll probably make after this one lol
Anyway I set up a php page on the local host that turns the light on and off, working on some prototyping to see how easy it would be. Turns out it's very easy lol and Then one thing led to another and now I have this
http://stumay.net/code/toggle.php booom
I think it would be a lot more interesting if i set up a web cam or something but I guess you can just imagine turning on a light from the other side of the world.
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
Can you say brainwashing It's a non stop disco
User avatar
pretentious
Addict
Addict
 
Posts: 1201
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)


Re: opening my Pi up to the world. Because i can

Post by Goatboy on Thu Oct 29, 2015 6:01 pm
([msg=90340]see Re: opening my Pi up to the world. Because i can[/msg])

Waiting for someone to

Code: Select all
while true; do curl 'http://stumay.net/code/toggle.php?toggle=true'; done


and splode ur lamp.
Assume that everything I say is or could be a lie.
19JAW6GabFHqe9yD9rr26QL3W3V2pNitbD
User avatar
Goatboy
Expert
Expert
 
Posts: 2863
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: opening my Pi up to the world. Because i can

Post by pretentious on Thu Oct 29, 2015 10:05 pm
([msg=90341]see Re: opening my Pi up to the world. Because i can[/msg])

Goatboy wrote:Waiting for someone to

Code: Select all
while true; do curl 'http://stumay.net/code/toggle.php?toggle=true'; done


and splode ur lamp.

I was gonna use a post to add some complexity to the script but i didn't know how to hyperlink that off by heart :P

2 things. The pi makes its own request every x seconds so that's not realistically gonna happen. Also i literally use the bulb as a 20+hz strobe every morning to try and wake me up so ya, have fun ;)

-- Fri Oct 30, 2015 2:11 pm --

Oh something else I'm probs gonna play with today...
Hook up a geolocation api to this so i can display which parts of the world are turning it on/off haha. I want the wordpress visitor infograph!
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
Can you say brainwashing It's a non stop disco
User avatar
pretentious
Addict
Addict
 
Posts: 1201
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)


Re: opening my Pi up to the world. Because i can

Post by Goatboy on Fri Oct 30, 2015 7:28 pm
([msg=90345]see Re: opening my Pi up to the world. Because i can[/msg])

A POST would do nothing to mitigate the above, you can just do something like "curl -XPOST http://whatever" to use POST instead of GET.

What do you mean about the pi making its own request? You mean it is toggling the lamp itself?
Assume that everything I say is or could be a lie.
19JAW6GabFHqe9yD9rr26QL3W3V2pNitbD
User avatar
Goatboy
Expert
Expert
 
Posts: 2863
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: opening my Pi up to the world. Because i can

Post by pretentious on Sat Oct 31, 2015 6:40 am
([msg=90349]see Re: opening my Pi up to the world. Because i can[/msg])

Goatboy wrote:A POST would do nothing to mitigate the above, you can just do something like "curl -XPOST http://whatever" to use POST instead of GET.

So I could have held you down for maybe 10 seconds? Sweet :)
Goatboy wrote:What do you mean about the pi making its own request? You mean it is toggling the lamp itself?

Yeah, I make an HTTP request with the pi to perform the switching. the webpage is a simple interface for the outside world. I'm keeping the actual business logic local.

Speaking of the webpage though, I'm using a geolocation API to get country statistics. Keeping a log of activity and country in a flat file which will be processed and have stats counted every x hours, Added a javascript map, which due to my lack of js know how, is barely functional(wanted color coding for heavy traffic but I could barely understand most of the code), but i have stats on country mouse over which is better than nothing. It's kinda silly but I had the idea of getting stats on power consumption using the timestamps as well as eventually logging which countries visited the page but left without toggling, a 'the button' experiment lol We'll see what I can pull out my ass
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
Can you say brainwashing It's a non stop disco
User avatar
pretentious
Addict
Addict
 
Posts: 1201
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)


Re: opening my Pi up to the world. Because i can

Post by tremor77 on Wed Nov 04, 2015 1:16 am
([msg=90394]see Re: opening my Pi up to the world. Because i can[/msg])

I mentioned it in the other thread, you should fire up a websocket between the control page and the pi and add a function that serves as a rate limiter to keep people from strobe lighting you. (something like this: http://www.instructables.com/id/Easy-No ... -Raspberr/)

so the way the websocket would work is the webserver would host the websocket and the pi would be a client, as well as any remote visitors.. the "client" code served up to web visitors would be a little different than the client code for the pi.

pi-side you would just listen for toggle events.. user client side you could do a lot more login.. you could basically disable the button for anyone connected to the page until a timer expires as the page view would be shared by all connected browsers in realtime.. a number of logic scenarios could take place.. you could just concurrent users fight over control of the toggle.. deny multiple toggles in a row based on IP, etc etc.
Image
User avatar
tremor77
Addict
Addict
 
Posts: 1095
Joined: Wed Mar 31, 2010 12:00 pm
Location: New York
Blog: View Blog (0)


Re: opening my Pi up to the world. Because i can

Post by pretentious on Thu Nov 05, 2015 6:25 am
([msg=90409]see Re: opening my Pi up to the world. Because i can[/msg])

the server I'm using only has LAMP by default, I don't' know how easy it would be to set up node.js(don't have ssh that I know of). It's a pretty standard set up that I don't have a whole lot of control over tbh, I couldn't even install the latest version of open cart lol. I appreciate the advice and I'm definitely going to play with node in the future because I've decided now that I like javascript, this is actually a side project of a side project where I'm working on the software side of a home automation system. For this little project, It aint broke, At least not the server side lol

BTW I've moved to using jvectormap, which has a decent api so I can now generate the visual effects I want. On the server side, I'm generating javascript files which just contain global associative array variables for use in the map. I'm sure this is not the best way to do it but it's working for now haha. Next step is to draw lines to connect the the timeline of light toggles
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
Can you say brainwashing It's a non stop disco
User avatar
pretentious
Addict
Addict
 
Posts: 1201
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)



Return to Hardware

Who is online

Users browsing this forum: No registered users and 0 guests