// isOriginAllowed checks if a given origin is allowed to perform cross-domain requests
// on the endpoint
439537
func (c *Cors) isOriginAllowed(r *http.Request, origin string) bool {
	if c.allowOriginFunc != nil {
		return c.allowOriginFunc(r, origin)
	}
	if c.allowedOriginsAll {
		return true
	}
	origin = strings.ToLower(origin)
	for _, o := range c.allowedOrigins {
		if o == origin {
			return true
		}
	}
	for _, w := range c.allowedWOrigins {
		if w.match(origin) {
			return true
		}
	}
	return false
}
1242683
func (m *GossipMessage) IsOrgRestricted() bool {
	return m.Tag == GossipMessage_CHAN_AND_ORG || m.Tag == GossipMessage_ORG_ONLY
}
205795
func (h *SetupHandler) isOnboarding(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	result, err := h.OnboardingService.IsOnboarding(ctx)
	if err != nil {
		EncodeError(ctx, err, w)
		return
	}
	if err := encodeResponse(ctx, w, http.StatusOK, isOnboardingResponse{result}); err != nil {
		logEncodingError(h.Logger, r, err)
		return
	}
}
237974
func (cfs *cacheFSObjects) IsOnline() bool {
	cfs.onlineMutex.RLock()
	defer cfs.onlineMutex.RUnlock()
	return cfs.online
}
1124924
func (tr TimeRange) IsOccurring(t time.Time) bool {
	return !(t.Before(tr.Start) || t.After(tr.End))
}
330867
func (i *ImportRestriction) isRestrictedDir(dir string) (bool, error) {
	if under, err := isPathUnder(i.BaseDir, dir); err != nil {
		return false, err
	} else if !under {
		return false, nil
	}

	for _, ignored := range i.IgnoredSubTrees {
		if under, err := isPathUnder(ignored, dir); err != nil {
			return false, err
		} else if under {
			return false, nil
		}
	}

	return true, nil
}
99260
func (w Week) IsOccurring(t time.Time) bool {
	weekInt := int(w)

	if weekInt == Last {
		return isLastWeekInMonth(t)
	}

	return weekInMonth(t) == weekInt
}
78966
func (m *Listener) GetUseOriginalDst() *types.BoolValue {
	if m != nil {
		return m.UseOriginalDst
	}
	return nil
}
299289
func (v Version) MinorUpgradeConstraintStr() ConstraintStr {
	segments := v.raw.Segments()
	return ConstraintStr(fmt.Sprintf("~> %d.%d", segments[0], segments[1]))
}
661663
func (fi *FileInfo) isRequestorUserSidEqualTo(sid *winacl.SID) bool {
	tok, err := fi.getRequestorToken()
	if err != nil {
		debug("IsRequestorUserSidEqualTo:", err)
		return false
	}
	defer tok.Close()
	tokUser, err := tok.GetTokenUser()
	if err != nil {
		debug("IsRequestorUserSidEqualTo: GetTokenUser:", err)
		return false
	}
	res, _, _ := syscall.Syscall(procEqualSid.Addr(), 2,
		uintptr(unsafe.Pointer(sid)),
		uintptr(unsafe.Pointer(tokUser.User.Sid)),
		0)
	if isDebug {
		u1, _ := (*syscall.SID)(sid).String()
		u2, _ := tokUser.User.Sid.String()
		debugf("IsRequestorUserSidEqualTo: EqualSID(%q,%q) => %v (expecting non-zero)\n", u1, u2, res)
	}
	runtime.KeepAlive(sid)
	runtime.KeepAlive(tokUser.User.Sid)
	return res != 0
}
1195730
func sameOrigin(u1, u2 *url.URL) bool {
	return u1.Scheme == u2.Scheme && u1.Hostname() == u2.Hostname()
}
254124
func Cors(allowedOrigins ...string) http.HandlerFunc {
	if len(allowedOrigins) == 0 {
		allowedOrigins = append(allowedOrigins, "*")
	}
	return func(rw http.ResponseWriter, req *http.Request) {
		allowed := false
		// Set appropriate response headers required for CORS
		reqOrigin := req.Header.Get(headerGetOrigin)
		for _, o := range allowedOrigins {
			// Set appropriate response headers required for CORS
			if o == "*" || o == reqOrigin {
				rw.Header().Set(headerOrigin, reqOrigin)
				allowed = true
				break
			}
		}

		if !allowed {
			webgo.SendHeader(rw, http.StatusForbidden)
			return
		}

		rw.Header().Set(headerMethods, allowMethods)
		rw.Header().Set(headerCreds, "true")

		// Adding allowed headers
		rw.Header().Set(headerAllowHeaders, allowHeaders+req.Header.Get(headerReqHeaders))
	}
}
53657
func DisallowedURLFilters(filters ...*regexp.Regexp) func(*Collector) {
	return func(c *Collector) {
		c.DisallowedURLFilters = filters
	}
}
265817
func (f DefaultDownloader) GetISOFileURI(isoURL string) string {
	urlObj, err := url.Parse(isoURL)
	if err != nil {
		return isoURL
	}
	if urlObj.Scheme == fileScheme {
		return isoURL
	}
	isoPath := filepath.Join(constants.GetMinipath(), "cache", "iso", filepath.Base(isoURL))
	// As this is a file URL there should be no backslashes regardless of platform running on.
	return "file://" + filepath.ToSlash(isoPath)
}
655568
func (s *Server) setAllowedOrigins(rw http.ResponseWriter, ro string) {
	if len(s.allowedOrigins) > 0 {
		if _, ok := s.allowedOrigins[ro]; ok {
			// localhost CORS is not supported by all browsers. It has to use "*".
			if strings.Contains(ro, "127.0.0.1") || strings.Contains(ro, "localhost") {
				ro = "*"
			}
			rw.Header().Set("Access-Control-Allow-Origin", ro)
			rw.Header().Set("Access-Control-Allow-Methods", allowedMethods)
			rw.Header().Set("Access-Control-Allow-Headers", allowedHeaders)
			rw.Header().Set("Access-Control-Max-Age", strconv.Itoa(maxAge))
		}
	}
}
1015990
func GetOrigin(path string) (Origin, error) {
	if strings.HasPrefix(path, "http") {
		return &HTTPOrigin{path}, nil
	} else if strings.HasPrefix(path, "/") {
		return &FileOrigin{path}, nil
	} else {
		return nil, errors.New("unknown origin: " + path)
	}
}
578815
func (c *Client) IsOnboarding(ctx context.Context) (isOnboarding bool, err error) {
	err = c.db.View(func(tx *bolt.Tx) error {
		result := tx.Bucket(onboardingBucket).Get(onboardingKey)
		isOnboarding = len(result) == 0
		return nil
	})
	return isOnboarding, err
}