예제 #1
0
func RunCompact(dbpath string) {
	mystore, err := store.NewStore("leveldb", dbpath)
	check(err)
	defer mystore.Close()
	err = mystore.Compact()
	check(err)
}
예제 #2
0
func RunSearch(dbpath string, args []string) {
	mystore, err := store.NewStore("leveldb", dbpath)
	check(err)
	defer mystore.Close()

	docs, err := mystore.QueryString(args[0])
	check(err)
	for _, doc := range docs {
		fmt.Println(doc)
	}
}
예제 #3
0
func RunExpandCIDR(dbpath string, args []string) {
	mystore, err := store.NewStore("leveldb", dbpath)
	check(err)
	defer mystore.Close()

	ips, err := mystore.ExpandCIDR(args[0])
	check(err)
	for _, ip := range ips {
		fmt.Printf("%s\n", ip)
	}
}
예제 #4
0
func startWeb() {
	var stores []store.IpStore
	matches, err := filepath.Glob("*.db")
	check(err)
	for _, db := range matches {
		log.Printf("Opening %s\n", db)
		mystore, err := store.NewStore("leveldb", db)
		check(err)
		stores = append(stores, mystore)
	}
	http.Handle("/search", &storeHandler{stores: stores})
	log.Fatal(http.ListenAndServe(bind, nil))
}
예제 #5
0
func (i *Indexer) OpenOrCreateStore(filename string) (*store.IpStore, error) {
	s, alreadyExists := i.storeMap[filename]
	if alreadyExists {
		return &s, nil
	}
	log.Printf("Opening %s\n", filename)
	mystore, err := store.NewStore(i.config.Store, filename)
	if err != nil {
		return nil, err
	}
	i.storeMap[filename] = mystore
	i.stores = append(i.stores, mystore)
	return &mystore, nil
}
예제 #6
0
func RunIndex(dbpath string, backend_type string, args []string) {
	runtime.GOMAXPROCS(runtime.NumCPU())
	mystore, err := store.NewStore("leveldb", dbpath)
	check(err)
	defer mystore.Close()

	for _, path := range args {
		mybackend := backend.NewBackend(backend_type)
		matches, err := filepath.Glob(path)
		check(err)
		for _, fp := range matches {
			err = Index(mystore, mybackend, fp)
			check(err)
		}
	}
}