From b7a76ab5ec633a0bfadbb6351ace9d966881aa1d Mon Sep 17 00:00:00 2001 From: xvzc Date: Sat, 5 Mar 2022 08:46:47 +0900 Subject: [PATCH] add timeout --- net/conn.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/conn.go b/net/conn.go index ad23326..64f1376 100644 --- a/net/conn.go +++ b/net/conn.go @@ -2,6 +2,7 @@ package net import ( "net" + "time" log "github.com/sirupsen/logrus" "github.com/xvzc/SpoofDPI/doh" @@ -56,6 +57,8 @@ func (conn *Conn) ReadBytes() ([]byte, error) { ret := make([]byte, 0) buf := make([]byte, BUF_SIZE) + conn.conn.SetReadDeadline(time.Now().Add(3 * time.Second)) + for { n, err := conn.Read(buf) if err != nil {