github.com/imannamdari/v2ray-core/v5@v5.0.5/proxy/shadowsocks/simplified/config.go (about) 1 package simplified 2 3 import ( 4 "context" 5 6 "github.com/imannamdari/v2ray-core/v5/common" 7 "github.com/imannamdari/v2ray-core/v5/common/protocol" 8 "github.com/imannamdari/v2ray-core/v5/common/serial" 9 "github.com/imannamdari/v2ray-core/v5/proxy/shadowsocks" 10 ) 11 12 func init() { 13 common.Must(common.RegisterConfig((*ServerConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { 14 simplifiedServer := config.(*ServerConfig) 15 fullServer := &shadowsocks.ServerConfig{ 16 User: &protocol.User{ 17 Account: serial.ToTypedMessage(&shadowsocks.Account{ 18 Password: simplifiedServer.Password, 19 CipherType: simplifiedServer.Method, 20 }), 21 }, 22 Network: simplifiedServer.Networks.GetNetwork(), 23 PacketEncoding: simplifiedServer.PacketEncoding, 24 } 25 26 return common.CreateObject(ctx, fullServer) 27 })) 28 29 common.Must(common.RegisterConfig((*ClientConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { 30 simplifiedClient := config.(*ClientConfig) 31 fullClient := &shadowsocks.ClientConfig{ 32 Server: []*protocol.ServerEndpoint{ 33 { 34 Address: simplifiedClient.Address, 35 Port: simplifiedClient.Port, 36 User: []*protocol.User{ 37 { 38 Account: serial.ToTypedMessage(&shadowsocks.Account{ 39 Password: simplifiedClient.Password, 40 CipherType: simplifiedClient.Method, 41 ExperimentReducedIvHeadEntropy: simplifiedClient.ExperimentReducedIvHeadEntropy, 42 }), 43 }, 44 }, 45 }, 46 }, 47 } 48 49 return common.CreateObject(ctx, fullClient) 50 })) 51 }