예제 #1
0
파일: amq_shell.c 프로젝트: cookrn/openamq
static void s_do_authenticated_port_scan (
    char *s_opt_host, char *s_opt_vhost, char *s_opt_user, char *s_opt_pass)
{
    int
        port;
    icl_longstr_t
        *auth_data;                     //  Authorisation data
    amq_client_connection_t
        *connection;
    icl_shortstr_t
        host;
    int
        brokers_found = 0;

    icl_console_out ("Scanning for all accessible brokers on %s (ports 5000-9999)", s_opt_host);
    auth_data = amq_client_connection_auth_plain (s_opt_user, s_opt_pass);
    for (port = 5000; port < 10000; port++) {
        icl_shortstr_fmt (host, "%s:%d", s_opt_host, port);
        connection = amq_client_connection_new (host, s_opt_vhost, auth_data, "amq_shell", 0, 1000);
        if (connection) {
            icl_console_out ("Found %s/%s on %s",
                connection->server_product, connection->server_version, host);
            brokers_found++;
            amq_client_connection_destroy (&connection);
        }
    }
    icl_longstr_destroy (&auth_data);
    if (!brokers_found)
        icl_console_out ("No accessible AMQP brokers found");
    exit (EXIT_SUCCESS);
}
예제 #2
0
파일: rwire.c 프로젝트: lightwave/ropenamq
static VALUE rwire_connection_init(
	VALUE self,
	VALUE host,
	VALUE vhost,
	VALUE username,
	VALUE password,
	VALUE client_name,
	VALUE trace,
	VALUE timeout)
{
	icl_longstr_t *auth_data;
	char *_hostname    = StringValuePtr(host);
	char *_vhost       = StringValuePtr(vhost);
	char *_client_name = StringValuePtr(client_name);
	char *_username    = StringValuePtr(username);
	char *_password    = StringValuePtr(password);;

	//  Open all connections
	auth_data = amq_client_connection_auth_plain(_username, _password);
	amq_client_connection_t * c = amq_client_connection_new(
				_hostname,
				_vhost,
				auth_data,
				_client_name,
				FIX2INT(trace),
				FIX2INT(timeout));

	if (!c)
		rb_raise(eAMQError, "Failed to connect to AMQ broker");

	DATA_PTR(self) = c;

	return self;
}
예제 #3
0
        inline openamq_t (const char *host_, const char *send_rk_,
            const char *receive_rk_, bool direct)
        {
	    //  Store routing keys.
            strncpy (send_rk, send_rk_, 256);
	    strncpy (receive_rk, receive_rk_, 256);

            //  Initialise iCL.
            icl_system_initialise (0, NULL);

            //  Open a connection.
            icl_longstr_t *auth_data =
                amq_client_connection_auth_plain ("guest", "guest");
            connection = amq_client_connection_new (
                (char*) host_, "/", auth_data, "perf", 0, 30000);
            assert (connection);
            icl_longstr_destroy (&auth_data);

            //  Switch into direct mode if required.
            if (direct)
                connection->direct = TRUE;

            //  Open a channel.
            session = amq_client_session_new (connection);
            assert (session);

           //  Create a private queue.
           amq_client_session_queue_declare (
               session, 0, NULL, FALSE, FALSE, TRUE, TRUE, NULL);

           //  Bind the queue to the exchange.
           amq_client_session_queue_bind (session, 0, NULL, "amq.direct",
               (char*) receive_rk, NULL);

           //  Consume from the queue.
           amq_client_session_basic_consume (
               session, 0, NULL, NULL, TRUE, TRUE, TRUE, NULL);
        }