Beispiel #1
0
func GetCache() (*cache, error) {
	if cacheSingleton == nil {

		var err error = nil
		cacheSingleton = new(cache)

		cacheSingleton.collection, err = unqlitego.NewDatabase("DNSCache.unqlite")
		if err != nil {
			return nil, err
		}

		//Commit After 100 Changes
		cacheSingleton.collection.CommitAfter = 100

		cacheSingleton.collection.SetMarshal(bson.Marshal)
		cacheSingleton.collection.SetUnmarshal(bson.Unmarshal)

		cacheSingleton.ipToHostname, err = unqlitego.NewDatabase("IPtoHostname.unqlite")
		//Commit After 100 Changes
		cacheSingleton.ipToHostname.CommitAfter = 100

		return cacheSingleton, err
	}

	return cacheSingleton, nil
}
func GetFilterCollectionHelper() (*filtercollectionhelper, error) {
	if filtercollectionHelperSingleton == nil {
		var err error

		filtercollectionHelperSingleton = new(filtercollectionhelper)
		filtercollectionHelperSingleton.collection, err = unqlitego.NewDatabase("FilterCollections.unqlite")
		filtercollectionHelperSingleton.domainToCollectionNames, err = unqlitego.NewDatabase("DomainToFilterCollections.key.unqlite")
		if err != nil {
			return filtercollectionHelperSingleton, err
		}
	}
	return filtercollectionHelperSingleton, nil
}
Beispiel #3
0
func GetLeaseHelper() (*leasehelper, error) {
	if leaseHelperSingleton == nil {
		var err error

		leaseHelperSingleton = new(leasehelper)
		leaseHelperSingleton.collection, err = unqlitego.NewDatabase("Lease.unqlite")
		if err != nil {
			return leaseHelperSingleton, err
		}

		leaseHelperSingleton.macaddressKey, err = unqlitego.NewDatabase("MacaddressToLease.key.unqlite")
		if err != nil {
			return leaseHelperSingleton, err
		}
	}
	return leaseHelperSingleton, nil
}
Beispiel #4
0
func GetUserHelper() (*userhelper, error) {
	if userHelperSingleton == nil {
		var err error

		userHelperSingleton = new(userhelper)
		userHelperSingleton.collection, err = unqlitego.NewDatabase("Users.unqlite")
		if err != nil {
			return userHelperSingleton, err
		}
	}
	return userHelperSingleton, nil
}
Beispiel #5
0
func GetDeviceHelper() (*devicehelper, error) {
	if deviceHelperSingleton == nil {
		var err error

		deviceHelperSingleton = new(devicehelper)
		deviceHelperSingleton.collection, err = unqlitego.NewDatabase("Device.unqlite")
		if err != nil {
			return deviceHelperSingleton, err
		}

		deviceHelperSingleton.ipAddressKey, err = unqlitego.NewDatabase("IPtoDevice.key.unqlite")
		if err != nil {
			return deviceHelperSingleton, err
		}

		deviceHelperSingleton.hostnameKey, err = unqlitego.NewDatabase("HostnametoDevice.key.unqlite")
		if err != nil {
			return deviceHelperSingleton, err
		}
	}

	return deviceHelperSingleton, nil
}
func GetBlockedRouteHelper() (*blockroutehelper, error) {
	if blockRouteHelperSingleton == nil {
		var err error

		blockRouteHelperSingleton = new(blockroutehelper)
		blockRouteHelperSingleton.collection, err = unqlitego.NewDatabase("Blocked.unqlite")
		blockRouteHelperSingleton.collection.SetMarshal(bson.Marshal)
		blockRouteHelperSingleton.collection.SetUnmarshal(bson.Unmarshal)
		if err != nil {
			return blockRouteHelperSingleton, err
		}
	}

	return blockRouteHelperSingleton, nil
}