github.com/imannamdari/v2ray-core/v5@v5.0.5/proxy/socks/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/proxy/socks"
     9  )
    10  
    11  func init() {
    12  	common.Must(common.RegisterConfig((*ServerConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
    13  		simplifiedServer := config.(*ServerConfig)
    14  		fullServer := &socks.ServerConfig{
    15  			AuthType:       socks.AuthType_NO_AUTH,
    16  			Address:        simplifiedServer.Address,
    17  			UdpEnabled:     simplifiedServer.UdpEnabled,
    18  			PacketEncoding: simplifiedServer.PacketEncoding,
    19  		}
    20  		return common.CreateObject(ctx, fullServer)
    21  	}))
    22  
    23  	common.Must(common.RegisterConfig((*ClientConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
    24  		simplifiedClient := config.(*ClientConfig)
    25  		fullClient := &socks.ClientConfig{
    26  			Server: []*protocol.ServerEndpoint{
    27  				{
    28  					Address: simplifiedClient.Address,
    29  					Port:    simplifiedClient.Port,
    30  				},
    31  			},
    32  		}
    33  		return common.CreateObject(ctx, fullClient)
    34  	}))
    35  }