Upload file via SSH2 protocol using QNetworkAccessManager - qt

I need to upload an image file on server using ssh2 protocol on port 22. SSH2 protocol with QNetworkAccessManger is not popular on Google either. Here is my code.
QUrl uploadUrl("ssh2://192.168.10.227/var/www/html/img/"+mImgFile);
uploadUrl.setUserName("xxxxxx");
uploadUrl.setPassword("xxxxxx");
uploadUrl.setPort(22);
qDebug() << uploadUrl.toString();
QNetworkRequest uploadReq(uploadUrl);
mReply = mNetworkManager->put(uploadReq, &file);
connect(mReply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
With URL-scheme as "ssh2" or "sftp" or "ssh2.sftp"; it outputs that Protocol is unknown. And the reason i used strange-looking "ssh2.sftp", is here(just a little php code to view).
I want to know whether ssh2 can be used with qnetworkaccessmanager at all? If yes, what is the correct URL-format to upload an image file?

There is no SSH support in Qt, for example see
Howto implement SFTP with Qt/QNetworkAccessManager (C++) and How to easily establish an SSH connection in Qt?
The list of supported URL schemes in QNetworkAccessManager can be obtained by QNetworkAccessManager::supportedSchemes() that is ("ftp", "file", "qrc", "http", "https", "data") in default Qt releases (https is supported only if external OpenSSL library is found, since it is also not supplied with Qt).
So, it is still needed to use external C library libssh2 to work with SSH2 protocol using native sockets.
I found here that there was some old Qt extension LibQxt with Qt SSH support. However, it is no longer maintained.

Related

Serve HLS with raspap/lighttpd rather than nginx

I currently serve audio/video from a raspberry pi using the picam project along with nginx to stream it as an HLS (Http Live Streaming) stream (as detailed in the project page). Thus, in /etc/nginx/sites-available/default I add:
location /hls/ {
root /run/shm;
}
Then, I can access my stream (for example with VLC player) at http://mypi.local/hls/index.m3u8.
However, I no longer wish to rely on my internet box to stream. Indeed, I would like my client(s) to directly connect to the pi. Thus, I have recently tried Raspap to transform my raspberry pi to a hotspot.
However, as raspap seems to use lighttpd as its webserver, I am wondering how I can still stream my audio/video stream as it is currently done with picam and nginx.
server.modules += ("mod_alias")
alias.url = ( "/hls/" => "/run/shm/" )

Polipo Proxy specify network interface to listen on

Right at the moment I am taking a closer look to the polipo proxy software. I already managed to setup an easy socks5 proxy with basic user authentication.
All it needs to be finished is to change the listening interface from eth0 to ppp0. Sadly polipo documentation doesn't provide any detail about this task.
The operating system is Debian 8 running in Hyper-V.
Can this configuration somehow be accomplished, either through calling parameters or configuration file or even iptables?
In the function create_listener, in file io.c, after line 751, add something like the following:
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, "ppp0");
rc = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
if(rc < 0) {
done = (*handler)(-errno, NULL, NULL);
assert(done);
return NULL;
}
Note: this doesn't provide a working solution to the question. I looked into something similar, but settled with using a different proxy software. Perhaps this information can help arrive at a working solution.
Some possible solutions I have found are the following:
use network namespaces (unix stackexchange, superuser, igalia blog)
read more in info: info ip-netns
"configure polipo to listen on every interface, then block the requests from
interfaces you do not want with iptables" (archlinux forum)
use a different proxy software, like tinyproxy (archlinux forum)
[unix stackexchange]: https://unix.stackexchange.com/questions/210982
[superuser]: https://superuser.com/questions/241178

telit cell modem http server

I need to implement an http server on a device that will be installed at a remote location and acessible through a cell modem. I am experience in embedded systems but I'm new to cell modems.
I was originally using this cell modem: http://www.janus-rc.com/HSPA910cf.html (based on a Telit HE910 module) for SMS alerts but now need to implement the http server functionailty.
I am not sure whether this cell modem supports the http server functionality and cannot seem to find much on the topic.
Would appreciate if anyone with experience in cell modems can shed some light on this.
The HE910 does not have any sort of built-in HTTP server, but you can still implement your own.
If you look at the documentation (Telit_HE910_UE910_AT_Commands_Reference_Guide_r5), you'll see that the HE910 has support for TCP, allowing you to use AT commands to make and receive socket connections.
It even appears (see Telit_Easy_Script_Python_2.7_r3) that the HE910 supports on-board Python with the socket module, so you should be able to implement a small HTTP server without even requiring a host to drive it.

SSL. no OPENSSL_Applink

There are openssl server and Qt client using QSslSocket.
When client connected to server server shows no OPENSSL_Applink and shuts down. But with OpenSSL client server works correct. What can be a reason?
#include <openssl/applink.c>
Including applink.c will solve the problem. Please check OpenSSL FAQ
Basically we get this error only if we use any file handling APIs like d2i_X509. I was getting assert failure in applink.c while using this API in windows VC8.0. Later I have done fopen separately and called d2i_X509_fp API.

FTPS (FTP-SSL) in Qt 4.6

Im trying to get FTP-SSL to work with Qt 4.6.3. I've already compiled Qt with OpenSSL support. Are there any good resources about FTPS with Qt? It seems that QFtp does not provide SSL support. I really dont want to create my own FTPS implementation.
// edit:
I discovered QNetworkAccessManager (ty # frank) but I cant find any useful documentation or examples for SSL with it. Thats what I'm trying:
QUrl url = QUrl("ftp://localhost/filex.txt");
url.setUserName("root");
url.setPassword("root");
QNetworkRequest request(url);
QSslConfiguration SslConfiguration(QSslConfiguration::defaultConfiguration());
request.setSslConfiguration(SslConfiguration);
manager->get(request);
But FileZilla wont let me connect. The FZ console says:
(000035)21.12.2010 17:31:46 - (not logged in) (127.0.0.1)> USER root
(000035)21.12.2010 17:31:46 - (not logged in) (127.0.0.1)> 530 SSL required
FileZilla configuration:
FTP over SSL/TLS support enabled
Explicit FTP over TLS enabled
Plain unencrypted FTP disallowed
SSL forced for roots login
I would at least expect some sort of sslErrors signals since user/pw is fine and SSL fails, but I'm only getting authenticationRequired signals.
Thanks for your help!
Unfortunately there's no out of the box solution for FTPS in Qt.
QFtp implements many ftp commands
but does not support encryption.
QNetworkAccessManager supports only
basic ftp functions (file
download/upload) and does not support
encryption in case of ftp, either. It's
worth to mention it does support
encryption for HTTP, which is the
protocol it's mainly designed for.
QSslSocket implements SSL but no
specific protocol like FTP or HTTP
Taking above information into consideration an idea comes to mind to mix QFtp with QSslSocket to get encrypted FTP. The problem is QFtp class has no method which would allow to make QFtp use user supplied socket. By comparision QHttp has such a method - int QHttp::setSocket(QTcpSocket * socket)
Bottom line; according to Thiago Macieira (designer of QNetworkAccessManager) the way to go is to implement FTP protocol using QSslSocket.

Resources