Skip to content

Commit fd1de7e

Browse files
committed
fix: error propagation in http-connect mode
If there is an error encountered by the proxy-server, such as DNS lookup, this is not propagated back correctly to the client in http-connect mode. This PR adds an http response, conveying the error message to the client before closing the http connection. Signed-off-by: Imran Pochi <[email protected]>
1 parent 60b5f0e commit fd1de7e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/server/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ limitations under the License.
1717
package server
1818

1919
import (
20+
"bytes"
2021
"context"
2122
"errors"
2223
"fmt"
2324
"io"
25+
"net/http"
2426
runpprof "runtime/pprof"
2527
"strconv"
2628
"strings"
@@ -119,6 +121,13 @@ func (c *ProxyClientConnection) send(pkt *client.Packet) error {
119121
return err
120122
} else if pkt.Type == client.PacketType_DIAL_RSP {
121123
if pkt.GetDialResponse().Error != "" {
124+
body := bytes.NewBufferString(pkt.GetDialResponse().Error)
125+
t := http.Response{
126+
StatusCode: 400,
127+
Body: io.NopCloser(body),
128+
}
129+
130+
t.Write(c.HTTP)
122131
return c.CloseHTTP()
123132
}
124133
return nil

0 commit comments

Comments
 (0)