Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+28
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package proxymux splits a net.Listener in two, routing SOCKS5
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"tailscale.com/types/nettype"
|
||||
)
|
||||
|
||||
// SplitSOCKSAndHTTP accepts connections on ln and passes connections
|
||||
@@ -127,11 +129,15 @@ func (ln *listener) Addr() net.Addr {
|
||||
type connWithOneByte struct {
|
||||
net.Conn
|
||||
|
||||
b byte
|
||||
bRead bool
|
||||
b byte
|
||||
bRead bool
|
||||
readClosed bool
|
||||
}
|
||||
|
||||
func (c *connWithOneByte) Read(bs []byte) (int, error) {
|
||||
if c.readClosed {
|
||||
return 0, net.ErrClosed
|
||||
}
|
||||
if c.bRead {
|
||||
return c.Conn.Read(bs)
|
||||
}
|
||||
@@ -142,3 +148,22 @@ func (c *connWithOneByte) Read(bs []byte) (int, error) {
|
||||
bs[0] = c.b
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
// CloseRead implements [nettype.HalfCloser], allowing the underlying Conn
|
||||
// to be half-closed if possible. Otherwise, this is a no-op.
|
||||
func (c *connWithOneByte) CloseRead() error {
|
||||
if hc, ok := c.Conn.(nettype.HalfCloser); ok {
|
||||
c.readClosed = true
|
||||
return hc.CloseRead()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CloseWrite implements [nettype.HalfCloser], allowing the underlying Conn
|
||||
// to be half-closed if possible. Otherwise, this is a no-op.
|
||||
func (c *connWithOneByte) CloseWrite() error {
|
||||
if hc, ok := c.Conn.(nettype.HalfCloser); ok {
|
||||
return hc.CloseWrite()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user