Пример #1
0
func (d *D5ServConf) validate() error {
	if len(d.Listen) < 1 {
		return CONF_MISS.Apply("Listen")
	}
	a, e := net.ResolveTCPAddr("tcp", d.Listen)
	if e != nil {
		return LOCAL_BIND_ERROR.Apply(e)
	}
	d.ListenAddr = a
	if len(d.AuthTable) < 1 {
		return CONF_MISS.Apply("AuthTable")
	}
	d.AuthSys, e = auth.GetAuthSysImpl(d.AuthTable)
	ThrowErr(e)
	if len(d.Algo) < 1 {
		return CONF_MISS.Apply("Algo")
	}
	_, y := availableCiphers[d.Algo]
	if !y {
		return UNSUPPORTED_CIPHER.Apply(d.Algo)
	}
	if d.ServerName == NULL {
		return CONF_ERROR.Apply("ServerName")
	}
	if d.RSAKeys == nil {
		return CONF_MISS.Apply("ServerPrivateKey")
	}
	return nil
}
Пример #2
0
func (d *serverConf) validate() error {
	if len(d.Listen) < 1 {
		return CONF_MISS.Apply("Listen")
	}
	a, e := net.ResolveTCPAddr("tcp", d.Listen)
	if e != nil {
		return LOCAL_BIND_ERROR.Apply(e)
	}
	d.ListenAddr = a
	if len(d.Auth) < 1 {
		return CONF_MISS.Apply("Auth")
	}
	d.AuthSys, e = auth.GetAuthSysImpl(d.Auth)
	if e != nil {
		return e
	}
	if len(d.Cipher) < 1 {
		return CONF_MISS.Apply("Cipher")
	}
	_, e = GetAvailableCipher(d.Cipher)
	if e != nil {
		return e
	}
	if d.ServerName == NULL {
		return CONF_MISS.Apply("ServerName")
	}
	if d.Parallels < 2 || d.Parallels > 16 {
		return CONF_ERROR.Apply("Parallels")
	}
	if d.privateKey == nil {
		return CONF_MISS.Apply("PrivateKey")
	}
	if len(d.DenyDest) > 0 {
		if d.DenyDest == "OFF" || d.DenyDest == "off" {
			d.DenyDest = NULL
		} else if !regexp.MustCompile("[A-Za-z]{2}").MatchString(d.DenyDest) {
			return CONF_ERROR.Apply("DenyDest must be ISO3166-1 2-letter Country Code")
		}
	}
	return nil
}
Пример #3
0
func (d *D5ServConf) validate() error {
	if len(d.Listen) < 1 {
		return CONF_MISS.Apply("Listen")
	}
	a, e := net.ResolveTCPAddr("tcp", d.Listen)
	if e != nil {
		return LOCAL_BIND_ERROR.Apply(e)
	}
	d.ListenAddr = a
	if len(d.Auth) < 1 {
		return CONF_MISS.Apply("Auth")
	}
	d.AuthSys, e = auth.GetAuthSysImpl(d.Auth)
	ThrowErr(e)
	if len(d.Cipher) < 1 {
		return CONF_MISS.Apply("Cipher")
	}
	_, y := availableCiphers[d.Cipher]
	if !y {
		return UNSUPPORTED_CIPHER.Apply(d.Cipher)
	}
	if d.ServerName == NULL {
		return CONF_ERROR.Apply("ServerName")
	}
	if d.RSAKeys == nil {
		return CONF_MISS.Apply("ServerPrivateKey")
	}
	if len(d.DenyDest) > 0 {
		if d.DenyDest == "OFF" || d.DenyDest == "off" {
			d.DenyDest = NULL
		} else if !regexp.MustCompile("[A-Za-z]{2}").MatchString(d.DenyDest) {
			return CONF_ERROR.Apply("DenyDest must be ISO3166-1 2-letter Country Code")
		}
	}
	return nil
}