コード例 #1
0
ファイル: socks.go プロジェクト: v2ray/v2ray-core
func (v *SocksServerConfig) Build() (*serial.TypedMessage, error) {
	config := new(socks.ServerConfig)
	if v.AuthMethod == AuthMethodNoAuth {
		config.AuthType = socks.AuthType_NO_AUTH
	} else if v.AuthMethod == AuthMethodUserPass {
		config.AuthType = socks.AuthType_PASSWORD
	} else {
		return nil, errors.New("Unknown socks auth method: " + v.AuthMethod)
	}

	if len(v.Accounts) > 0 {
		config.Accounts = make(map[string]string, len(v.Accounts))
		for _, account := range v.Accounts {
			config.Accounts[account.Username] = account.Password
		}
	}

	config.UdpEnabled = v.UDP
	if v.Host != nil {
		config.Address = v.Host.Build()
	}

	config.Timeout = v.Timeout
	return serial.ToTypedMessage(config), nil
}
コード例 #2
0
ファイル: socks.go プロジェクト: xyz12810/v2ray-core
func (this *SocksServerConfig) Build() (*loader.TypedSettings, error) {
	config := new(socks.ServerConfig)
	if this.AuthMethod == AuthMethodNoAuth {
		config.AuthType = socks.AuthType_NO_AUTH
	} else if this.AuthMethod == AuthMethodUserPass {
		config.AuthType = socks.AuthType_PASSWORD
	} else {
		return nil, errors.New("Unknown socks auth method: " + this.AuthMethod)
	}

	if len(this.Accounts) > 0 {
		config.Accounts = make(map[string]string, len(this.Accounts))
		for _, account := range this.Accounts {
			config.Accounts[account.Username] = account.Password
		}
	}

	config.UdpEnabled = this.UDP
	if this.Host != nil {
		config.Address = this.Host.Build()
	}

	config.Timeout = this.Timeout
	return loader.NewTypedSettings(config), nil
}