Exemple #1
0
func (cc *CConn) Read(num int) ([]byte, error) {
	data, err := Utils.ReadConn(num, cc.conn)
	if err != nil {
		return nil, err
	}
	return data, nil
}
Exemple #2
0
func (cc *CConn) ReadStr(num int) (string, error) {
	data, err := Utils.ReadConn(num, cc.conn)
	if err != nil {
		return "", err
	}
	//	Utils.LogInfo("read datastr=%v\n",data)
	return strings.Trim(string(data), "\r\n\t "), nil
}
Exemple #3
0
func (cc *CConn) ReadInt(num int) (int, error) {
	data, err := Utils.ReadConn(num, cc.conn)
	if err != nil {
		return 0, err
	}
	//	Utils.LogInfo("read data=%#v\n",data)
	return int(Utils.BytesToUint32(data)), nil

}
Exemple #4
0
func sendPolicy(conn net.Conn) {
	defer conn.Close()
	str := "<cross-domain-policy><site-control permitted-cross-domain-policies=\"master-only\"/>  <allow-access-from domain=\"*\" to-ports=\"9876\" /></cross-domain-policy>"
	//	str+="\0"
	Utils.LogInfo("send data=%s\n", str)
	_, err := Utils.ReadConn(23, conn)
	if err != nil {
		Utils.LogErr(err)
	}
	bufk := bufio.NewWriter(conn)

	bufk.WriteString(str)
	//	bufk.WriteString("\\0")
	bufk.Flush()
}
Exemple #5
0
/**
根据约定的数据包结构,区分出是telnet还是client
**/
func New(conn net.Conn) (IConn, error) {
	data, err := Utils.ReadConn(1, conn)
	Utils.LogInfo("new data=%v\n", string(data))
	if err != nil {
		return nil, err
	}
	Utils.LogInfo("data=%v\n", data)
	var retn IConn
	if string(data) == "1" {
		Utils.LogInfo("telnet\n")
		retn = NewTelnet(conn)
	} else {
		Utils.LogInfo("client\n")
		retn = NewClient(conn)
	}
	return retn, nil
}