예제 #1
0
//export tinyweb_config
func tinyweb_config(module *C.struct_kr_module, conf *C.char) int {
	var err error
	var config map[string]interface{}
	addr := "localhost:8053"
	if err = json.Unmarshal([]byte(C.GoString(conf)), &config); err != nil {
		fmt.Printf("[tinyweb] %s\n", err)
	} else {
		if v, ok := config["addr"]; ok {
			addr = v.(string)
		}
		if v, ok := config["geoip"]; ok {
			geoip.SetCustomDirectory(v.(string))
		}
	}
	geo_db, err = geoip.OpenTypeFlag(geoip.GEOIP_COUNTRY_EDITION, geoip.GEOIP_MEMORY_CACHE)
	if err != nil {
		fmt.Printf("[tinyweb] couldn't open GeoIP IPv4 Country Edition\n")
	}
	geo_db6, err = geoip.OpenTypeFlag(geoip.GEOIP_COUNTRY_EDITION_V6, geoip.GEOIP_MEMORY_CACHE)
	if err != nil {
		fmt.Printf("[tinyweb] couldn't open GeoIP IPv6 Country Edition\n")
	}

	// Start web interface
	http.HandleFunc("/feed", serve_feed)
	http.HandleFunc("/stats", serve_stats)
	http.HandleFunc("/geo", serve_geo)
	http.HandleFunc("/tinyweb.js", serve_file)
	http.HandleFunc("/datamaps.world.min.js", serve_file)
	http.HandleFunc("/topojson.js", serve_file)
	http.HandleFunc("/jquery.js", serve_file)
	http.HandleFunc("/epoch.css", serve_file)
	http.HandleFunc("/favicon.ico", serve_file)
	http.HandleFunc("/epoch.js", serve_file)
	http.HandleFunc("/d3.js", serve_file)
	http.HandleFunc("/", serve_page)
	// @todo Not sure how to cancel this routine yet
	fmt.Printf("[tinyweb] listening on %s\n", addr)
	go http.ListenAndServe(addr, nil)
	return 0
}
예제 #2
0
func (g *GeoIP) setDirectory() {
	if len(Config.GeoIP.Directory) > 0 {
		geoip.SetCustomDirectory(Config.GeoIP.Directory)
	}
}
예제 #3
0
파일: geoip.go 프로젝트: abh/geodns
func (g *GeoIP) setDirectory() {
	directory := Config.GeoIPDirectory()
	if len(directory) > 0 {
		geoip.SetCustomDirectory(directory)
	}
}