コード例 #1
0
ファイル: lanternpro.go プロジェクト: Nuos/chained-server
func New(next http.Handler) (*LanternProFilter, error) {
	return &LanternProFilter{
		next:           next,
		proTokens:      set.New(),
		clientRegistry: ctrie.New(nil),
	}, nil
}
コード例 #2
0
	if config.EvaluateUnlistedResources {
		glog.Info("No resource listing matched, creating event.")
		go ids.AddEvent("Request", "RE1", r)
	}
}

var config VerbsConfig

type VerbsConfig struct {
	EnableGlobalPreflightRequests bool
	EvaluateUnlistedResources     bool
	Resources                     map[string][]string
}

var staticResourcePaths = set.New()
var regexResourcePaths = make([]*regexp.Regexp, 0)

func PopulateExpectedVerbs(verbsYamlFile *string) {
	//var config VerbsConfig

	source, err := ioutil.ReadFile(*verbsYamlFile)
	if err != nil {
		panic(err)
	}

	err = yaml.Unmarshal(source, &config)
	if err != nil {
		panic(err)
	}
コード例 #3
0
	}

	for _, re := range regexPaths {
		if re.MatchString(r.URL.Path) {
			// found match with regex, we're good
			return
		}
	}

	//create event - didn't find a match
	glog.Info("Did not find matching resource - creating event.")
	go ids.AddEvent("Access Control", "ACE1", r)

}

var staticPaths = set.New()
var regexPaths = make([]*regexp.Regexp, 0)

//var expectedResources = set.New()

type ResourcesConfig struct {
	Resources []string
}

func PopulateExpectedResources(resourcesYamlFile *string) {
	var config ResourcesConfig

	source, err := ioutil.ReadFile(*resourcesYamlFile)
	if err != nil {
		panic(err)
	}
コード例 #4
0
	// both have values
	if ip != "" && res != "" {
		//fmt.Println("both")
		return ip == b.Ipaddress && res == b.Resource
	}

	// only ip has value
	if ip != "" {
		//fmt.Println("ip only")
		return ip == b.Ipaddress
	}

	// only res has value
	if res != "" {
		//fmt.Println("res only")
		return res == b.Resource
	}

	return false
}

type Blocks []Block

var StoredBlocks = set.New()

func unixToTime(s int64) (time.Time, error) {
	//return time.Unix(0, ms*int64(time.Millisecond)), nil
	return time.Unix(s, 0), nil
}