Coverage Report

Created: 2025-07-01 07:09

/src/glib/gio/gproxyaddressenumerator.c
Line
Count
Source (jump to first uncovered line)
1
/* GIO - GLib Input, Output and Streaming Library
2
 *
3
 * Copyright (C) 2010 Collabora, Ltd.
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2.1 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General
16
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
19
 */
20
21
#include "config.h"
22
#include "gproxyaddressenumerator.h"
23
24
#include <string.h>
25
26
#include "gasyncresult.h"
27
#include "ginetaddress.h"
28
#include "glibintl.h"
29
#include "gnetworkaddress.h"
30
#include "gnetworkingprivate.h"
31
#include "gproxy.h"
32
#include "gproxyaddress.h"
33
#include "gproxyresolver.h"
34
#include "gtask.h"
35
#include "gresolver.h"
36
#include "gsocketaddress.h"
37
#include "gsocketaddressenumerator.h"
38
#include "gsocketconnectable.h"
39
40
/**
41
 * SECTION:gproxyaddressenumerator
42
 * @short_description: Proxy wrapper enumerator for socket addresses
43
 * @include: gio/gio.h
44
 *
45
 * #GProxyAddressEnumerator is a wrapper around #GSocketAddressEnumerator which
46
 * takes the #GSocketAddress instances returned by the #GSocketAddressEnumerator
47
 * and wraps them in #GProxyAddress instances, using the given
48
 * #GProxyAddressEnumerator:proxy-resolver.
49
 *
50
 * This enumerator will be returned (for example, by
51
 * g_socket_connectable_enumerate()) as appropriate when a proxy is configured;
52
 * there should be no need to manually wrap a #GSocketAddressEnumerator instance
53
 * with one.
54
 */
55
56
0
#define GET_PRIVATE(o) (G_PROXY_ADDRESS_ENUMERATOR (o)->priv)
57
58
enum
59
{
60
  PROP_0,
61
  PROP_URI,
62
  PROP_DEFAULT_PORT,
63
  PROP_CONNECTABLE,
64
  PROP_PROXY_RESOLVER
65
};
66
67
struct _GProxyAddressEnumeratorPrivate
68
{
69
  /* Destination address */
70
  GSocketConnectable *connectable;
71
  gchar              *dest_uri;
72
  guint16             default_port;
73
  gchar              *dest_hostname;
74
  guint16             dest_port;
75
  GList              *dest_ips;
76
77
  /* Proxy enumeration */
78
  GProxyResolver           *proxy_resolver;
79
  gchar                   **proxies;
80
  gchar                   **next_proxy;
81
  GSocketAddressEnumerator *addr_enum;
82
  GSocketAddress           *proxy_address;
83
  const gchar              *proxy_uri;
84
  gchar                    *proxy_type;
85
  gchar                    *proxy_username;
86
  gchar                    *proxy_password;
87
  gboolean                  supports_hostname;
88
  GList                    *next_dest_ip;
89
  GError                   *last_error;
90
};
91
92
G_DEFINE_TYPE_WITH_PRIVATE (GProxyAddressEnumerator, g_proxy_address_enumerator, G_TYPE_SOCKET_ADDRESS_ENUMERATOR)
93
94
static void
95
save_userinfo (GProxyAddressEnumeratorPrivate *priv,
96
               const gchar *proxy)
97
0
{
98
0
  g_clear_pointer (&priv->proxy_username, g_free);
99
0
  g_clear_pointer (&priv->proxy_password, g_free);
100
101
0
  g_uri_split_with_user (proxy, G_URI_FLAGS_HAS_PASSWORD, NULL,
102
0
                         &priv->proxy_username, &priv->proxy_password,
103
0
                         NULL, NULL, NULL, NULL, NULL, NULL, NULL);
104
0
}
105
106
static void
107
next_enumerator (GProxyAddressEnumeratorPrivate *priv)
108
0
{
109
0
  if (priv->proxy_address)
110
0
    return;
111
112
0
  while (priv->addr_enum == NULL && *priv->next_proxy)
113
0
    {
114
0
      GSocketConnectable *connectable = NULL;
115
0
      GProxy *proxy;
116
117
0
      priv->proxy_uri = *priv->next_proxy++;
118
0
      g_free (priv->proxy_type);
119
0
      priv->proxy_type = g_uri_parse_scheme (priv->proxy_uri);
120
121
0
      if (priv->proxy_type == NULL)
122
0
  continue;
123
124
      /* Assumes hostnames are supported for unknown protocols */
125
0
      priv->supports_hostname = TRUE;
126
0
      proxy = g_proxy_get_default_for_protocol (priv->proxy_type);
127
0
      if (proxy)
128
0
        {
129
0
    priv->supports_hostname = g_proxy_supports_hostname (proxy);
130
0
    g_object_unref (proxy);
131
0
        }
132
133
0
      if (strcmp ("direct", priv->proxy_type) == 0)
134
0
  {
135
0
    if (priv->connectable)
136
0
      connectable = g_object_ref (priv->connectable);
137
0
    else
138
0
      connectable = g_network_address_new (priv->dest_hostname,
139
0
             priv->dest_port);
140
0
  }
141
0
      else
142
0
  {
143
0
    GError *error = NULL;
144
145
0
    connectable = g_network_address_parse_uri (priv->proxy_uri, 0, &error);
146
147
0
    if (error)
148
0
      {
149
0
        g_warning ("Invalid proxy URI '%s': %s",
150
0
       priv->proxy_uri, error->message);
151
0
        g_error_free (error);
152
0
      }
153
154
0
    save_userinfo (priv, priv->proxy_uri);
155
0
  }
156
157
0
      if (connectable)
158
0
  {
159
0
    priv->addr_enum = g_socket_connectable_enumerate (connectable);
160
0
    g_object_unref (connectable);
161
0
  }
162
0
    }
163
0
}
164
165
static GSocketAddress *
166
g_proxy_address_enumerator_next (GSocketAddressEnumerator  *enumerator,
167
         GCancellable              *cancellable,
168
         GError                   **error)
169
0
{
170
0
  GProxyAddressEnumeratorPrivate *priv = GET_PRIVATE (enumerator);
171
0
  GSocketAddress *result = NULL;
172
0
  GError *first_error = NULL;
173
174
0
  if (priv->proxies == NULL)
175
0
    {
176
0
      priv->proxies = g_proxy_resolver_lookup (priv->proxy_resolver,
177
0
                 priv->dest_uri,
178
0
                 cancellable,
179
0
                 error);
180
0
      priv->next_proxy = priv->proxies;
181
182
0
      if (priv->proxies == NULL)
183
0
  return NULL;
184
0
    }
185
186
0
  while (result == NULL && (*priv->next_proxy || priv->addr_enum))
187
0
    {
188
0
      gchar *dest_hostname;
189
0
      gchar *dest_protocol;
190
0
      GInetSocketAddress *inetsaddr;
191
0
      GInetAddress *inetaddr;
192
0
      guint16 port;
193
194
0
      next_enumerator (priv);
195
196
0
      if (!priv->addr_enum)
197
0
  continue;
198
199
0
      if (priv->proxy_address == NULL)
200
0
  {
201
0
    priv->proxy_address = g_socket_address_enumerator_next (
202
0
            priv->addr_enum,
203
0
            cancellable,
204
0
            first_error ? NULL : &first_error);
205
0
  }
206
207
0
      if (priv->proxy_address == NULL)
208
0
  {
209
0
    g_object_unref (priv->addr_enum);
210
0
    priv->addr_enum = NULL;
211
212
0
    if (priv->dest_ips)
213
0
      {
214
0
        g_resolver_free_addresses (priv->dest_ips);
215
0
        priv->dest_ips = NULL;
216
0
      }
217
218
0
    continue;
219
0
  }
220
221
0
      if (strcmp ("direct", priv->proxy_type) == 0)
222
0
  {
223
0
    result = priv->proxy_address;
224
0
    priv->proxy_address = NULL;
225
0
    continue;
226
0
  }
227
228
0
      if (!priv->supports_hostname)
229
0
  {
230
0
    GInetAddress *dest_ip;
231
232
0
    if (!priv->dest_ips)
233
0
      {
234
0
        GResolver *resolver;
235
236
0
        resolver = g_resolver_get_default();
237
0
        priv->dest_ips = g_resolver_lookup_by_name (resolver,
238
0
                priv->dest_hostname,
239
0
                cancellable,
240
0
                first_error ? NULL : &first_error);
241
0
        g_object_unref (resolver);
242
243
0
        if (!priv->dest_ips)
244
0
    {
245
0
      g_object_unref (priv->proxy_address);
246
0
      priv->proxy_address = NULL;
247
0
      continue;
248
0
    }
249
0
      }
250
251
0
    if (!priv->next_dest_ip)
252
0
      priv->next_dest_ip = priv->dest_ips;
253
  
254
0
    dest_ip = G_INET_ADDRESS (priv->next_dest_ip->data);
255
0
    dest_hostname = g_inet_address_to_string (dest_ip);
256
257
0
    priv->next_dest_ip = g_list_next (priv->next_dest_ip);
258
0
  }
259
0
      else
260
0
  {
261
0
    dest_hostname = g_strdup (priv->dest_hostname);
262
0
  }
263
0
      dest_protocol = g_uri_parse_scheme (priv->dest_uri);
264
          
265
0
      g_return_val_if_fail (G_IS_INET_SOCKET_ADDRESS (priv->proxy_address),
266
0
          NULL);
267
268
0
      inetsaddr = G_INET_SOCKET_ADDRESS (priv->proxy_address);
269
0
      inetaddr = g_inet_socket_address_get_address (inetsaddr);
270
0
      port = g_inet_socket_address_get_port (inetsaddr);
271
272
0
      result = g_object_new (G_TYPE_PROXY_ADDRESS,
273
0
           "address", inetaddr,
274
0
           "port", port,
275
0
           "protocol", priv->proxy_type,
276
0
           "destination-protocol", dest_protocol,
277
0
           "destination-hostname", dest_hostname,
278
0
           "destination-port", priv->dest_port,
279
0
           "username", priv->proxy_username,
280
0
           "password", priv->proxy_password,
281
0
           "uri", priv->proxy_uri,
282
0
           NULL);
283
0
      g_free (dest_hostname);
284
0
      g_free (dest_protocol);
285
286
0
      if (priv->supports_hostname || priv->next_dest_ip == NULL)
287
0
  {
288
0
    g_object_unref (priv->proxy_address);
289
0
    priv->proxy_address = NULL;
290
0
  }
291
0
    }
292
293
0
  if (result == NULL && first_error)
294
0
    g_propagate_error (error, first_error);
295
0
  else if (first_error)
296
0
    g_error_free (first_error);
297
298
0
  return result;
299
0
}
300
301
302
303
static void
304
complete_async (GTask *task)
305
0
{
306
0
  GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
307
308
0
  if (priv->last_error)
309
0
    {
310
0
      g_task_return_error (task, priv->last_error);
311
0
      priv->last_error = NULL;
312
0
    }
313
0
  else
314
0
    g_task_return_pointer (task, NULL, NULL);
315
316
0
  g_object_unref (task);
317
0
}
318
319
static void
320
return_result (GTask *task)
321
0
{
322
0
  GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
323
0
  GSocketAddress *result;
324
325
0
  if (strcmp ("direct", priv->proxy_type) == 0)
326
0
    {
327
0
      result = priv->proxy_address;
328
0
      priv->proxy_address = NULL;
329
0
    }
330
0
  else
331
0
    {
332
0
      gchar *dest_hostname, *dest_protocol;
333
0
      GInetSocketAddress *inetsaddr;
334
0
      GInetAddress *inetaddr;
335
0
      guint16 port;
336
337
0
      if (!priv->supports_hostname)
338
0
  {
339
0
    GInetAddress *dest_ip;
340
341
0
    if (!priv->next_dest_ip)
342
0
      priv->next_dest_ip = priv->dest_ips;
343
344
0
    dest_ip = G_INET_ADDRESS (priv->next_dest_ip->data);
345
0
    dest_hostname = g_inet_address_to_string (dest_ip);
346
347
0
    priv->next_dest_ip = g_list_next (priv->next_dest_ip);
348
0
  }
349
0
      else
350
0
  {
351
0
    dest_hostname = g_strdup (priv->dest_hostname);
352
0
  }
353
0
      dest_protocol = g_uri_parse_scheme (priv->dest_uri);
354
355
0
      g_return_if_fail (G_IS_INET_SOCKET_ADDRESS (priv->proxy_address));
356
357
0
      inetsaddr = G_INET_SOCKET_ADDRESS (priv->proxy_address);
358
0
      inetaddr = g_inet_socket_address_get_address (inetsaddr);
359
0
      port = g_inet_socket_address_get_port (inetsaddr);
360
361
0
      result = g_object_new (G_TYPE_PROXY_ADDRESS,
362
0
           "address", inetaddr,
363
0
           "port", port,
364
0
           "protocol", priv->proxy_type,
365
0
           "destination-protocol", dest_protocol,
366
0
           "destination-hostname", dest_hostname,
367
0
           "destination-port", priv->dest_port,
368
0
           "username", priv->proxy_username,
369
0
           "password", priv->proxy_password,
370
0
           "uri", priv->proxy_uri,
371
0
           NULL);
372
0
      g_free (dest_hostname);
373
0
      g_free (dest_protocol);
374
375
0
      if (priv->supports_hostname || priv->next_dest_ip == NULL)
376
0
  {
377
0
    g_object_unref (priv->proxy_address);
378
0
    priv->proxy_address = NULL;
379
0
  }
380
0
    }
381
382
0
  g_task_return_pointer (task, result, g_object_unref);
383
0
  g_object_unref (task);
384
0
}
385
386
static void address_enumerate_cb (GObject      *object,
387
          GAsyncResult *result,
388
          gpointer  user_data);
389
390
static void
391
next_proxy (GTask *task)
392
0
{
393
0
  GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
394
395
0
  if (*priv->next_proxy)
396
0
    {
397
0
      g_object_unref (priv->addr_enum);
398
0
      priv->addr_enum = NULL;
399
400
0
      if (priv->dest_ips)
401
0
  {
402
0
    g_resolver_free_addresses (priv->dest_ips);
403
0
    priv->dest_ips = NULL;
404
0
  }
405
406
0
      next_enumerator (priv);
407
408
0
      if (priv->addr_enum)
409
0
  {
410
0
    g_socket_address_enumerator_next_async (priv->addr_enum,
411
0
              g_task_get_cancellable (task),
412
0
              address_enumerate_cb,
413
0
              task);
414
0
    return;
415
0
  }
416
0
    }
417
418
0
  complete_async (task);
419
0
}
420
421
static void
422
dest_hostname_lookup_cb (GObject           *object,
423
       GAsyncResult      *result,
424
       gpointer           user_data)
425
0
{
426
0
  GTask *task = user_data;
427
0
  GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
428
429
0
  g_clear_error (&priv->last_error);
430
0
  priv->dest_ips = g_resolver_lookup_by_name_finish (G_RESOLVER (object),
431
0
                 result,
432
0
                 &priv->last_error);
433
0
  if (priv->dest_ips)
434
0
    return_result (task);
435
0
  else
436
0
    {
437
0
      g_clear_object (&priv->proxy_address);
438
0
      next_proxy (task);
439
0
    }
440
0
}
441
442
static void
443
address_enumerate_cb (GObject    *object,
444
          GAsyncResult *result,
445
          gpointer      user_data)
446
0
{
447
0
  GTask *task = user_data;
448
0
  GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
449
450
0
  g_clear_error (&priv->last_error);
451
0
  priv->proxy_address =
452
0
    g_socket_address_enumerator_next_finish (priv->addr_enum,
453
0
               result,
454
0
               &priv->last_error);
455
0
  if (priv->proxy_address)
456
0
    {
457
0
      if (!priv->supports_hostname && !priv->dest_ips)
458
0
  {
459
0
    GResolver *resolver;
460
0
    resolver = g_resolver_get_default();
461
0
    g_resolver_lookup_by_name_async (resolver,
462
0
             priv->dest_hostname,
463
0
             g_task_get_cancellable (task),
464
0
             dest_hostname_lookup_cb,
465
0
             task);
466
0
    g_object_unref (resolver);
467
0
    return;
468
0
  }
469
470
0
      return_result (task);
471
0
    }
472
0
  else
473
0
    next_proxy (task);
474
0
}
475
476
static void
477
proxy_lookup_cb (GObject      *object,
478
     GAsyncResult *result,
479
     gpointer      user_data)
480
0
{
481
0
  GTask *task = user_data;
482
0
  GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
483
484
0
  g_clear_error (&priv->last_error);
485
0
  priv->proxies = g_proxy_resolver_lookup_finish (G_PROXY_RESOLVER (object),
486
0
              result,
487
0
              &priv->last_error);
488
0
  priv->next_proxy = priv->proxies;
489
490
0
  if (priv->last_error)
491
0
    {
492
0
      complete_async (task);
493
0
      return;
494
0
    }
495
0
  else
496
0
    {
497
0
      next_enumerator (priv);
498
0
      if (priv->addr_enum)
499
0
  {
500
0
    g_socket_address_enumerator_next_async (priv->addr_enum,
501
0
              g_task_get_cancellable (task),
502
0
              address_enumerate_cb,
503
0
              task);
504
0
    return;
505
0
  }
506
0
    }
507
508
0
  complete_async (task);
509
0
}
510
511
static void
512
g_proxy_address_enumerator_next_async (GSocketAddressEnumerator *enumerator,
513
               GCancellable             *cancellable,
514
               GAsyncReadyCallback       callback,
515
               gpointer                  user_data)
516
0
{
517
0
  GProxyAddressEnumeratorPrivate *priv = GET_PRIVATE (enumerator);
518
0
  GTask *task;
519
520
0
  task = g_task_new (enumerator, cancellable, callback, user_data);
521
0
  g_task_set_source_tag (task, g_proxy_address_enumerator_next_async);
522
0
  g_task_set_task_data (task, priv, NULL);
523
524
0
  if (priv->proxies == NULL)
525
0
    {
526
0
      g_proxy_resolver_lookup_async (priv->proxy_resolver,
527
0
             priv->dest_uri,
528
0
             cancellable,
529
0
             proxy_lookup_cb,
530
0
             task);
531
0
      return;
532
0
    }
533
534
0
  if (priv->addr_enum)
535
0
    {
536
0
      if (priv->proxy_address)
537
0
  {
538
0
    return_result (task);
539
0
    return;
540
0
  }
541
0
      else
542
0
  {
543
0
    g_socket_address_enumerator_next_async (priv->addr_enum,
544
0
              cancellable,
545
0
              address_enumerate_cb,
546
0
              task);
547
0
    return;
548
0
  }
549
0
    }
550
551
0
  complete_async (task);
552
0
}
553
554
static GSocketAddress *
555
g_proxy_address_enumerator_next_finish (GSocketAddressEnumerator  *enumerator,
556
          GAsyncResult              *result,
557
          GError                   **error)
558
0
{
559
0
  g_return_val_if_fail (g_task_is_valid (result, enumerator), NULL);
560
561
0
  return g_task_propagate_pointer (G_TASK (result), error);
562
0
}
563
564
static void
565
g_proxy_address_enumerator_constructed (GObject *object)
566
0
{
567
0
  GProxyAddressEnumeratorPrivate *priv = GET_PRIVATE (object);
568
0
  GSocketConnectable *conn;
569
0
  guint port;
570
571
0
  if (priv->dest_uri)
572
0
    {
573
0
      conn = g_network_address_parse_uri (priv->dest_uri, priv->default_port, NULL);
574
0
      if (conn)
575
0
        {
576
0
          g_object_get (conn,
577
0
                        "hostname", &priv->dest_hostname,
578
0
                        "port", &port,
579
0
                        NULL);
580
0
          priv->dest_port = port;
581
582
0
          g_object_unref (conn);
583
0
        }
584
0
      else
585
0
        g_warning ("Invalid URI '%s'", priv->dest_uri);
586
0
    }
587
588
0
  G_OBJECT_CLASS (g_proxy_address_enumerator_parent_class)->constructed (object);
589
0
}
590
591
static void
592
g_proxy_address_enumerator_get_property (GObject        *object,
593
                                         guint           property_id,
594
                                         GValue         *value,
595
                                         GParamSpec     *pspec)
596
0
{
597
0
  GProxyAddressEnumeratorPrivate *priv = GET_PRIVATE (object);
598
0
  switch (property_id)
599
0
    {
600
0
    case PROP_URI:
601
0
      g_value_set_string (value, priv->dest_uri);
602
0
      break;
603
604
0
    case PROP_DEFAULT_PORT:
605
0
      g_value_set_uint (value, priv->default_port);
606
0
      break;
607
608
0
    case PROP_CONNECTABLE:
609
0
      g_value_set_object (value, priv->connectable);
610
0
      break;
611
612
0
    case PROP_PROXY_RESOLVER:
613
0
      g_value_set_object (value, priv->proxy_resolver);
614
0
      break;
615
616
0
    default:
617
0
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
618
0
    }
619
0
}
620
621
static void
622
g_proxy_address_enumerator_set_property (GObject        *object,
623
                                         guint           property_id,
624
                                         const GValue   *value,
625
                                         GParamSpec     *pspec)
626
0
{
627
0
  GProxyAddressEnumeratorPrivate *priv = GET_PRIVATE (object);
628
0
  switch (property_id)
629
0
    {
630
0
    case PROP_URI:
631
0
      priv->dest_uri = g_value_dup_string (value);
632
0
      break;
633
634
0
    case PROP_DEFAULT_PORT:
635
0
      priv->default_port = g_value_get_uint (value);
636
0
      break;
637
638
0
    case PROP_CONNECTABLE:
639
0
      priv->connectable = g_value_dup_object (value);
640
0
      break;
641
642
0
    case PROP_PROXY_RESOLVER:
643
0
      if (priv->proxy_resolver)
644
0
        g_object_unref (priv->proxy_resolver);
645
0
      priv->proxy_resolver = g_value_get_object (value);
646
0
      if (!priv->proxy_resolver)
647
0
        priv->proxy_resolver = g_proxy_resolver_get_default ();
648
0
      g_object_ref (priv->proxy_resolver);
649
0
      break;
650
651
0
    default:
652
0
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
653
0
    }
654
0
}
655
656
static void
657
g_proxy_address_enumerator_finalize (GObject *object)
658
0
{
659
0
  GProxyAddressEnumeratorPrivate *priv = GET_PRIVATE (object);
660
661
0
  if (priv->connectable)
662
0
    g_object_unref (priv->connectable);
663
664
0
  if (priv->proxy_resolver)
665
0
    g_object_unref (priv->proxy_resolver);
666
667
0
  g_free (priv->dest_uri);
668
0
  g_free (priv->dest_hostname);
669
670
0
  if (priv->dest_ips)
671
0
    g_resolver_free_addresses (priv->dest_ips);
672
673
0
  g_strfreev (priv->proxies);
674
675
0
  if (priv->addr_enum)
676
0
    g_object_unref (priv->addr_enum);
677
678
0
  g_free (priv->proxy_type);
679
0
  g_free (priv->proxy_username);
680
0
  g_free (priv->proxy_password);
681
682
0
  g_clear_error (&priv->last_error);
683
684
0
  G_OBJECT_CLASS (g_proxy_address_enumerator_parent_class)->finalize (object);
685
0
}
686
687
static void
688
g_proxy_address_enumerator_init (GProxyAddressEnumerator *self)
689
0
{
690
0
  self->priv = g_proxy_address_enumerator_get_instance_private (self);
691
0
}
692
693
static void
694
g_proxy_address_enumerator_class_init (GProxyAddressEnumeratorClass *proxy_enumerator_class)
695
0
{
696
0
  GObjectClass *object_class = G_OBJECT_CLASS (proxy_enumerator_class);
697
0
  GSocketAddressEnumeratorClass *enumerator_class = G_SOCKET_ADDRESS_ENUMERATOR_CLASS (proxy_enumerator_class);
698
699
0
  object_class->constructed = g_proxy_address_enumerator_constructed;
700
0
  object_class->set_property = g_proxy_address_enumerator_set_property;
701
0
  object_class->get_property = g_proxy_address_enumerator_get_property;
702
0
  object_class->finalize = g_proxy_address_enumerator_finalize;
703
704
0
  enumerator_class->next = g_proxy_address_enumerator_next;
705
0
  enumerator_class->next_async = g_proxy_address_enumerator_next_async;
706
0
  enumerator_class->next_finish = g_proxy_address_enumerator_next_finish;
707
708
0
  g_object_class_install_property (object_class,
709
0
           PROP_URI,
710
0
           g_param_spec_string ("uri",
711
0
              P_("URI"),
712
0
              P_("The destination URI, use none:// for generic socket"),
713
0
              NULL,
714
0
              G_PARAM_READWRITE |
715
0
              G_PARAM_CONSTRUCT_ONLY |
716
0
              G_PARAM_STATIC_STRINGS));
717
718
  /**
719
   * GProxyAddressEnumerator:default-port:
720
   *
721
   * The default port to use if #GProxyAddressEnumerator:uri does not
722
   * specify one.
723
   *
724
   * Since: 2.38
725
   */
726
0
  g_object_class_install_property (object_class,
727
0
           PROP_DEFAULT_PORT,
728
0
           g_param_spec_uint ("default-port",
729
0
                                                      P_("Default port"),
730
0
                                                      P_("The default port to use if uri does not specify one"),
731
0
                                                      0, 65535, 0,
732
0
                                                      G_PARAM_READWRITE |
733
0
                                                      G_PARAM_CONSTRUCT_ONLY |
734
0
                                                      G_PARAM_STATIC_STRINGS));
735
736
0
  g_object_class_install_property (object_class,
737
0
           PROP_CONNECTABLE,
738
0
           g_param_spec_object ("connectable",
739
0
              P_("Connectable"),
740
0
              P_("The connectable being enumerated."),
741
0
              G_TYPE_SOCKET_CONNECTABLE,
742
0
              G_PARAM_READWRITE |
743
0
              G_PARAM_CONSTRUCT_ONLY |
744
0
              G_PARAM_STATIC_STRINGS));
745
746
  /**
747
   * GProxyAddressEnumerator:proxy-resolver:
748
   *
749
   * The proxy resolver to use.
750
   *
751
   * Since: 2.36
752
   */
753
0
  g_object_class_install_property (object_class,
754
0
                                   PROP_PROXY_RESOLVER,
755
0
                                   g_param_spec_object ("proxy-resolver",
756
0
                                                        P_("Proxy resolver"),
757
0
                                                        P_("The proxy resolver to use."),
758
0
                                                        G_TYPE_PROXY_RESOLVER,
759
0
                                                        G_PARAM_READWRITE |
760
0
                                                        G_PARAM_CONSTRUCT |
761
0
                                                        G_PARAM_STATIC_STRINGS));
762
0
}