Ejemplo n.º 1
0
static void
print_resolved_service (const char *service,
                        GList      *targets,
			GError     *error)
{
  GList *t;  

  G_LOCK (response);
  printf ("Service: %s\n", service);
  if (error)
    {
      printf ("Error: %s\n", error->message);
      g_error_free (error);
    }
  else
    {
      for (t = targets; t; t = t->next)
	{
	  printf ("%s:%u (pri %u, weight %u)\n",
		  g_srv_target_get_hostname (t->data),
		  g_srv_target_get_port (t->data),
		  g_srv_target_get_priority (t->data),
		  g_srv_target_get_weight (t->data));
          g_srv_target_free (t->data);
	}
      g_list_free (targets);
    }
  printf ("\n");

  done_lookup ();
  G_UNLOCK (response);
}
Ejemplo n.º 2
0
static void
do_test1(GObject *sender, GAsyncResult *res, gpointer data) {
	GList *services = NULL;
	GError *error = NULL;
	GResolver *resolver;
	const char *servername = data;
	int port = 3478;

	services = g_resolver_lookup_service_finish(G_RESOLVER(sender),
			res, &error);
	if(error != NULL) {
		purple_debug_info("stun", "Failed to look up srv record : %s\n", error->message);

		g_error_free(error);
	} else {
		servername = g_srv_target_get_hostname((GSrvTarget *)services->data);
		port = g_srv_target_get_port((GSrvTarget *)services->data);
	}

	purple_debug_info("stun", "connecting to %s:%d\n", servername, port);

	resolver = g_resolver_get_default();
	g_resolver_lookup_by_name_async(resolver,
	                                servername,
	                                NULL,
	                                hbn_cb,
	                                GINT_TO_POINTER(port));
	g_object_unref(resolver);

	g_resolver_free_targets(services);
}
Ejemplo n.º 3
0
static void dns_srv_response(GObject *resolver,
                             GAsyncResult *result,
                             gpointer data)
{
    GError *error  = NULL;
    GList *targets = g_resolver_lookup_service_finish(G_RESOLVER(resolver),
                     result,
                     &error);
    struct sipe_dns_query *query = data;

    if (targets) {
        GSrvTarget *target = targets->data;
        query->callback(query->extradata,
                        g_srv_target_get_hostname(target),
                        g_srv_target_get_port(target));
        g_resolver_free_targets(targets);
    } else {
        SIPE_DEBUG_INFO("dns_srv_response: failed: %s",
                        error ? error->message : "UNKNOWN");
        g_error_free(error);
        if (query->callback)
            query->callback(query->extradata, NULL, 0);
    }
    g_object_unref(query->cancel);
    g_free(query);
}
Ejemplo n.º 4
0
static VALUE
rg_hostname(VALUE self)
{
        return CSTR2RVAL(g_srv_target_get_hostname(_SELF(self)));
}