Okay so i know that you can route web-requests through a proxy in Python, is there any way to route ALL traffic from your system through a server. Much like a VPN client such as Hotspot Shield or CyberGhost, but a custom-build client using the Python language?
Any links/help is greatly appreciated.
Thanks.
The short answer is no.
The long answer is: network routing is managed by OS and could be managed by other utilities, like iptables. Adding such capabilities to standard libraries is out of the scope of programming language. So, what you are probably looking for is a binding of a VPN library (e.g. libpptp) or making syscalls in Cython, which is not much different than writing in C.
Related
Goal
I have made a website using the Flask framework and am fairly comfortable with HTML, CSS, JS, Python. My goal is to connect an arduino to the client's PC's usb port and use serial.write() to send a number to it.
Notes
I have a working example of interfacing with python if arduino was connected to the server.
import serial
ser = serial.Serial('COM4', 9600)
ser.write('5')
Now I want to run these exact 3 lines on the client side.
Is this even doable? I have researched a lot and it seems that this is not doable due to security reasons? (I'm hoping somebody proves me wrong here.) That is why I'm looking for a workaround. But before that I must mention, I don't need any of the data (numbers) to come from the server. Once the webpage is loaded all serial communication that I need is on the client side.
Client side python: I have looked into writing python on the client side and read about skulpt and PyPyjs but am not sure how I could run the mentioned 3 lines with them on client side(neither seems to support pyserial needed for import serial or at least I have not had any luck finding documentation)
I also looked into arduino documentation for interfacing with software but it seems that all the languages mentioned are server side. If you know of any possible direction languages that could help, I'd be happy to know and go learn them. I saw many forums mentioning Node.js but my understanding is that would also only do the job on the server side.
I'd appreciate any help on where else/other topics I should look into. Thanks in advance.
Is this even doable? I have researched a lot and it seems that this is not doable due to security reasons?
You are correct. There is no ability for browsers to access a COM port. It doesn't matter what language or framework you pick, a browser isn't going to give you that access.
You would need to make a standalone desktop application. You can use HTML and JavaScript to access serial ports, just not in a browser. Chrome Apps (which are actually going away) can do it, as well as an App that uses Electron.
I am trying to create a secure chat server with python, and after many hours of hunting all I have discovered is that I should use SSH, and that Paramiko seems to be the best python module for it (I may be wrong). I cannot find out how to implement this though, and being quite new to Python, the docs were a bit deep for me, especially as I didn't really know what to look for!
Any links to example code would be greatly appreciated, especially concerning the server (there seems to be hundreds of examples about connecting to an ssh server, but none about creating them - am i missing something vital here? I have heard that it is possible to create an ssh server in python, but the apparent lack of code on the internet is worrying me)
Thanks
EDIT:
My ultimate goal is to create a secure chat client with python, and I would like to keep it as simple as possible, however, security is the main goal. I have seen and made several chat clients in the recent past, however, they required telnet to connect to them, so were not secure, I wish to correct this.
Try Twisted, an asynchronous networking engine written in Python. They have a very simple example called chatserver.py. Get that running and then make it listen on SSL using a self-signed SSL certificate.
Here is another example.
I was wondering if you could help me with some programming. I'm trying to write a chat program but i'm stuck. I can use LAN easily enough, but I cant do it over WAN / the Internet as an external IP-address only refers to the Lan/router. how can you connect to one computer in particular?
I'm trying to write in Python, but ive ran into a problem. i'm using a very basic client-server system using the socket module for both (so far).
The problem i'm having is that, while connecting over LAN is easy enough, i need to connect over the internet to one computer. This is because the external IP is only referring to the router. I know i could use probably port-forwarding but i was wondering if there was a way to reach the individual computer without the user manipulating router settings.
There's something called NAT Traversal. But it's not standard at all and there are may ways to do it, depending on the router vendor and other things. So it's a very complex thing to implement in a generic manner.
I have multiples servers (200-300) in Python 2.4 calling a WCF service using REST. I would like to be able to notify those servers of some changes that occured on the WCF service instead of asking all servers in Python to do some pooling to detect such changes.
How can I do such broadcast, notification to avoid the pooling?
Thanks
Sylvain
A message bus seems to be the right choice. You might want to have a look at ZeroMQ. It's cross-platform and has bindings in a variety of languages.
Which way is better?
Creating a while loop and then using the select module OR using ThreadedTCPServer with a custom class.
Im having problems with the Threaded TCP Server, although it could just be my coding.
My personal recommendation is to use Twisted. It's a Python-based framework intended primarily for writing event-driven network software. The documentation has a lot of great examples of how to create various types of servers and clients, as well.
I am sure there is no such a thing like the "correct" way.
If you want not, must not or cannot use any of the existing server implementations the general idea is (in pseudo code):
ss = serversocket()
ss.bind ()
while (True):
cs = ss.accept ()
spawnCommThread (cs)
In the CommThread for each client you take care of reading from the socket returned by accept, communicate with your client and die, when the client closes the connection or another criterion is given.