From 7bd656c036e1a2a18f1b310a282d4248e1450c11 Mon Sep 17 00:00:00 2001 From: zhiyi Date: Fri, 15 Dec 2023 20:45:13 +0800 Subject: [PATCH] *update Dockerfile *add more read timeout set point --- Dockerfile | 23 +++++------------------ server/conn.go | 13 +++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9598663e..091e93ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,13 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:1.20-bullseye +FROM golang:1.20-bookworm -# apt 切换国内源,安装 google webrtc 依赖安装脚本的依赖 -# mirrors.163.com -# repo.huaweicloud.com -RUN sed -i 's|deb.debian.org|mirrors.163.com|g' /etc/apt/sources.list && \ - apt update && \ +RUN apt update && \ apt install xz-utils bzip2 sudo lsb-release ninja-build generate-ninja file patch -y # 安装nodejs 20 @@ -31,12 +27,7 @@ RUN apt-get install -y ca-certificates curl gnupg && \ apt-get install nodejs -y # 安装msquic依赖 -RUN apt-get update && \ - apt-get install -y cmake build-essential liblttng-ust-dev lttng-tools libssl-dev && \ - wget https://cmake.org/files/v3.23/cmake-3.23.0.tar.gz && \ - tar -zxvf cmake-3.23.0.tar.gz && cd cmake-3.23.0 && ./configure && make -j8 && make install && \ - cmake --version -# RUN apt-get install -y cmake build-essential liblttng-ust-dev lttng-tools +RUN apt-get install -y cmake build-essential liblttng-ust-dev lttng-tools libssl-dev # golang 切换国内源并且提前安装好依赖 ENV GO111MODULE=on @@ -47,7 +38,7 @@ RUN cd /go/src/github.com/isrc-cas/gt && \ rm -rf /go/src/github.com/isrc-cas/gt # 安装 gnu 编译链 -RUN apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-x86-64-linux-gnu g++-x86-64-linux-gnu -y +RUN apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-x86-64-linux-gnu g++-x86-64-linux-gnu # 安装 google webrtc 依赖 ADD ./dep/_google-webrtc/src/build /root/build @@ -55,8 +46,4 @@ RUN sed -i 's/egrep -q "i686|x86_64"/true/g' /root/build/install-build-deps.sh & DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai bash /root/build/install-build-deps.sh --no-chromeos-fonts && \ rm -rf /root/build -RUN if uname -m | grep aarch64; then \ - file /usr/x86_64-linux-gnu/lib/libm.a | grep "ASCII text" && \ - rm -f /usr/x86_64-linux-gnu/lib/libm.a && \ - ln -s /usr/x86_64-linux-gnu/lib/libm-2.31.a /usr/x86_64-linux-gnu/lib/libm.a && echo "success"; \ - fi \ No newline at end of file +RUN cp -r /usr/x86_64-linux-gnu/lib/* /usr/lib/x86_64-linux-gnu/ diff --git a/server/conn.go b/server/conn.go index 027b1fcd..c62d9738 100644 --- a/server/conn.go +++ b/server/conn.go @@ -962,6 +962,12 @@ func (c *conn) process(taskID uint32, task *conn, cli *client) { buf[4] = byte(predef.Close >> 8) buf[5] = byte(predef.Close) _, wErr = c.Write(buf[:6]) + if wErr == nil && + c.server.config.Timeout.Duration > 0 && + !c.server.config.TimeoutOnUnidirectionalTraffic { + dl := time.Now().Add(c.server.config.Timeout.Duration) + wErr = c.SetReadDeadline(dl) + } } pool.BytesPool.Put(buf) if rErr != nil || wErr != nil { @@ -1011,6 +1017,13 @@ func (c *conn) process(taskID uint32, task *conn, cli *client) { if wErr != nil { return } + if c.server.config.Timeout.Duration > 0 && !c.server.config.TimeoutOnUnidirectionalTraffic { + dl := time.Now().Add(c.server.config.Timeout.Duration) + wErr = c.SetReadDeadline(dl) + if wErr != nil { + return + } + } bufIndex -= 4 buf[bufIndex] = byte(predef.Data >> 8)