config.go 974 B

123456789101112131415161718192021222324252627282930313233
  1. package simplified
  2. import (
  3. "context"
  4. "github.com/v2fly/v2ray-core/v4/common"
  5. "github.com/v2fly/v2ray-core/v4/common/protocol"
  6. "github.com/v2fly/v2ray-core/v4/proxy/socks"
  7. )
  8. func init() {
  9. common.Must(common.RegisterConfig((*ServerConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
  10. simplifiedServer := config.(*ServerConfig)
  11. fullServer := &socks.ServerConfig{
  12. AuthType: socks.AuthType_NO_AUTH,
  13. Address: simplifiedServer.Address,
  14. UdpEnabled: simplifiedServer.UdpEnabled,
  15. }
  16. return socks.NewServer(ctx, fullServer)
  17. }))
  18. common.Must(common.RegisterConfig((*ClientConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
  19. simplifiedClient := config.(*ClientConfig)
  20. fullClient := &socks.ClientConfig{
  21. Server: []*protocol.ServerEndpoint{
  22. {
  23. Address: simplifiedClient.Address,
  24. Port: simplifiedClient.Port,
  25. },
  26. },
  27. }
  28. return socks.NewClient(ctx, fullClient)
  29. }))
  30. }