1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-19 02:03:38 -04:00
v2fly/infra/conf/v5cfg/outbound.go
Xiaokang Wang (Shelikhoo) b6da3e86a5
Shadowsocks2022 Client Implementation Improvements (#2770)
* Shadowsocks2022 Client Implementation Improvements

1. Added UDP Replay Detection
2. Added UDP Processor State Cache
3. Added More Detailed Output for Time Difference Error
4. Replaced Mutex with RWMutex for reduced lock contention
5. Added per server session tracking of decryption cache and anti-replay window
6. Adjust server session track time
7. Increase per session buffer to 128
8. Fix client crash when EIH is not enabled
9. Fix client log contains non-human-friendly content
10.Remove mark and remove for trackedSessions
11. Fixed packet size uint16 overflow issue
2023-11-24 00:40:07 +00:00

73 lines
1.9 KiB
Go

package v5cfg
import (
"context"
"github.com/golang/protobuf/proto"
core "github.com/v2fly/v2ray-core/v5"
"github.com/v2fly/v2ray-core/v5/app/proxyman"
"github.com/v2fly/v2ray-core/v5/common/serial"
"github.com/v2fly/v2ray-core/v5/transport/internet"
)
func (c OutboundConfig) BuildV5(ctx context.Context) (proto.Message, error) {
senderSettings := &proxyman.SenderConfig{}
if c.SendThrough != nil {
address := c.SendThrough
if address.Family().IsDomain() {
return nil, newError("unable to send through: " + address.String())
}
senderSettings.Via = address.Build()
}
if c.StreamSetting != nil {
ss, err := c.StreamSetting.BuildV5(ctx)
if err != nil {
return nil, err
}
senderSettings.StreamSettings = ss.(*internet.StreamConfig)
}
if c.ProxySettings != nil {
ps, err := c.ProxySettings.Build()
if err != nil {
return nil, newError("invalid outbound detour proxy settings.").Base(err)
}
senderSettings.ProxySettings = ps
}
if c.MuxSettings != nil {
senderSettings.MultiplexSettings = c.MuxSettings.Build()
}
senderSettings.DomainStrategy = proxyman.SenderConfig_AS_IS
switch c.DomainStrategy {
case "UseIP":
senderSettings.DomainStrategy = proxyman.SenderConfig_USE_IP
case "UseIP4":
senderSettings.DomainStrategy = proxyman.SenderConfig_USE_IP4
case "UseIP6":
senderSettings.DomainStrategy = proxyman.SenderConfig_USE_IP6
case "AsIs", "":
default:
return nil, newError("unknown domain strategy: ", c.DomainStrategy)
}
if c.Settings == nil {
c.Settings = []byte("{}")
}
outboundConfigPack, err := loadHeterogeneousConfigFromRawJSON("outbound", c.Protocol, c.Settings)
if err != nil {
return nil, newError("unable to load outbound protocol config").Base(err)
}
return &core.OutboundHandlerConfig{
SenderSettings: serial.ToTypedMessage(senderSettings),
Tag: c.Tag,
ProxySettings: serial.ToTypedMessage(outboundConfigPack),
}, nil
}