Beispiel #1
0
func GetValidHost(remoteAddrPort string) (string, error) {
	if config.AnaLog.DevelopmentEnv {
		return "permanent.de", nil
	}

	var err error
	if ownDomain == "" {
		if config.AnaLog.Domain == "" {
			ownDomain, err = os.Hostname()
			if err != nil {
				return "", err
			}
			ownDomain = removeSubdomains(ownDomain)
		} else {
			ownDomain = config.AnaLog.Domain
		}
	}

	idl.Debug(ownDomain)

	var remoteAddr string

	remoteAddr, _, err = net.SplitHostPort(remoteAddrPort)
	if err != nil {
		return "", err
	}

	names, err := net.LookupAddr(remoteAddr)
	if err != nil {
		return "", err
	}

	for _, name := range names {
		remoteDomain := removeSubdomains(name)
		if remoteDomain == ownDomain {
			return name, nil
		}
		idl.Debug(remoteDomain)
	}

	return "", errors.New("invalid request")
}
Beispiel #2
0
func Constraint(constraint, version string) bool {
	c, err := semver.NewConstraint(constraint)
	if err != nil {
		idl.Err(err)
		return false
	}

	v, err := semver.NewVersion(version)
	if err != nil {
		idl.Debug(err)
		return false
	}

	return c.Check(v)
}
Beispiel #3
0
func CheckRecurredTaskEnd(begin logpoint.LogPoint) error {
	end, err := persistence.GetEndByStart(begin)
	if err == persistence.NXlogpoint {
		idl.Warn(`Task "`+begin.Task+`" not finished`, begin)
		return nil
	}

	if err != nil {
		negativeCheck("internal error")
		return err
	}

	if end.State != state.OK {
		idl.Warn(`Task "`+begin.Task+`" unsuccessful`, end)
	}

	idl.Debug("task successfully checked", end)

	return nil

}
Beispiel #4
0
func NotFound(w http.ResponseWriter, req *http.Request) *webapp.Error {
	idl.Debug(req)
	return webapp.Write(errors.New("404 - Not found"), "404 - This isn't the page you're looking for", http.StatusNotFound)
}