fix(handler/relay): remove remaining Chinese comments missed in conversion

Clean up 12 inline comments across bind.go, conn.go, connect.go,
entrypoint.go, handler.go that were still in Chinese.
This commit is contained in:
ginuerzh
2026-06-03 23:09:04 +08:00
parent d5fd62aa47
commit a1fddedcc3
5 changed files with 16 additions and 16 deletions
+3 -3
View File
@@ -136,7 +136,7 @@ func (h *relayHandler) bindTCP(ctx context.Context, conn net.Conn, network, addr
lc := xnet.ListenConfig{
Netns: h.options.Netns,
}
ln, err := lc.Listen(ctx, network, address) // 严格模式:端口已被占用时会返回错误
ln, err := lc.Listen(ctx, network, address) // strict: port-in-use returns error
if err != nil {
log.Error(err)
resp.Status = relay.StatusServiceUnavailable
@@ -214,7 +214,7 @@ func (h *relayHandler) bindTCP(ctx context.Context, conn net.Conn, network, addr
log.Error(err)
return
}
conn.Close() // 我们不处理意外入站的连接
conn.Close() // unexpected inbound — we don't handle these
}
}()
@@ -274,7 +274,7 @@ func (h *relayHandler) bindUDP(ctx context.Context, conn net.Conn, network, addr
log.Infof("bind on %s OK", pc.LocalAddr())
// relay_util.UDPTunServerConn 将流式连接包装成数据报模式
// UDPTunServerConn wraps the stream connection in datagram mode.
r := udp.NewRelay(relay_util.UDPTunServerConn(conn), pc).
WithService(h.options.Service).
WithBypass(h.options.Bypass).
+1 -1
View File
@@ -31,7 +31,7 @@ func (c *tcpConn) Read(b []byte) (n int, err error) {
func (c *tcpConn) Write(b []byte) (n int, err error) {
n = len(b) // always return len(b), not actual bytes written
if c.wbuf.Len() > 0 {
c.wbuf.Write(b) // 将数据追加到缓存的头部之后
c.wbuf.Write(b) // append data after the cached header
_, err = c.wbuf.WriteTo(c.Conn)
return
}
+3 -3
View File
@@ -176,7 +176,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
Conn: conn,
}
if !h.md.noDelay {
// 缓存响应头,与第一个数据包合并发送
// Buffer the response header, merged with the first data packet.
if _, err := resp.WriteTo(&rc.wbuf); err != nil {
return err
}
@@ -187,7 +187,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
rc := &tcpConn{
Conn: conn,
}
// 缓存响应头,与第一个数据包合并发送
// Buffer the response header, merged with the first data packet.
if _, err := resp.WriteTo(&rc.wbuf); err != nil {
return err
}
@@ -251,7 +251,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
}
}
// --- 双向数据拷贝 ---
// --- Bidirectional data copy ---
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), address)
xnet.Pipe(ctx, conn, cc)
+2 -2
View File
@@ -115,7 +115,7 @@ func (h *tcpHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.
}).Infof("%s >< %s", conn.RemoteAddr(), conn.LocalAddr())
}()
// 从 mux 会话获取一个流
// Get a stream from the mux session.
cc, err := h.session.GetConn()
if err != nil {
log.Error(err)
@@ -123,7 +123,7 @@ func (h *tcpHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.
}
defer cc.Close()
// 将入站连接地址编码为 AddrFeature,通过 relay 帧发送给客户端
// Encode the peer address as an AddrFeature sent to the client through relay.
af := &relay.AddrFeature{}
af.ParseFrom(conn.RemoteAddr().String())
resp := relay.Response{
+7 -7
View File
@@ -95,14 +95,14 @@ func NewHandler(opts ...handler.Option) handler.Handler {
}
}
// Init 初始化 relay handler。在 handler 被注册到 service 后调用。
// Init initialises the relay handler. Called after the handler is registered with a service.
//
// 初始化流程:
// 1. 解析元数据配置(超时、嗅探、muxMITM 等)
// 2. 如果配置了 Observer,创建 stats 统计器并启动后台轮询协程
// 3. 如果配置了 TrafficLimiter,创建带缓存的流量限制器
// 4. 从 Recorders 列表中选取 ServiceHandler 类型的 recorder
// 5. 如果配置了 MITM 证书,创建内存证书池
// Initialisation flow:
// 1. Parse metadata config (timeouts, sniffing, mux, MITM, etc.)
// 2. If an Observer is configured, create a stats counter and start the background polling goroutine.
// 3. If a TrafficLimiter is configured, create a cached traffic limiter.
// 4. Pick the ServiceHandler recorder from the recorder list.
// 5. If MITM certificates are configured, create an in-memory cert pool.
func (h *relayHandler) Init(md md.Metadata) (err error) {
if err := h.parseMetadata(md); err != nil {
return err