Esempio n. 1
0
func init() {
	config.RegisterInboundConnectionConfig("vmess",
		func(data []byte) (interface{}, error) {
			config := new(Config)
			err := json.Unmarshal(data, config)
			return config, err
		})
}
Esempio n. 2
0
func init() {
	config.RegisterInboundConnectionConfig("vmess",
		func(data []byte) (interface{}, error) {
			type JsonConfig struct {
				Users []*vmess.User `json:"clients"`
			}
			jsonConfig := new(JsonConfig)
			if err := json.Unmarshal(data, jsonConfig); err != nil {
				return nil, err
			}
			return &Config{
				AllowedUsers: jsonConfig.Users,
			}, nil
		})
}
Esempio n. 3
0
func init() {
	config.RegisterInboundConnectionConfig("socks",
		func(data []byte) (interface{}, error) {
			type SocksAccount struct {
				Username string `json:"user"`
				Password string `json:"pass"`
			}

			type SocksConfig struct {
				AuthMethod string             `json:"auth"`
				Accounts   []*SocksAccount    `json:"accounts"`
				UDP        bool               `json:"udp"`
				Host       *v2net.AddressJson `json:"ip"`
			}

			rawConfig := new(SocksConfig)
			if err := json.Unmarshal(data, rawConfig); err != nil {
				return nil, err
			}
			socksConfig := new(Config)
			if rawConfig.AuthMethod == AuthMethodNoAuth {
				socksConfig.AuthType = AuthTypeNoAuth
			} else if rawConfig.AuthMethod == AuthMethodUserPass {
				socksConfig.AuthType = AuthTypePassword
			} else {
				log.Error("Socks: Unknown auth method: %s", rawConfig.AuthMethod)
				return nil, internal.ErrorBadConfiguration
			}

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

			socksConfig.UDPEnabled = rawConfig.UDP
			if rawConfig.Host != nil {
				socksConfig.Address = rawConfig.Host.Address
			} else {
				socksConfig.Address = v2net.IPAddress([]byte{127, 0, 0, 1})
			}
			return socksConfig, nil
		})
}
Esempio n. 4
0
func init() {
	config.RegisterInboundConnectionConfig("dokodemo-door",
		func(data []byte) (interface{}, error) {
			type DokodemoConfig struct {
				Host         *v2net.AddressJson `json:"address"`
				PortValue    v2net.Port         `json:"port"`
				NetworkList  *v2net.NetworkList `json:"network"`
				TimeoutValue int                `json:"timeout"`
			}
			rawConfig := new(DokodemoConfig)
			if err := json.Unmarshal(data, rawConfig); err != nil {
				return nil, err
			}
			return &Config{
				Address: rawConfig.Host.Address,
				Port:    rawConfig.PortValue,
				Network: rawConfig.NetworkList,
				Timeout: rawConfig.TimeoutValue,
			}, nil
		})
}
Esempio n. 5
0
func init() {
	config.RegisterInboundConnectionConfig("vmess", json.JsonConfigLoader(func() interface{} {
		return new(Inbound)
	}))
}
Esempio n. 6
0
func init() {
	config.RegisterInboundConnectionConfig("dokodemo-door", json.JsonConfigLoader(func() interface{} {
		return new(DokodemoConfig)
	}))
}
Esempio n. 7
0
func init() {
	config.RegisterInboundConnectionConfig("http", json.JsonConfigLoader(func() interface{} {
		return new(HttpProxyConfig)
	}))
}
Esempio n. 8
0
func init() {
	config.RegisterInboundConnectionConfig("http",
		func(data []byte) (interface{}, error) {
			return new(Config), nil
		})
}