Beispiel #1
0
func readConfig() {
	cfg := qcfg.NewCfg("monim.cfg", opt.Cfg, false)
	accntfile := cfg.Str(opt.Env, "core", "passwdfile", "NOFILE")
	if accntfile != "NOFILE" {
		cfg1 := qcfg.NewCfg("passwd.cfg", accntfile, false)
		users := cfg1.GetRows("accnt")
		for _, usr := range users {
			pass := cfg1.Str("accnt", usr, "passwd", "NOPASS")
			if pass != "NOPASS" {
				passwd[usr] = pass
				username[usr] = cfg1.Str("accnt", usr, "name", usr)
				phonenumber[usr] = cfg1.Str("accnt", usr, "phone", "NA")
				email[usr] = cfg1.Str("accnt", usr, "email", "NA")
			}
		}
	}
	alertBaseHost = cfg.Str(opt.Env, "alerts", "host", "localhost")
	jobMailerPath = cfg.Str(opt.Env, "alerts", "jobmailerpath", "NOMAIL")
	opsdl = cfg.Str(opt.Env, "alerts", "opsdl", "*****@*****.**")
}
Beispiel #2
0
Datei: cim.go Projekt: LDCS/cim
func NewCimServer(host, simInst string, root *CimNode, data interface{}) (*CimServer, error) {
	cs := new(CimServer)
	if host == "" {
		host = "127.0.0.1"
	}
	cs.host = host
	cs.simInst = simInst
	cs.root = root
	cs.data = data
	var ccfg *qcfg.CfgBlock = qcfg.NewCfg(simInst, cfgFile, false)
	var port = ccfg.Str("ports-lst", "ports", simInst, "")
	if port == "" {
		return nil, errors.New("Invalid sim : " + simInst)
	}
	cs.port = port
	return cs, nil
}
Beispiel #3
0
Datei: cim.go Projekt: LDCS/cim
func NewCimConnection(host, simInst, connId string) (*CimConnection, error) {
	cc := new(CimConnection)
	if host == "" {
		host = "127.0.0.1"
	}
	cc.host = host
	cc.simInst = simInst
	var ccfg *qcfg.CfgBlock = qcfg.NewCfg(connId, cfgFile, false)
	var port = ccfg.Str("ports-lst", "ports", simInst, "")
	if port == "" {
		return nil, errors.New("Invalid sim : " + simInst)
	}
	cc.port = port
	err := errors.New("")
	cc.tcpAddr, err = net.ResolveTCPAddr("tcp4", cc.host+":"+cc.port)
	if err != nil {
		return nil, err
	}
	cc.tcpConn, err = net.DialTCP("tcp4", nil, cc.tcpAddr)
	if err != nil {
		return nil, err
	}
	err1 := cc.tcpConn.SetKeepAlive(true)
	err2 := cc.tcpConn.SetNoDelay(true)
	if err1 != nil || err2 != nil {
		cc.tcpConn.Close()
		return nil, errors.New("Cannot set KeepAlive or NoDelay")
	}
	_, err = cc.tcpConn.Write(gen_login_msg())
	if err != nil {
		cc.tcpConn.Close()
		return nil, errors.New("Cannot send login message to sim")
	}
	buf := make([]byte, 1024)
	_, err = cc.tcpConn.Read(buf)
	if err != nil {
		cc.tcpConn.Close()
		return nil, errors.New("Cannot read login msg response from sim")
	}
	//fmt.Println("Login response :", buf[:n])
	cc.resp = make([]byte, responseMaxLength)
	return cc, nil
}