1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* GIO - GLib Input, Output and Streaming Library
5 * Copyright (C) 2008 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 #include "gresolver.h"
26 #include "gnetworkingprivate.h"
27 #include "gasyncresult.h"
28 #include "ginetaddress.h"
30 #include "gsrvtarget.h"
31 #include "gthreadedresolver.h"
42 * @short_description: Asynchronous and cancellable DNS resolver
45 * #GResolver provides cancellable synchronous and asynchronous DNS
46 * resolution, for hostnames (g_resolver_lookup_by_address(),
47 * g_resolver_lookup_by_name() and their async variants) and SRV
48 * (service) records (g_resolver_lookup_service()).
50 * #GNetworkAddress and #GNetworkService provide wrappers around
51 * #GResolver functionality that also implement #GSocketConnectable,
52 * making it easy to connect to a remote host/service.
60 static guint signals[LAST_SIGNAL] = { 0 };
62 struct _GResolverPrivate {
64 time_t resolv_conf_timestamp;
73 * The object that handles DNS resolution. Use g_resolver_get_default()
74 * to get the default resolver.
76 * This is an abstract type; subclasses of it implement different resolvers for
77 * different platforms and situations.
79 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GResolver, g_resolver, G_TYPE_OBJECT,
80 G_ADD_PRIVATE (GResolver)
81 g_networking_init ();)
84 srv_records_to_targets (GList *records)
86 const gchar *hostname;
87 guint16 port, priority, weight;
91 for (l = records; l != NULL; l = g_list_next (l))
93 g_variant_get (l->data, "(qqq&s)", &priority, &weight, &port, &hostname);
94 target = g_srv_target_new (hostname, port, priority, weight);
95 g_variant_unref (l->data);
99 return g_srv_target_list_sort (records);
103 g_resolver_real_lookup_service (GResolver *resolver,
105 GCancellable *cancellable,
110 records = G_RESOLVER_GET_CLASS (resolver)->lookup_records (resolver,
112 G_RESOLVER_RECORD_SRV,
116 return srv_records_to_targets (records);
120 g_resolver_real_lookup_service_async (GResolver *resolver,
122 GCancellable *cancellable,
123 GAsyncReadyCallback callback,
126 G_RESOLVER_GET_CLASS (resolver)->lookup_records_async (resolver,
128 G_RESOLVER_RECORD_SRV,
135 g_resolver_real_lookup_service_finish (GResolver *resolver,
136 GAsyncResult *result,
141 records = G_RESOLVER_GET_CLASS (resolver)->lookup_records_finish (resolver,
145 return srv_records_to_targets (records);
149 g_resolver_class_init (GResolverClass *resolver_class)
151 /* Automatically pass these over to the lookup_records methods */
152 resolver_class->lookup_service = g_resolver_real_lookup_service;
153 resolver_class->lookup_service_async = g_resolver_real_lookup_service_async;
154 resolver_class->lookup_service_finish = g_resolver_real_lookup_service_finish;
158 * @resolver: a #GResolver
160 * Emitted when the resolver notices that the system resolver
161 * configuration has changed.
164 g_signal_new (I_("reload"),
167 G_STRUCT_OFFSET (GResolverClass, reload),
169 g_cclosure_marshal_VOID__VOID,
174 g_resolver_init (GResolver *resolver)
180 resolver->priv = g_resolver_get_instance_private (resolver);
183 if (stat (_PATH_RESCONF, &st) == 0)
184 resolver->priv->resolv_conf_timestamp = st.st_mtime;
188 G_LOCK_DEFINE_STATIC (default_resolver);
189 static GResolver *default_resolver;
192 * g_resolver_get_default:
194 * Gets the default #GResolver. You should unref it when you are done
195 * with it. #GResolver may use its reference count as a hint about how
196 * many threads it should allocate for concurrent DNS resolutions.
198 * Returns: (transfer full): the default #GResolver.
203 g_resolver_get_default (void)
207 G_LOCK (default_resolver);
208 if (!default_resolver)
209 default_resolver = g_object_new (G_TYPE_THREADED_RESOLVER, NULL);
210 ret = g_object_ref (default_resolver);
211 G_UNLOCK (default_resolver);
217 * g_resolver_set_default:
218 * @resolver: the new default #GResolver
220 * Sets @resolver to be the application's default resolver (reffing
221 * @resolver, and unreffing the previous default resolver, if any).
222 * Future calls to g_resolver_get_default() will return this resolver.
224 * This can be used if an application wants to perform any sort of DNS
225 * caching or "pinning"; it can implement its own #GResolver that
226 * calls the original default resolver for DNS operations, and
227 * implements its own cache policies on top of that, and then set
228 * itself as the default resolver for all later code to use.
233 g_resolver_set_default (GResolver *resolver)
235 G_LOCK (default_resolver);
236 if (default_resolver)
237 g_object_unref (default_resolver);
238 default_resolver = g_object_ref (resolver);
239 G_UNLOCK (default_resolver);
242 /* Bionic has res_init() but it's not in any header */
248 g_resolver_maybe_reload (GResolver *resolver)
253 if (stat (_PATH_RESCONF, &st) == 0)
255 if (st.st_mtime != resolver->priv->resolv_conf_timestamp)
257 resolver->priv->resolv_conf_timestamp = st.st_mtime;
261 g_signal_emit (resolver, signals[RELOAD], 0);
267 /* filter out duplicates, cf. https://bugzilla.gnome.org/show_bug.cgi?id=631379 */
269 remove_duplicates (GList *addrs)
275 /* TODO: if this is too slow (it's O(n^2) but n is typically really
276 * small), we can do something more clever but note that we must not
277 * change the order of elements...
279 for (l = addrs; l != NULL; l = l->next)
281 GInetAddress *address = G_INET_ADDRESS (l->data);
282 for (ll = l->next; ll != NULL; ll = lll)
284 GInetAddress *other_address = G_INET_ADDRESS (ll->data);
286 if (g_inet_address_equal (address, other_address))
288 g_object_unref (other_address);
289 /* we never return the first element */
290 g_warn_if_fail (g_list_delete_link (addrs, ll) == addrs);
296 /* Note that this does not follow the "FALSE means @error is set"
297 * convention. The return value tells the caller whether it should
298 * return @addrs and @error to the caller right away, or if it should
299 * continue and trying to resolve the name as a hostname.
302 handle_ip_address (const char *hostname,
309 struct in_addr ip4addr;
312 addr = g_inet_address_new_from_string (hostname);
315 *addrs = g_list_append (NULL, addr);
323 /* Reject IPv6 addresses that have brackets ('[' or ']') and/or port numbers,
324 * as no valid addresses should contain these at this point.
325 * Non-standard IPv4 addresses would be rejected during the call to
326 * getaddrinfo() later.
328 if (strrchr (hostname, '[') != NULL ||
329 strrchr (hostname, ']') != NULL)
332 /* Reject non-standard IPv4 numbers-and-dots addresses.
333 * g_inet_address_new_from_string() will have accepted any "real" IP
334 * address, so if inet_aton() succeeds, then it's an address we want
337 if (inet_aton (hostname, &ip4addr))
340 g_set_error (error, G_RESOLVER_ERROR, G_RESOLVER_ERROR_NOT_FOUND,
341 _("Error resolving “%s”: %s"),
342 hostname, gai_strerror (EAI_NONAME));
350 * g_resolver_lookup_by_name:
351 * @resolver: a #GResolver
352 * @hostname: the hostname to look up
353 * @cancellable: (allow-none): a #GCancellable, or %NULL
354 * @error: return location for a #GError, or %NULL
356 * Synchronously resolves @hostname to determine its associated IP
357 * address(es). @hostname may be an ASCII-only or UTF-8 hostname, or
358 * the textual form of an IP address (in which case this just becomes
359 * a wrapper around g_inet_address_new_from_string()).
361 * On success, g_resolver_lookup_by_name() will return a non-empty #GList of
362 * #GInetAddress, sorted in order of preference and guaranteed to not
363 * contain duplicates. That is, if using the result to connect to
364 * @hostname, you should attempt to connect to the first address
365 * first, then the second if the first fails, etc. If you are using
366 * the result to listen on a socket, it is appropriate to add each
367 * result using e.g. g_socket_listener_add_address().
369 * If the DNS resolution fails, @error (if non-%NULL) will be set to a
370 * value from #GResolverError and %NULL will be returned.
372 * If @cancellable is non-%NULL, it can be used to cancel the
373 * operation, in which case @error (if non-%NULL) will be set to
374 * %G_IO_ERROR_CANCELLED.
376 * If you are planning to connect to a socket on the resolved IP
377 * address, it may be easier to create a #GNetworkAddress and use its
378 * #GSocketConnectable interface.
380 * Returns: (element-type GInetAddress) (transfer full): a non-empty #GList
381 * of #GInetAddress, or %NULL on error. You
382 * must unref each of the addresses and free the list when you are
383 * done with it. (You can use g_resolver_free_addresses() to do this.)
388 g_resolver_lookup_by_name (GResolver *resolver,
389 const gchar *hostname,
390 GCancellable *cancellable,
394 gchar *ascii_hostname = NULL;
396 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
397 g_return_val_if_fail (hostname != NULL, NULL);
399 /* Check if @hostname is just an IP address */
400 if (handle_ip_address (hostname, &addrs, error))
403 if (g_hostname_is_non_ascii (hostname))
404 hostname = ascii_hostname = g_hostname_to_ascii (hostname);
406 g_resolver_maybe_reload (resolver);
407 addrs = G_RESOLVER_GET_CLASS (resolver)->
408 lookup_by_name (resolver, hostname, cancellable, error);
410 remove_duplicates (addrs);
412 g_free (ascii_hostname);
417 * g_resolver_lookup_by_name_async:
418 * @resolver: a #GResolver
419 * @hostname: the hostname to look up the address of
420 * @cancellable: (allow-none): a #GCancellable, or %NULL
421 * @callback: (scope async): callback to call after resolution completes
422 * @user_data: (closure): data for @callback
424 * Begins asynchronously resolving @hostname to determine its
425 * associated IP address(es), and eventually calls @callback, which
426 * must call g_resolver_lookup_by_name_finish() to get the result.
427 * See g_resolver_lookup_by_name() for more details.
432 g_resolver_lookup_by_name_async (GResolver *resolver,
433 const gchar *hostname,
434 GCancellable *cancellable,
435 GAsyncReadyCallback callback,
438 gchar *ascii_hostname = NULL;
440 GError *error = NULL;
442 g_return_if_fail (G_IS_RESOLVER (resolver));
443 g_return_if_fail (hostname != NULL);
445 /* Check if @hostname is just an IP address */
446 if (handle_ip_address (hostname, &addrs, &error))
450 task = g_task_new (resolver, cancellable, callback, user_data);
451 g_task_set_source_tag (task, g_resolver_lookup_by_name_async);
453 g_task_return_pointer (task, addrs, (GDestroyNotify) g_resolver_free_addresses);
455 g_task_return_error (task, error);
456 g_object_unref (task);
460 if (g_hostname_is_non_ascii (hostname))
461 hostname = ascii_hostname = g_hostname_to_ascii (hostname);
463 g_resolver_maybe_reload (resolver);
464 G_RESOLVER_GET_CLASS (resolver)->
465 lookup_by_name_async (resolver, hostname, cancellable, callback, user_data);
467 g_free (ascii_hostname);
471 * g_resolver_lookup_by_name_finish:
472 * @resolver: a #GResolver
473 * @result: the result passed to your #GAsyncReadyCallback
474 * @error: return location for a #GError, or %NULL
476 * Retrieves the result of a call to
477 * g_resolver_lookup_by_name_async().
479 * If the DNS resolution failed, @error (if non-%NULL) will be set to
480 * a value from #GResolverError. If the operation was cancelled,
481 * @error will be set to %G_IO_ERROR_CANCELLED.
483 * Returns: (element-type GInetAddress) (transfer full): a #GList
484 * of #GInetAddress, or %NULL on error. See g_resolver_lookup_by_name()
490 g_resolver_lookup_by_name_finish (GResolver *resolver,
491 GAsyncResult *result,
496 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
498 if (g_async_result_legacy_propagate_error (result, error))
500 else if (g_async_result_is_tagged (result, g_resolver_lookup_by_name_async))
502 /* Handle the stringified-IP-addr case */
503 return g_task_propagate_pointer (G_TASK (result), error);
506 addrs = G_RESOLVER_GET_CLASS (resolver)->
507 lookup_by_name_finish (resolver, result, error);
509 remove_duplicates (addrs);
515 * g_resolver_free_addresses: (skip)
516 * @addresses: a #GList of #GInetAddress
518 * Frees @addresses (which should be the return value from
519 * g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()).
520 * (This is a convenience method; you can also simply free the results
526 g_resolver_free_addresses (GList *addresses)
530 for (a = addresses; a; a = a->next)
531 g_object_unref (a->data);
532 g_list_free (addresses);
536 * g_resolver_lookup_by_address:
537 * @resolver: a #GResolver
538 * @address: the address to reverse-resolve
539 * @cancellable: (allow-none): a #GCancellable, or %NULL
540 * @error: return location for a #GError, or %NULL
542 * Synchronously reverse-resolves @address to determine its
543 * associated hostname.
545 * If the DNS resolution fails, @error (if non-%NULL) will be set to
546 * a value from #GResolverError.
548 * If @cancellable is non-%NULL, it can be used to cancel the
549 * operation, in which case @error (if non-%NULL) will be set to
550 * %G_IO_ERROR_CANCELLED.
552 * Returns: a hostname (either ASCII-only, or in ASCII-encoded
553 * form), or %NULL on error.
558 g_resolver_lookup_by_address (GResolver *resolver,
559 GInetAddress *address,
560 GCancellable *cancellable,
563 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
564 g_return_val_if_fail (G_IS_INET_ADDRESS (address), NULL);
566 g_resolver_maybe_reload (resolver);
567 return G_RESOLVER_GET_CLASS (resolver)->
568 lookup_by_address (resolver, address, cancellable, error);
572 * g_resolver_lookup_by_address_async:
573 * @resolver: a #GResolver
574 * @address: the address to reverse-resolve
575 * @cancellable: (allow-none): a #GCancellable, or %NULL
576 * @callback: (scope async): callback to call after resolution completes
577 * @user_data: (closure): data for @callback
579 * Begins asynchronously reverse-resolving @address to determine its
580 * associated hostname, and eventually calls @callback, which must
581 * call g_resolver_lookup_by_address_finish() to get the final result.
586 g_resolver_lookup_by_address_async (GResolver *resolver,
587 GInetAddress *address,
588 GCancellable *cancellable,
589 GAsyncReadyCallback callback,
592 g_return_if_fail (G_IS_RESOLVER (resolver));
593 g_return_if_fail (G_IS_INET_ADDRESS (address));
595 g_resolver_maybe_reload (resolver);
596 G_RESOLVER_GET_CLASS (resolver)->
597 lookup_by_address_async (resolver, address, cancellable, callback, user_data);
601 * g_resolver_lookup_by_address_finish:
602 * @resolver: a #GResolver
603 * @result: the result passed to your #GAsyncReadyCallback
604 * @error: return location for a #GError, or %NULL
606 * Retrieves the result of a previous call to
607 * g_resolver_lookup_by_address_async().
609 * If the DNS resolution failed, @error (if non-%NULL) will be set to
610 * a value from #GResolverError. If the operation was cancelled,
611 * @error will be set to %G_IO_ERROR_CANCELLED.
613 * Returns: a hostname (either ASCII-only, or in ASCII-encoded
614 * form), or %NULL on error.
619 g_resolver_lookup_by_address_finish (GResolver *resolver,
620 GAsyncResult *result,
623 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
625 if (g_async_result_legacy_propagate_error (result, error))
628 return G_RESOLVER_GET_CLASS (resolver)->
629 lookup_by_address_finish (resolver, result, error);
633 g_resolver_get_service_rrname (const char *service,
634 const char *protocol,
637 gchar *rrname, *ascii_domain = NULL;
639 if (g_hostname_is_non_ascii (domain))
640 domain = ascii_domain = g_hostname_to_ascii (domain);
642 rrname = g_strdup_printf ("_%s._%s.%s", service, protocol, domain);
644 g_free (ascii_domain);
649 * g_resolver_lookup_service:
650 * @resolver: a #GResolver
651 * @service: the service type to look up (eg, "ldap")
652 * @protocol: the networking protocol to use for @service (eg, "tcp")
653 * @domain: the DNS domain to look up the service in
654 * @cancellable: (allow-none): a #GCancellable, or %NULL
655 * @error: return location for a #GError, or %NULL
657 * Synchronously performs a DNS SRV lookup for the given @service and
658 * @protocol in the given @domain and returns an array of #GSrvTarget.
659 * @domain may be an ASCII-only or UTF-8 hostname. Note also that the
660 * @service and @protocol arguments do not include the leading underscore
661 * that appears in the actual DNS entry.
663 * On success, g_resolver_lookup_service() will return a non-empty #GList of
664 * #GSrvTarget, sorted in order of preference. (That is, you should
665 * attempt to connect to the first target first, then the second if
666 * the first fails, etc.)
668 * If the DNS resolution fails, @error (if non-%NULL) will be set to
669 * a value from #GResolverError and %NULL will be returned.
671 * If @cancellable is non-%NULL, it can be used to cancel the
672 * operation, in which case @error (if non-%NULL) will be set to
673 * %G_IO_ERROR_CANCELLED.
675 * If you are planning to connect to the service, it is usually easier
676 * to create a #GNetworkService and use its #GSocketConnectable
679 * Returns: (element-type GSrvTarget) (transfer full): a non-empty #GList of
680 * #GSrvTarget, or %NULL on error. You must free each of the targets and the
681 * list when you are done with it. (You can use g_resolver_free_targets() to do
687 g_resolver_lookup_service (GResolver *resolver,
688 const gchar *service,
689 const gchar *protocol,
691 GCancellable *cancellable,
697 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
698 g_return_val_if_fail (service != NULL, NULL);
699 g_return_val_if_fail (protocol != NULL, NULL);
700 g_return_val_if_fail (domain != NULL, NULL);
702 rrname = g_resolver_get_service_rrname (service, protocol, domain);
704 g_resolver_maybe_reload (resolver);
705 targets = G_RESOLVER_GET_CLASS (resolver)->
706 lookup_service (resolver, rrname, cancellable, error);
713 * g_resolver_lookup_service_async:
714 * @resolver: a #GResolver
715 * @service: the service type to look up (eg, "ldap")
716 * @protocol: the networking protocol to use for @service (eg, "tcp")
717 * @domain: the DNS domain to look up the service in
718 * @cancellable: (allow-none): a #GCancellable, or %NULL
719 * @callback: (scope async): callback to call after resolution completes
720 * @user_data: (closure): data for @callback
722 * Begins asynchronously performing a DNS SRV lookup for the given
723 * @service and @protocol in the given @domain, and eventually calls
724 * @callback, which must call g_resolver_lookup_service_finish() to
725 * get the final result. See g_resolver_lookup_service() for more
731 g_resolver_lookup_service_async (GResolver *resolver,
732 const gchar *service,
733 const gchar *protocol,
735 GCancellable *cancellable,
736 GAsyncReadyCallback callback,
741 g_return_if_fail (G_IS_RESOLVER (resolver));
742 g_return_if_fail (service != NULL);
743 g_return_if_fail (protocol != NULL);
744 g_return_if_fail (domain != NULL);
746 rrname = g_resolver_get_service_rrname (service, protocol, domain);
748 g_resolver_maybe_reload (resolver);
749 G_RESOLVER_GET_CLASS (resolver)->
750 lookup_service_async (resolver, rrname, cancellable, callback, user_data);
756 * g_resolver_lookup_service_finish:
757 * @resolver: a #GResolver
758 * @result: the result passed to your #GAsyncReadyCallback
759 * @error: return location for a #GError, or %NULL
761 * Retrieves the result of a previous call to
762 * g_resolver_lookup_service_async().
764 * If the DNS resolution failed, @error (if non-%NULL) will be set to
765 * a value from #GResolverError. If the operation was cancelled,
766 * @error will be set to %G_IO_ERROR_CANCELLED.
768 * Returns: (element-type GSrvTarget) (transfer full): a non-empty #GList of
769 * #GSrvTarget, or %NULL on error. See g_resolver_lookup_service() for more
775 g_resolver_lookup_service_finish (GResolver *resolver,
776 GAsyncResult *result,
779 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
781 if (g_async_result_legacy_propagate_error (result, error))
784 return G_RESOLVER_GET_CLASS (resolver)->
785 lookup_service_finish (resolver, result, error);
789 * g_resolver_free_targets: (skip)
790 * @targets: a #GList of #GSrvTarget
792 * Frees @targets (which should be the return value from
793 * g_resolver_lookup_service() or g_resolver_lookup_service_finish()).
794 * (This is a convenience method; you can also simply free the
800 g_resolver_free_targets (GList *targets)
804 for (t = targets; t; t = t->next)
805 g_srv_target_free (t->data);
806 g_list_free (targets);
810 * g_resolver_lookup_records:
811 * @resolver: a #GResolver
812 * @rrname: the DNS name to lookup the record for
813 * @record_type: the type of DNS record to lookup
814 * @cancellable: (allow-none): a #GCancellable, or %NULL
815 * @error: return location for a #GError, or %NULL
817 * Synchronously performs a DNS record lookup for the given @rrname and returns
818 * a list of records as #GVariant tuples. See #GResolverRecordType for
819 * information on what the records contain for each @record_type.
821 * If the DNS resolution fails, @error (if non-%NULL) will be set to
822 * a value from #GResolverError and %NULL will be returned.
824 * If @cancellable is non-%NULL, it can be used to cancel the
825 * operation, in which case @error (if non-%NULL) will be set to
826 * %G_IO_ERROR_CANCELLED.
828 * Returns: (element-type GVariant) (transfer full): a non-empty #GList of
829 * #GVariant, or %NULL on error. You must free each of the records and the list
830 * when you are done with it. (You can use g_list_free_full() with
831 * g_variant_unref() to do this.)
836 g_resolver_lookup_records (GResolver *resolver,
838 GResolverRecordType record_type,
839 GCancellable *cancellable,
844 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
845 g_return_val_if_fail (rrname != NULL, NULL);
847 g_resolver_maybe_reload (resolver);
848 records = G_RESOLVER_GET_CLASS (resolver)->
849 lookup_records (resolver, rrname, record_type, cancellable, error);
855 * g_resolver_lookup_records_async:
856 * @resolver: a #GResolver
857 * @rrname: the DNS name to lookup the record for
858 * @record_type: the type of DNS record to lookup
859 * @cancellable: (allow-none): a #GCancellable, or %NULL
860 * @callback: (scope async): callback to call after resolution completes
861 * @user_data: (closure): data for @callback
863 * Begins asynchronously performing a DNS lookup for the given
864 * @rrname, and eventually calls @callback, which must call
865 * g_resolver_lookup_records_finish() to get the final result. See
866 * g_resolver_lookup_records() for more details.
871 g_resolver_lookup_records_async (GResolver *resolver,
873 GResolverRecordType record_type,
874 GCancellable *cancellable,
875 GAsyncReadyCallback callback,
878 g_return_if_fail (G_IS_RESOLVER (resolver));
879 g_return_if_fail (rrname != NULL);
881 g_resolver_maybe_reload (resolver);
882 G_RESOLVER_GET_CLASS (resolver)->
883 lookup_records_async (resolver, rrname, record_type, cancellable, callback, user_data);
887 * g_resolver_lookup_records_finish:
888 * @resolver: a #GResolver
889 * @result: the result passed to your #GAsyncReadyCallback
890 * @error: return location for a #GError, or %NULL
892 * Retrieves the result of a previous call to
893 * g_resolver_lookup_records_async(). Returns a non-empty list of records as
894 * #GVariant tuples. See #GResolverRecordType for information on what the
897 * If the DNS resolution failed, @error (if non-%NULL) will be set to
898 * a value from #GResolverError. If the operation was cancelled,
899 * @error will be set to %G_IO_ERROR_CANCELLED.
901 * Returns: (element-type GVariant) (transfer full): a non-empty #GList of
902 * #GVariant, or %NULL on error. You must free each of the records and the list
903 * when you are done with it. (You can use g_list_free_full() with
904 * g_variant_unref() to do this.)
909 g_resolver_lookup_records_finish (GResolver *resolver,
910 GAsyncResult *result,
913 g_return_val_if_fail (G_IS_RESOLVER (resolver), NULL);
914 return G_RESOLVER_GET_CLASS (resolver)->
915 lookup_records_finish (resolver, result, error);
919 g_resolver_get_serial (GResolver *resolver)
921 g_return_val_if_fail (G_IS_RESOLVER (resolver), 0);
923 g_resolver_maybe_reload (resolver);
926 return (guint64) resolver->priv->resolv_conf_timestamp;
933 * g_resolver_error_quark:
935 * Gets the #GResolver Error Quark.
937 * Returns: a #GQuark.
941 G_DEFINE_QUARK (g-resolver-error-quark, g_resolver_error)