UhmResolver: libuhttpmock Reference Manual

## UhmResolver UhmResolver — mock DNS resolver |

## Stability Level

Unstable, unless otherwise indicated

## Functions

UhmResolver * | uhm_resolver_new ()
void | uhm_resolver_reset ()
gboolean | uhm_resolver_add_A ()
gboolean | uhm_resolver_add_SRV ()

## Types and Values

| UhmResolver
| UhmResolverClass

## Object Hierarchy

        GObject
        ╰── GResolver
            ╰── UhmResolver

## Includes

    #include <libuhttpmock/uhm-resolver.h>

## Description

A mock DNS resolver which resolves according to specified host-name–IP-address pairs, and raises an error for all non-specified host name requests. This allows network connections for expected services to be redirected to a different server, such as a local mock server on a loopback interface.

## Functions

### uhm_resolver_new ()

    UhmResolver *
    uhm_resolver_new (void);

Creates a new UhmResolver with default property values.

#### Returns

a new UhmResolver; unref with `g_object_unref()`.

[transfer full]

### uhm_resolver_reset ()

    void
    uhm_resolver_reset (UhmResolver *self);

Resets the state of the UhmResolver, deleting all records added with `uhm_resolver_add_A()` and `uhm_resolver_add_SRV()`.

#### Parameters

self | a UhmResolver |

### uhm_resolver_add_A ()

    gboolean
    uhm_resolver_add_A (UhmResolver *self,
                        const gchar *hostname,
                        const gchar *addr);

Adds a resolution mapping from the host name `hostname` to the IP address `addr` .

#### Parameters

self | a UhmResolver |
hostname | the hostname to match |
addr | the IP address to resolve to |

#### Returns

`TRUE` on success; `FALSE` otherwise

Since: 0.1.0

### uhm_resolver_add_SRV ()

    gboolean
    uhm_resolver_add_SRV (UhmResolver *self,
                          const gchar *service,
                          const gchar *protocol,
                          const gchar *domain,
                          const gchar *addr,
                          guint16 port);

Adds a resolution mapping the given `service` (on `protocol` and `domain` ) to the IP address `addr` and given `port` .

#### Parameters

self | a UhmResolver |
service | the service name to match |
protocol | the protocol name to match |
domain | the domain name to match |
addr | the IP address to resolve to |
port | the port to resolve to |

#### Returns

`TRUE` on success; `FALSE` otherwise

Since: 0.1.0

## Types and Values

### UhmResolver

    typedef struct _UhmResolver UhmResolver;

All the fields in the UhmResolver structure are private and should never be accessed directly.

Since: 0.1.0

### UhmResolverClass

    typedef struct {
    } UhmResolverClass;

All the fields in the UhmResolverClass structure are private and should never be accessed directly.

Since: 0.1.0