예제 #1
0
func loadLocalHostMapping(file string) error {
	ini, err := util.LoadIniFile(file)
	if nil != err {
		return err
	}
	props, exist := ini.GetTagProperties("")
	if exist {
		for k, _ := range props {
			selector := &util.ListSelector{}
			vs, _ := ini.GetProperty("", k)
			hs := strings.Split(vs, "|")
			for _, h := range hs {
				selector.Add(h)
			}
			if strings.Contains(k, "*") {
				rh := new(regexHost)
				var err error
				if rh.regex, err = util.PrepareRegexp(k, true); nil != err {
					log.Printf("[ERROR]Invalid regex host pattern:%s for reason:%v\n", k, err)
					continue
				}
				rh.selector = selector
				regexMappingArray = append(regexMappingArray, rh)
			} else {
				mapping[k] = selector
			}
		}
	}
	return nil
}
예제 #2
0
파일: config.go 프로젝트: juju2013/gsnova
func InitConfig() error {
	cfg, err := util.LoadIniFile(CfgFile)
	Cfg = cfg
	if nil != err {
		log.Fatalf("Failed to load config file for reason:%s\n", err.Error())
	}
	if addr, exist := Cfg.GetProperty("LocalServer", "Listen"); exist {
		_, port, _ := net.SplitHostPort(addr)
		if len(port) > 0 {
			ProxyPort = port
		}
	}

	//	if timeout, exist := Cfg.GetIntProperty("LocalServer", "KeepAliveTimeout"); exist {
	//		KeepAliveTimeout = time.Duration(timeout)
	//	}
	//	if addr, exist := Cfg.GetProperty("LocalProxy", "Proxy"); exist {
	//		LocalProxy, _ = url.Parse(addr)
	//	}
	if enable, exist := Cfg.GetIntProperty("Misc", "DebugEnable"); exist {
		DebugEnable = (enable != 0)
	}
	if key, exist := Cfg.GetProperty("Misc", "RC4Key"); exist {
		RC4Key = key
	}
	event.SetRC4Key(RC4Key)
	return err
}
예제 #3
0
func LoadServerConfig(ctx appengine.Context) {
	ini, err := util.LoadIniFile("snova.conf")
	if nil != err {
		ctx.Errorf("Failed to load config:%v", err)
		return
	} else {
		ctx.Infof("Load config snova.conf success.")
	}
	fromIni(ini)
	//ctx.Infof("######%v  %d", Cfg.AllUsers, len(Cfg.AllUsers))
}