Skip to content

Commit

Permalink
Merge commit 'e6b7730437464f4ac060ee20df2ca533c6bbf426' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
QQxiaoming committed Nov 23, 2023
2 parents e16ac77 + e6b7730 commit 79ac331
Show file tree
Hide file tree
Showing 57 changed files with 4,998 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,20 @@ jobs:
./build_fcitx_qt6_linux.sh
cp ./fcitx-qt5-1.2.7/build/qt6/platforminputcontext/libfcitxplatforminputcontextplugin-qt6.so ./
- name: build libssh2
run: |
cd depend
export PATH=$Qt6_DIR/bin:$PATH
./build_libssh2.sh
sudo cp -R ./output /usr/local/
- name: Build all
run: |
git fetch --tags --force
git describe --always --long --dirty --abbrev=10 --tags | awk '{print "\""$0"\""}' > git_tag.inc
sed -i 's/git_tag.inc/git_tag.ci.inc/g' quardCRT.pro
sed -i 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.5.3\/gcc_64/g' build_deb.sh
sed -i 's/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=\/usr\/local\/output/g' ./lib/qtssh/qtssh.pri
./build_deb.sh
- name: Upload build asserts
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ jobs:
brew install --build-from-source cmake
brew install create-dmg
- name: build libssh2
run: |
cd depend
export PATH=$Qt6_DIR/bin:$PATH
./build_libssh2.sh
sudo cp -R ./output /usr/local/
- name: Build all
run: |
git fetch --tags --force
git describe --always --long --dirty --abbrev=10 --tags | awk '{print "\""$0"\""}' > git_tag.inc
sed -i'.original' -e 's/git_tag.inc/git_tag.ci.inc/g' quardCRT.pro
sed -i'.original' -e 's/QT_DIR=\/opt\/Qt6.2.0\/6.2.0\/gcc_64/QT_DIR=$(cd "$(dirname "$0")";pwd)\/..\/Qt\/6.5.3\/macos/g' build_dmg.sh
sed -i'.original' -e 's/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=\/usr\/local\/output/g' ./lib/qtssh/qtssh.pri
./build_dmg.sh
- name: Upload build asserts
Expand Down
38 changes: 34 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,25 @@ jobs:
Choco-Install -PackageName innosetup --force
Choco-Install -PackageName cmake --force
#- uses: msys2/setup-msys2@v2
# with:
# msystem: mingw64
- uses: msys2/setup-msys2@v2
with:
msystem: mingw64

- name: build libssh2
shell: msys2 {0}
run: |
pacman --noconfirm -S make cmake autoconf automake bison diffutils libtool texinfo xmlto
pacman --noconfirm -S base-devel msys2-devel mingw-w64-{x86_64,i686}-toolchain
cd depend
export PATH=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin:$PATH
./build_libssh2_mingw.sh
mkdir /d/libssh2
mkdir /d/libssh2/include
mkdir /d/libssh2/lib
mkdir /d/libssh2/bin
cp -r ./output/include/* /d/libssh2/include/
cp -r ./output/lib/* /d/libssh2/lib/
cp -r ./output/bin/* /d/libssh2/bin/
#- name: Build winpty
# shell: msys2 {0}
Expand All @@ -71,6 +87,7 @@ jobs:
./tools/sed/sed.exe -i "s/QT_TOOLS_DIR=C:\/Qt\/Qt6.2.0\/Tools\/mingw810_32\/bin/QT_TOOLS_DIR=C:\/ProgramData\/Chocolatey\/lib\/mingw\/tools\/install\/mingw64\/bin/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/mingw32-make -j8/mingw32-make -j1/g" ./build_setup.bat
./tools/sed/sed.exe -i "s/WINPTY_DIR=D:\\quardCRT\\depend\\winpty/WINPTY_DIR=D:\\winpty/g" ./lib/ptyqt/ptyqt.pri
./tools/sed/sed.exe -i "s/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=D:\\libssh2/g" ./lib/qtssh/qtssh.pri
./build_setup.bat
- name: Upload build asserts
Expand Down Expand Up @@ -109,7 +126,19 @@ jobs:
arch: x64
toolset: 14.29

- name: Install depend
- name: Install libssh2
run: |
cd depend
./build_libssh2_msvc.bat
mkdir D:\\libssh2
mkdir D:\\libssh2\\include
mkdir D:\\libssh2\\lib
mkdir D:\\libssh2\\bin
cp -r ./output/include/* D:\\libssh2\\include/
cp -r ./output/lib/* D:\\libssh2\\lib/
cp -r ./output/bin/* D:\\libssh2\\bin/
- name: Install winpty
run: |
cd D:/
curl -L https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msys2-2.7.0-x64.tar.gz -o winpty-0.4.3-msys2-2.7.0-x64.tar.gz
Expand All @@ -124,6 +153,7 @@ jobs:
./tools/sed/sed.exe -i "s/QT_DIR=C:\/Qt\/Qt6.2.0\/6.2.0\/msvc64\/bin/QT_DIR=%Qt6_DIR%/g" ./build_setup_msvc.bat
./tools/sed/sed.exe -i "s/QT_TOOLS_DIR=C:\/Qt\/Qt6.2.0\/Tools\/msvc64\/bin/QT_TOOLS_DIR=C:\/ProgramData\/Chocolatey\/lib\/mingw\/tools\/install\/msvc64\/bin/g" ./build_setup_msvc.bat
./tools/sed/sed.exe -i "s/WINPTY_DIR=D:\\quardCRT\\depend\\winpty/WINPTY_DIR=D:\\winpty/g" ./lib/ptyqt/ptyqt.pri
./tools/sed/sed.exe -i "s/LIBSSH2_DIR=\/libssh2/LIBSSH2_DIR=D:\\libssh2/g" ./lib/qtssh/qtssh.pri
./build_setup_msvc.bat
cp ./InnoSetup/quardCRT_setup.exe ./InnoSetup/quardCRT_setup_msvc.exe
Expand Down
1 change: 1 addition & 0 deletions build_setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ del /f /q /a .\sed*
xcopy /y .\build_release\out\quardCRT.exe .\InnoSetup\build\
:: 使用windeployqt拷贝依赖dll库到打包目录
windeployqt --dir .\InnoSetup\build .\InnoSetup\build\quardCRT.exe
xcopy /y "D:\libssh2\bin\*.dll" ".\InnoSetup\build\"
xcopy /y "D:\winpty\bin\winpty.dll" ".\InnoSetup\build\"
xcopy /y "D:\winpty\bin\winpty-agent.exe" ".\InnoSetup\build\"
xcopy /y .\scripts\Profile.ps1 .\InnoSetup\build\
Expand Down
1 change: 1 addition & 0 deletions build_setup_msvc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ del /f /q /a .\sed*
xcopy /y .\build_release\out\quardCRT.exe .\InnoSetup\build\
:: 使用windeployqt拷贝依赖dll库到打包目录
windeployqt --dir .\InnoSetup\build .\InnoSetup\build\quardCRT.exe
xcopy /y "D:\libssh2\bin\*.dll" ".\InnoSetup\build\"
xcopy /y "D:\winpty\bin\winpty.dll" ".\InnoSetup\build\"
xcopy /y "D:\winpty\bin\winpty-agent.exe" ".\InnoSetup\build\"
xcopy /y .\scripts\Profile.ps1 .\InnoSetup\build\
Expand Down
3 changes: 3 additions & 0 deletions depend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
!build_fcitx_qt6_linux.sh
!build_winpty_ms.sh
!build_libssh2.sh
!build_libssh2_msvc.bat
!build_libssh2_mingw.sh
20 changes: 20 additions & 0 deletions depend/build_libssh2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)

cd $SHELL_FOLDER
tar -xzvf openssl-3.1.4.tar.gz
cd $SHELL_FOLDER/openssl-3.1.4
./config --prefix=$SHELL_FOLDER/output --openssldir=$SHELL_FOLDER/output no-threads
make -j16
make install
rm -rf $SHELL_FOLDER/openssl-3.1.4

cd $SHELL_FOLDER
tar -xzvf libssh2-1.11.0.tar.gz
cd $SHELL_FOLDER/libssh2-1.11.0
./configure --prefix=$SHELL_FOLDER/output --enable-shared --disable-static --without-libz --with-openssl=$SHELL_FOLDER/output
make -j16
make install
rm -rf $SHELL_FOLDER/libssh2-1.11.0
20 changes: 20 additions & 0 deletions depend/build_libssh2_mingw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)

cd $SHELL_FOLDER
tar -xzvf openssl-3.1.4.tar.gz
cd $SHELL_FOLDER/openssl-3.1.4
./configure --prefix=$SHELL_FOLDER/output --openssldir=$SHELL_FOLDER/output no-threads mingw64
make -j16
make install
rm -rf $SHELL_FOLDER/openssl-3.1.4

cd $SHELL_FOLDER
tar -xzvf libssh2-1.11.0.tar.gz
cd $SHELL_FOLDER/libssh2-1.11.0
./configure --prefix=$SHELL_FOLDER/output --enable-shared --disable-static --without-libz --with-openssl=$SHELL_FOLDER/output
make -j16
make install
rm -rf $SHELL_FOLDER/libssh2-1.11.0
8 changes: 8 additions & 0 deletions depend/build_libssh2_msvc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

tar -xzvf libssh2-1.11.0.tar.gz
mkdir output
cd ./libssh2-1.11.0
cmake -DCRYPTO_BACKEND=WinCNG -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=../output .
cmake --build . --config Release --target install
Binary file added depend/libssh2-1.11.0.tar.gz
Binary file not shown.
Binary file added depend/openssl-3.1.4.tar.gz
Binary file not shown.
67 changes: 67 additions & 0 deletions lib/qtssh/qtssh.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
HEADERS += \
$$PWD/sshchannel.h \
$$PWD/sshclient.h \
$$PWD/sshprocess.h \
$$PWD/sshshell.h \
$$PWD/sshkey.h \
$$PWD/sshscpget.h \
$$PWD/sshscpsend.h \
$$PWD/sshsftpcommandget.h \
$$PWD/sshsftpcommandfileinfo.h \
$$PWD/sshsftpcommand.h \
$$PWD/sshsftpcommandmkdir.h \
$$PWD/sshsftpcommandsend.h \
$$PWD/sshsftpcommandreaddir.h \
$$PWD/sshsftpcommandunlink.h \
$$PWD/sshsftp.h \
$$PWD/sshtunneldataconnector.h \
$$PWD/sshtunnelinconnection.h \
$$PWD/sshtunneloutconnection.h \
$$PWD/sshtunnelout.h \
$$PWD/sshtunnelin.h

SOURCES += \
$$PWD/sshchannel.cpp \
$$PWD/sshclient.cpp \
$$PWD/sshkey.cpp \
$$PWD/sshprocess.cpp \
$$PWD/sshshell.cpp \
$$PWD/sshscpget.cpp \
$$PWD/sshscpsend.cpp \
$$PWD/sshsftpcommand.cpp \
$$PWD/sshsftpcommandfileinfo.cpp \
$$PWD/sshsftpcommandget.cpp \
$$PWD/sshsftpcommandmkdir.cpp \
$$PWD/sshsftpcommandreaddir.cpp \
$$PWD/sshsftpcommandsend.cpp \
$$PWD/sshsftpcommandunlink.cpp \
$$PWD/sshsftp.cpp \
$$PWD/sshtunneldataconnector.cpp \
$$PWD/sshtunnelinconnection.cpp \
$$PWD/sshtunnelin.cpp \
$$PWD/sshtunneloutconnection.cpp \
$$PWD/sshtunnelout.cpp

INCLUDEPATH += \
$$PWD

LIBSSH2_DIR=/home/qqm/Downloads/work/quardCRT/quardCRT/depend/output




win32:{
win32-g++ {
INCLUDEPATH += $${LIBSSH2_DIR}/include
LIBS += -L$${LIBSSH2_DIR}/lib -lssh2
}
win32-msvc*{
INCLUDEPATH += $${LIBSSH2_DIR}/include
LIBS += $${LIBSSH2_DIR}\lib\libssh2.lib
}
}

unix:{
INCLUDEPATH += $${LIBSSH2_DIR}/include
LIBS += -L$${LIBSSH2_DIR}/lib -lssh2
}
57 changes: 57 additions & 0 deletions lib/qtssh/sshchannel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "sshchannel.h"
#include "sshclient.h"
#include <QCoreApplication>

Q_LOGGING_CATEGORY(sshchannel, "ssh.channel", QtWarningMsg)

SshChannel::SshChannel(QString name, SshClient *client)
: QObject(client)
, m_sshClient(client)
, m_name(name)
{
qCDebug(sshchannel) << "createChannel:" << m_name;
QObject::connect(m_sshClient, &SshClient::sshDataReceived, this, &SshChannel::sshDataReceived, Qt::QueuedConnection);
}

SshChannel::~SshChannel()
{
qCDebug(sshchannel) << "destroyChannel:" << this;
setChannelState(ChannelState::Free);
}

SshClient *SshChannel::sshClient() const
{
return m_sshClient;
}

SshChannel::ChannelState SshChannel::channelState() const
{
return m_channelState;
}

void SshChannel::setChannelState(const ChannelState &channelState)
{
if(m_channelState != channelState)
{
qCDebug(sshchannel) << m_name << "Change State:" << m_channelState << "->" << channelState;
m_channelState = channelState;
emit stateChanged(m_channelState);
}
}

bool SshChannel::waitForState(SshChannel::ChannelState state)
{
QEventLoop wait(this);
QObject::connect(this, &SshChannel::stateChanged, &wait, &QEventLoop::quit);
while(channelState() != ChannelState::Error && channelState() != ChannelState::Free && channelState() !=state)
{
wait.exec();
}
return channelState() == state;
}


QString SshChannel::name() const
{
return m_name;
}
62 changes: 62 additions & 0 deletions lib/qtssh/sshchannel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* \file sshchannel.h
* \brief Generic Channel SSH class
* \author Fabien Proriol
* \version 1.0
* \date 2018/03/22
* \details This class is a Generic class for all Ssh Channel
*/

#pragma once

#include <QObject>
#include <QLoggingCategory>
#include <QMutex>
#include <libssh2.h>

class SshClient;

Q_DECLARE_LOGGING_CATEGORY(sshchannel)

class SshChannel : public QObject
{
Q_OBJECT
friend class SshClient;

public:
QString name() const;
virtual void close() = 0;

enum ChannelState {
Openning,
Exec,
Ready,
Close,
WaitClose,
Freeing,
Free,
Error
};
Q_ENUM(ChannelState)

ChannelState channelState() const;
void setChannelState(const ChannelState &channelState);
bool waitForState(SshChannel::ChannelState state);

SshClient *sshClient() const;

protected:
explicit SshChannel(QString name, SshClient *client);
virtual ~SshChannel();
SshClient *m_sshClient {nullptr};
QString m_name;

protected slots:
virtual void sshDataReceived() {}

private:
ChannelState m_channelState {ChannelState::Openning};

signals:
void stateChanged(ChannelState state);
};
Loading

0 comments on commit 79ac331

Please sign in to comment.