示例#1
0
 public MessageQueue(MessageBrokerChannel channel, String queuename)
 {
     this._name = queuename;
     this._channel = channel;
 }
示例#2
0
        public Boolean Init()
        {
            this.Hostname = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "hostname", this.Hostname);
            this.Password = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "password", this.Password);
            this.Username = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "username", this.Username);
            this.UUID = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "uuid", this.UUID);
            this.Port = Util.checkregint("HKLM", @"SOFTWARE\dagent\messagebroker", "port", this.Port);
            this.Vhost = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "vhost", this.Vhost);
            this.RootKey = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "rootkey", this.RootKey);
            /*
             * Look for TXT records defining all the possible access methods which are available.
             */
            Resolver Resolver = new Resolver();
            Response response = Resolver.Query(this.Hostname,QType.TXT,QClass.ANY);
            LinkedList<Connector> AnyConnector = new LinkedList<Connector>();
            LinkedList<Connector> MacConnector = new LinkedList<Connector>();
            LinkedList<Connector> RouterIPConnector = new LinkedList<Connector>();
            foreach (AnswerRR answerRR in response.Answers)
            {
                switch (answerRR.Type)
                {
                    case Heijden.DNS.Type.TXT:
                        String[] strippedresponse = answerRR.RECORD.ToString().Split('\"');
                        String[] value = strippedresponse[1].Split('!');
                        if (value[0].ToLower().Equals("dagent"))
                        {
                            switch (value[1].ToLower())
                            {
                                case "connector":
                                    Connector conn = new Connector(value, 2);
                                    Util.log(this.ToString(), 99, conn.ToString());
                                    switch (conn.Match)
                                    {
                                        case "any":
                                            AnyConnector.AddLast(conn);
                                            break;
                                    }
                                    break;
                                case "rootkey":
                                    break;
                            }
                        }
                        break;
                }
            }
            /*
             * Fallback method to use DNS A Records
             */
            if (this._connection == null)
            {
                IPHostEntry ipentry = Dns.GetHostEntry(this.Hostname);
                foreach (IPAddress ip in ipentry.AddressList)
                {
                    try
                    {
                        Util.log(this.ToString(), 99, "Attempting connection to " + ip.ToString() + ":" + this.Port.ToString());
                        var factory = new ConnectionFactory()
                        {
                            HostName = ip.ToString(),
                            Password = this.Password,
                            UserName = this.Username,
                            Port = this.Port,
                            VirtualHost = this.Vhost
                        };
                        this._connection = factory.CreateConnection();
                        break;
                    }
                    catch (Exception e)
                    {
                        Util.log(this.ToString(), 1, e.ToString());
                    }

                }
                if (this._connection == null)
                {
                    Util.log(this.ToString(), 0, "Unable to connect to " + this.Hostname);
                    return false;
                }

                this.persistant = this.NewChannel();
                String queuename = "persist." + this.UUID + ".control";
                this.persistant.QueueDeclare(queuename,true);
                this.persistant.QueueBind(queuename, "dagent.control", "");
                return true;
            }
            return false;
        }
示例#3
0
 public MessageBrokerChannel NewChannel()
 {
     MessageBrokerChannel channel = new MessageBrokerChannel(this._connection.CreateModel());
     return channel;
 }
示例#4
0
 public MessageQueue(MessageBrokerChannel channel, String queuename)
 {
     this._name    = queuename;
     this._channel = channel;
 }
示例#5
0
        public Boolean Init()
        {
            this.Hostname = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "hostname", this.Hostname);
            this.Password = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "password", this.Password);
            this.Username = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "username", this.Username);
            this.UUID     = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "uuid", this.UUID);
            this.Port     = Util.checkregint("HKLM", @"SOFTWARE\dagent\messagebroker", "port", this.Port);
            this.Vhost    = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "vhost", this.Vhost);
            this.RootKey  = Util.checkregstring("HKLM", @"SOFTWARE\dagent\messagebroker", "rootkey", this.RootKey);

            /*
             * Look for TXT records defining all the possible access methods which are available.
             */
            Resolver Resolver = new Resolver();
            Response response = Resolver.Query(this.Hostname, QType.TXT, QClass.ANY);
            LinkedList <Connector> AnyConnector      = new LinkedList <Connector>();
            LinkedList <Connector> MacConnector      = new LinkedList <Connector>();
            LinkedList <Connector> RouterIPConnector = new LinkedList <Connector>();

            foreach (AnswerRR answerRR in response.Answers)
            {
                switch (answerRR.Type)
                {
                case Heijden.DNS.Type.TXT:
                    String[] strippedresponse = answerRR.RECORD.ToString().Split('\"');
                    String[] value            = strippedresponse[1].Split('!');
                    if (value[0].ToLower().Equals("dagent"))
                    {
                        switch (value[1].ToLower())
                        {
                        case "connector":
                            Connector conn = new Connector(value, 2);
                            Util.log(this.ToString(), 99, conn.ToString());
                            switch (conn.Match)
                            {
                            case "any":
                                AnyConnector.AddLast(conn);
                                break;
                            }
                            break;

                        case "rootkey":
                            break;
                        }
                    }
                    break;
                }
            }

            /*
             * Fallback method to use DNS A Records
             */
            if (this._connection == null)
            {
                IPHostEntry ipentry = Dns.GetHostEntry(this.Hostname);
                foreach (IPAddress ip in ipentry.AddressList)
                {
                    try
                    {
                        Util.log(this.ToString(), 99, "Attempting connection to " + ip.ToString() + ":" + this.Port.ToString());
                        var factory = new ConnectionFactory()
                        {
                            HostName    = ip.ToString(),
                            Password    = this.Password,
                            UserName    = this.Username,
                            Port        = this.Port,
                            VirtualHost = this.Vhost
                        };
                        this._connection = factory.CreateConnection();
                        break;
                    }
                    catch (Exception e)
                    {
                        Util.log(this.ToString(), 1, e.ToString());
                    }
                }
                if (this._connection == null)
                {
                    Util.log(this.ToString(), 0, "Unable to connect to " + this.Hostname);
                    return(false);
                }

                this.persistant = this.NewChannel();
                String queuename = "persist." + this.UUID + ".control";
                this.persistant.QueueDeclare(queuename, true);
                this.persistant.QueueBind(queuename, "dagent.control", "");
                return(true);
            }
            return(false);
        }
示例#6
0
        public MessageBrokerChannel NewChannel()
        {
            MessageBrokerChannel channel = new MessageBrokerChannel(this._connection.CreateModel());

            return(channel);
        }