mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-04 16:25:21 -05:00
update context functions
This commit is contained in:
@@ -2,10 +2,9 @@ package shadowsocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/app/log"
|
||||
"v2ray.com/core/common"
|
||||
@@ -40,7 +39,10 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
|
||||
|
||||
// Process implements OutboundHandler.Process().
|
||||
func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, dialer proxy.Dialer) error {
|
||||
destination := proxy.DestinationFromContext(ctx)
|
||||
destination, ok := proxy.TargetFromContext(ctx)
|
||||
if !ok {
|
||||
return errors.New("Shadowsocks|Client: Target not specified.")
|
||||
}
|
||||
network := destination.Network
|
||||
|
||||
var server *protocol.ServerSpec
|
||||
|
||||
@@ -75,7 +75,6 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet
|
||||
|
||||
func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection, dispatcher dispatcher.Interface) error {
|
||||
udpServer := udp.NewDispatcher(dispatcher)
|
||||
source := proxy.SourceFromContext(ctx)
|
||||
|
||||
reader := buf.NewReader(conn)
|
||||
for {
|
||||
@@ -86,8 +85,10 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
||||
|
||||
request, data, err := DecodeUDPPacket(v.user, payload)
|
||||
if err != nil {
|
||||
log.Info("Shadowsocks|Server: Skipping invalid UDP packet from: ", source, ": ", err)
|
||||
log.Access(source, "", log.AccessRejected, err)
|
||||
if source, ok := proxy.SourceFromContext(ctx); ok {
|
||||
log.Info("Shadowsocks|Server: Skipping invalid UDP packet from: ", source, ": ", err)
|
||||
log.Access(source, "", log.AccessRejected, err)
|
||||
}
|
||||
payload.Release()
|
||||
continue
|
||||
}
|
||||
@@ -105,7 +106,9 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
|
||||
}
|
||||
|
||||
dest := request.Destination()
|
||||
log.Access(source, dest, log.AccessAccepted, "")
|
||||
if source, ok := proxy.SourceFromContext(ctx); ok {
|
||||
log.Access(source, dest, log.AccessAccepted, "")
|
||||
}
|
||||
log.Info("Shadowsocks|Server: Tunnelling request to ", dest)
|
||||
|
||||
ctx = protocol.ContextWithUser(ctx, request.User)
|
||||
|
||||
Reference in New Issue
Block a user