Qt frp+TightVNC 实现远程访问功能

一,背景

Windows 软件安装到客户机器上,出现问题 需要对其进行远程支持,前期使用向日葵免费版,但是向日葵这个软件不可控,万一弹个广告或者哪天不能用了 都是承担不起的,所以基于frp 内网床头+vnc 局域网远程访问,实现一套自己可控的 远程支持系统

 

二,实现方案

(1),frp 部署 ,主要为了实现内网穿透功能。具体参考:https://blog.csdn.net/weixin_38416696/article/details/109549598?ops_request_misc=%25257B%252522request%25255Fid%252522%25253A%252522160828588916780265325454%252522%25252C%252522scm%252522%25253A%25252220140713.130102334.pc%25255Fblog.%252522%25257D&request_id=160828588916780265325454&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_v2~rank_v29-1-109549598.pc_v2_rank_blog_default&utm_term=frp

 

(2),vnc 编译。

编辑很简单,下载源码,cmake生成vs文件,vs编译(https://www.tightvnc.com/download.php

 

(3),Qt 业务逻辑编写

1.客户按下快捷键,或者点击远程支持,启动 单独的 exe ,并把 关键参数传递过去。

QString exeFile = QCoreApplication::applicationDirPath()+QString("/remotesupport.exe");
    if(!QFile::exists(exeFile)){
        return;
    }

    QString path = QCoreApplication::applicationDirPath()+QString("/remotesupport.exe --name %1").arg(SettingController::GetInst().getUser());
    path.replace("/","//");
    std::string exepath = path.toLocal8Bit().toStdString();
    LOG(INFO)<<"remotehelp path.... "<<path;


    WinExec(exepath.c_str(),SW_SHOWDEFAULT);
    LOG(INFO)<<"remote help error.."<<GetLastError();

2.remotesupport.exe  主要功能如下

启动vnc

if(isExistProcess("tvnserver.exe")){
        KillProcess("tvnserver.exe");
    }

    QString cmdParam =QCoreApplication::applicationDirPath()+"/vnc/tvnserver.exe";
    QProcess process;
    m_vncOk = process.startDetached(cmdParam,QStringList());

    if(m_vncOk)
        qDebug()<<"vnc start success!!!";
    else
        qDebug()<<"vnc start failed..."<<cmdParam<<m_vncOk<<process.errorString();

写frp配置文件

QString filepath = QCoreApplication::applicationDirPath()+"/frp/frpc.ini";
    QFile file(filepath);

    //方式:Append为追加,WriteOnly,ReadOnly
    if (!file.open(QIODevice::WriteOnly|QIODevice::Text)) {
        return;
    }
    QTextStream out(&file);
    out.setCodec("utf-8");
    out<<"[common]"<<endl;
    out<<"server_addr="<<m_serverIp<<endl;
    out<<"server_port="<<m_serverPort<<endl;
    out<<"token = klxx!1234"<<endl;

    out<<endl;
    out<<"["<<m_name<<"]"<< endl;
    out<<"type=tcp"<<endl;
    out<<"local_ip="<<m_localIp<<endl;
    out<<"local_port="<<m_localPort<<endl;
    out<<"remote_port=0"<<endl;


    out.flush();
    file.close();

启动frp

if(isExistProcess("frpc.exe")){
        KillProcess("frpc.exe");
    }

    QString cmdParam =QCoreApplication::applicationDirPath()+"/frp/frpc.exe";

    QStringList list;
    list<<"-c"<<QCoreApplication::applicationDirPath()+"/frp/frpc.ini";
    QProcess process;
    m_frpOk = process.startDetached(cmdParam,list);
    if(m_frpOk)
        qDebug()<<"frp start success!!!";
    else
        qDebug()<<"frp start failed..."<<cmdParam<<m_frpOk<<process.errorString();

 

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

土拨鼠不是老鼠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值