mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-18 13:42:29 +03:00
Fixes and improvements
This commit is contained in:
@@ -76,6 +76,15 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
return outbound, nil
|
||||
}
|
||||
|
||||
func (h *Outbound) Start(stage adapter.StartStage) error {
|
||||
for _, outbound := range h.outbounds {
|
||||
if err := adapter.LegacyStart(outbound, stage); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
||||
if N.NetworkName(network) == N.NetworkUDP {
|
||||
return h.uotClient.DialContext(ctx, network, destination)
|
||||
|
||||
@@ -99,9 +99,9 @@ func (h *Inbound) connHandler(ctx context.Context, conn net.Conn, metadata adapt
|
||||
failoverConn := NewFailoverConn(ctx, conn, nil, func() {
|
||||
h.sessionMtx.Lock(sessionUUID)
|
||||
h.mtx.Lock()
|
||||
defer h.sessionMtx.Unlock(sessionUUID)
|
||||
defer h.mtx.Unlock()
|
||||
delete(h.conns, sessionUUID)
|
||||
h.sessionMtx.Unlock(sessionUUID)
|
||||
h.mtx.Unlock()
|
||||
})
|
||||
h.mtx.Lock()
|
||||
h.conns[sessionUUID] = failoverConn
|
||||
@@ -118,6 +118,7 @@ func (h *Inbound) connHandler(ctx context.Context, conn net.Conn, metadata adapt
|
||||
serverConn, ok := h.conns[sessionUUID]
|
||||
h.mtx.RUnlock()
|
||||
if !ok {
|
||||
h.sessionMtx.Unlock(sessionUUID)
|
||||
_, err := conn.Write([]byte{StatusSessionNotFound})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -70,7 +70,7 @@ func (c *Config) SelectEndpointFromConfig(useHTTP2 bool, useIPv6 bool, port int)
|
||||
v4 := c.EndpointH2V4
|
||||
ip := net.ParseIP(v4)
|
||||
if ip == nil {
|
||||
return nil, fmt.Errorf("invalid endpoint_h2_v4 value %q")
|
||||
return nil, fmt.Errorf("invalid endpoint_h2_v4 value %q", v4)
|
||||
}
|
||||
return &net.TCPAddr{IP: ip, Port: port}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user