From b58528d49e0d9617bfb84f72c3bcbbd8a7842b39 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 1 Mar 2023 10:51:14 +0800 Subject: [PATCH] Add MsQuic to Linux server build target, ref ryzom/ryzomcore#628 --- CMakeModules/Findmsquic.cmake | 24 +++++++++---------- azure-pipelines.yml | 20 +++++++++++----- .../src/frontend_service/quic_selfsign.cpp | 4 ++++ .../src/frontend_service/quic_transceiver.cpp | 6 +++-- .../docker/ryzombuild_focal_amd64/Dockerfile | 15 ++++++++++-- .../docker/ryzombuild_jammy_amd64/Dockerfile | 15 ++++++++++-- 6 files changed, 60 insertions(+), 24 deletions(-) diff --git a/CMakeModules/Findmsquic.cmake b/CMakeModules/Findmsquic.cmake index 0fc6cb0cde..5871239e8e 100644 --- a/CMakeModules/Findmsquic.cmake +++ b/CMakeModules/Findmsquic.cmake @@ -5,30 +5,30 @@ ENDIF() FIND_PATH( msquic_INCLUDE_DIRS NAMES msquic.h - PATHS /usr/local/include/ + PATHS /usr/local/include /usr/include ) FIND_LIBRARY( msquic_LIBRARY_RELEASE - NAMES msquic - PATHS /usr/local/lib/ + NAMES libmsquic.so.2 msquic libmsquic + PATHS /usr/lib/x86_64-linux-gnu /usr/local/lib /usr/lib /opt/local ) FIND_LIBRARY( msquic_LIBRARY_DEBUG - NAMES msquicd - PATHS /usr/local/lib/ + NAMES libmsquicd.so.2 msquicd libmsquicd + PATHS /usr/lib/x86_64-linux-gnu /usr/local/lib /usr/lib /opt/local ) IF (msquic_INCLUDE_DIRS) + IF(msquic_LIBRARY_RELEASE AND msquic_LIBRARY_DEBUG) SET(msquic_FOUND TRUE) - IF(msquic_LIBRARY_RELEASE AND msquic_LIBRARY_DEBUG) - SET(msquic_LIBRARIES ${msquic_LIBRARIES} optimized ${msquic_LIBRARY_RELEASE}) - SET(msquic_LIBRARIES ${msquic_LIBRARIES} debug ${msquic_LIBRARY_DEBUG}) - ENDIF() - IF(msquic_LIBRARY_RELEASE) - SET(msquic_LIBRARIES ${msquic_LIBRARIES} ${msquic_LIBRARY_RELEASE}) - ENDIF() + SET(msquic_LIBRARIES ${msquic_LIBRARIES} optimized ${msquic_LIBRARY_RELEASE}) + SET(msquic_LIBRARIES ${msquic_LIBRARIES} debug ${msquic_LIBRARY_DEBUG}) + ELSEIF(msquic_LIBRARY_RELEASE) + SET(msquic_FOUND TRUE) + SET(msquic_LIBRARIES ${msquic_LIBRARIES} ${msquic_LIBRARY_RELEASE}) + ENDIF() ENDIF() IF (msquic_FOUND) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3ac47f7aff..14abff0134 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,10 +27,12 @@ jobs: sudo apt install libgsf-1-dev -y sudo apt install qtbase5-dev qttools5-dev qttools5-dev-tools sudo apt install libmsquic - wget https://github.com/microsoft/msquic/blob/main/src/inc/msquic.h - wget https://github.com/microsoft/msquic/blob/main/src/inc/msquic_posix.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic_posix.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/quic_sal_stub.h sudo mv msquic.h /usr/include/msquic.h sudo mv msquic_posix.h /usr/include/msquic_posix.h + sudo mv quic_sal_stub.h /usr/include/quic_sal_stub.h displayName: 'Dependencies' - script: | mkdir build @@ -38,6 +40,7 @@ jobs: cd build cmake -G "Ninja" -DCMAKE_SUPPRESS_REGENERATION=ON \ -DWITH_STATIC=ON -DWITH_NEL_TESTS=ON -DWITH_NEL_SAMPLES=ON \ + -DWITH_MSQUIC=ON \ -DWITH_LUA51=OFF -DWITH_LUA52=ON \ -DWITH_RYZOM=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_CLIENT=ON -DWITH_RYZOM_TOOLS=ON \ -DWITH_NEL_TOOLS=ON -DWITH_NELNS=ON -DWITH_NELNS_LOGIN_SYSTEM=ON -DWITH_NELNS_SERVER=ON \ @@ -80,10 +83,12 @@ jobs: sudo apt install libgsf-1-dev -y sudo apt install qtbase5-dev qttools5-dev qttools5-dev-tools sudo apt install libmsquic - wget https://github.com/microsoft/msquic/blob/main/src/inc/msquic.h - wget https://github.com/microsoft/msquic/blob/main/src/inc/msquic_posix.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic_posix.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/quic_sal_stub.h sudo mv msquic.h /usr/include/msquic.h sudo mv msquic_posix.h /usr/include/msquic_posix.h + sudo mv quic_sal_stub.h /usr/include/quic_sal_stub.h displayName: 'Dependencies' - script: | mkdir build @@ -91,6 +96,7 @@ jobs: cd build cmake -G "Ninja" -DCMAKE_SUPPRESS_REGENERATION=ON \ -DWITH_STATIC=ON -DWITH_NEL_TESTS=ON -DWITH_NEL_SAMPLES=ON \ + -DWITH_MSQUIC=ON \ -DWITH_LUA51=OFF -DWITH_LUA52=ON \ -DWITH_RYZOM=ON -DWITH_RYZOM_SERVER=ON -DWITH_RYZOM_CLIENT=ON -DWITH_RYZOM_TOOLS=ON \ -DWITH_NEL_TOOLS=ON -DWITH_NELNS=ON -DWITH_NELNS_LOGIN_SYSTEM=ON -DWITH_NELNS_SERVER=ON \ @@ -148,10 +154,12 @@ jobs: sudo apt update sudo apt remove -y man-db sudo apt install -y --no-install-recommends $(aptPackages) - wget https://github.com/microsoft/msquic/blob/main/src/inc/msquic.h - wget https://github.com/microsoft/msquic/blob/main/src/inc/msquic_posix.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic_posix.h + wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/quic_sal_stub.h sudo mv msquic.h /usr/include/msquic.h sudo mv msquic_posix.h /usr/include/msquic_posix.h + sudo mv quic_sal_stub.h /usr/include/quic_sal_stub.h displayName: '(ubuntu) Dependencies' condition: eq(variables['Agent.JobName'], 'client ubuntu') - task: Cache@2 diff --git a/ryzom/server/src/frontend_service/quic_selfsign.cpp b/ryzom/server/src/frontend_service/quic_selfsign.cpp index 2c524ca291..fbeca98ee3 100644 --- a/ryzom/server/src/frontend_service/quic_selfsign.cpp +++ b/ryzom/server/src/frontend_service/quic_selfsign.cpp @@ -1083,6 +1083,10 @@ void *FES_findOrCreateSelfSignedCertificate(uint8 *certHash) return nullptr; } +void FES_freeSelfSignedCertificate(void *cert) +{ +} + #endif /* end of file */ diff --git a/ryzom/server/src/frontend_service/quic_transceiver.cpp b/ryzom/server/src/frontend_service/quic_transceiver.cpp index 2d0ff5d588..cd5ddb3ee8 100644 --- a/ryzom/server/src/frontend_service/quic_transceiver.cpp +++ b/ryzom/server/src/frontend_service/quic_transceiver.cpp @@ -24,6 +24,8 @@ #include "config.h" #include "quic_selfsign.h" +#include + #ifdef NL_MSQUIC_AVAILABLE #include @@ -217,7 +219,7 @@ void CQuicTransceiver::start(uint16 port) // Programmatically create a self signed certificate, only valid in Windows // This is very useful for development servers uint8 certHash[20]; - PCCERT_CONTEXT schannelCert = (PCCERT_CONTEXT)FES_findOrCreateSelfSignedCertificate(certHash); + void *schannelCert = FES_findOrCreateSelfSignedCertificate(certHash); // PCCERT_CONTEXT if (schannelCert) { // Server credentials @@ -369,7 +371,7 @@ _Function_class_(QUIC_LISTENER_CALLBACK) user->Connection = ev->NEW_CONNECTION.Connection; user->increaseRef(); // They're in. - MsQuic->SetCallbackHandler(ev->NEW_CONNECTION.Connection, CQuicTransceiverImpl::connectionCallback, (void *)user); + MsQuic->SetCallbackHandler(ev->NEW_CONNECTION.Connection, (void *)CQuicTransceiverImpl::connectionCallback, (void *)user); status = MsQuic->ConnectionSetConfiguration(ev->NEW_CONNECTION.Connection, m->Configuration); nlwarning("New QUIC connection"); break; diff --git a/tool/quick_start/docker/ryzombuild_focal_amd64/Dockerfile b/tool/quick_start/docker/ryzombuild_focal_amd64/Dockerfile index 687d24acdb..38781bec60 100644 --- a/tool/quick_start/docker/ryzombuild_focal_amd64/Dockerfile +++ b/tool/quick_start/docker/ryzombuild_focal_amd64/Dockerfile @@ -4,8 +4,12 @@ MAINTAINER Ryzom Core RUN sed -i -e 's/archive\.ubuntu\.com/mirrors\.digitalocean\.com/' /etc/apt/sources.list RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - software-properties-common \ - cmake ninja-build curl wget build-essential ccache \ + software-properties-common aria2 wget \ + && aria2c https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb \ + && dpkg -i packages-microsoft-prod.deb \ + && rm packages-microsoft-prod.deb \ + && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + cmake ninja-build curl build-essential ccache \ bison autoconf automake \ libpng-dev \ libjpeg-dev \ @@ -21,6 +25,13 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ liblzma-dev \ libgsf-1-dev \ qtbase5-dev qttools5-dev qttools5-dev-tools \ + libmsquic \ + && aria2c https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic.h \ + && aria2c https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic_posix.h \ + && aria2c https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/quic_sal_stub.h \ + && mv msquic.h /usr/include/msquic.h \ + && mv msquic_posix.h /usr/include/msquic_posix.h \ + && mv quic_sal_stub.h /usr/include/quic_sal_stub.h \ && rm -rf /var/lib/apt/lists/* ENV CC=/usr/lib/ccache/gcc diff --git a/tool/quick_start/docker/ryzombuild_jammy_amd64/Dockerfile b/tool/quick_start/docker/ryzombuild_jammy_amd64/Dockerfile index 9ed7eba959..9ec051bd41 100644 --- a/tool/quick_start/docker/ryzombuild_jammy_amd64/Dockerfile +++ b/tool/quick_start/docker/ryzombuild_jammy_amd64/Dockerfile @@ -4,8 +4,12 @@ MAINTAINER Ryzom Core RUN sed -i -e 's/archive\.ubuntu\.com/mirrors\.digitalocean\.com/' /etc/apt/sources.list RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - software-properties-common \ - cmake ninja-build curl wget build-essential ccache \ + software-properties-common aria2 wget \ + && aria2c https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb \ + && dpkg -i packages-microsoft-prod.deb \ + && rm packages-microsoft-prod.deb \ + && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + cmake ninja-build curl build-essential ccache \ bison autoconf automake \ libpng-dev \ libjpeg-dev \ @@ -21,6 +25,13 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ liblzma-dev \ libgsf-1-dev \ qtbase5-dev qttools5-dev qttools5-dev-tools \ + libmsquic \ + && aria2c https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic.h \ + && aria2c https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic_posix.h \ + && aria2c https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/quic_sal_stub.h \ + && mv msquic.h /usr/include/msquic.h \ + && mv msquic_posix.h /usr/include/msquic_posix.h \ + && mv quic_sal_stub.h /usr/include/quic_sal_stub.h \ && rm -rf /var/lib/apt/lists/* ENV CC=/usr/lib/ccache/gcc