diff options
Diffstat (limited to 'src/libs6dns')
-rw-r--r-- | src/libs6dns/deps-lib/s6dns | 2 | ||||
-rw-r--r-- | src/libs6dns/s6dns_engine.c | 6 | ||||
-rw-r--r-- | src/libs6dns/s6dns_finish.c | 9 | ||||
-rw-r--r-- | src/libs6dns/s6dns_init.c | 11 |
4 files changed, 25 insertions, 3 deletions
diff --git a/src/libs6dns/deps-lib/s6dns b/src/libs6dns/deps-lib/s6dns index 1140b6e..b0ae95d 100644 --- a/src/libs6dns/deps-lib/s6dns +++ b/src/libs6dns/deps-lib/s6dns @@ -86,4 +86,6 @@ s6dns_debug_dumpdt_stderr.o s6dns_debug_dumpdt_post_recv.o s6dns_debug_dumpdt_pre_send.o s6dns_debug_dumpdt_post_send.o +s6dns_init.o +s6dns_finish.o -lskarnet diff --git a/src/libs6dns/s6dns_engine.c b/src/libs6dns/s6dns_engine.c index 6cf7797..f903ea9 100644 --- a/src/libs6dns/s6dns_engine.c +++ b/src/libs6dns/s6dns_engine.c @@ -71,7 +71,7 @@ static int randombind (int fd, int flag) { register unsigned int i = 0 ; for (; i < 10 ; i++) - if (socketbind46(fd, S6DNS_ENGINE_LOCAL0, 1025 + badrandom_int(64510), flag) >= 0) return 1 ; + if (socketbind46(fd, S6DNS_ENGINE_LOCAL0, 1025 + random_uint32(64510), flag) >= 0) return 1 ; return (socketbind46(fd, S6DNS_ENGINE_LOCAL0, 0, flag) >= 0) ; } @@ -86,7 +86,7 @@ static int thisudp (s6dns_engine_t *dt, tain_t const *stamp) } if (byte_diff(s6dns_ip46list_ip(&dt->servers, dt->curserver), SKALIBS_IP_SIZE, S6DNS_ENGINE_LOCAL0)) break ; } - if (badrandom_string(dt->sa.s + 2, 2) < 2) return -1 ; /* random query id */ + random_string(dt->sa.s + 2, 2) ; /* random query id */ dt->fd = socketudp46(s6dns_ip46list_is6(&dt->servers, dt->curserver)) ; if (dt->fd < 0) return -1 ; if (!randombind(dt->fd, s6dns_ip46list_is6(&dt->servers, dt->curserver))) @@ -117,7 +117,7 @@ static int thistcp (s6dns_engine_t *dt, tain_t const *stamp) for (; dt->curserver < S6DNS_MAX_SERVERS ; dt->curserver++) if (byte_diff(s6dns_ip46list_ip(&dt->servers, dt->curserver), SKALIBS_IP_SIZE, S6DNS_ENGINE_LOCAL0)) break ; if (dt->curserver >= S6DNS_MAX_SERVERS) return -2 ; - if (badrandom_string(dt->sa.s + 2, 2) < 2) return -1 ; + random_string(dt->sa.s + 2, 2) ; dt->fd = sockettcp46(s6dns_ip46list_is6(&dt->servers, dt->curserver)) ; if (dt->fd < 0) return -1 ; if (!randombind(dt->fd, s6dns_ip46list_is6(&dt->servers, dt->curserver))) diff --git a/src/libs6dns/s6dns_finish.c b/src/libs6dns/s6dns_finish.c new file mode 100644 index 0000000..3520c5d --- /dev/null +++ b/src/libs6dns/s6dns_finish.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <s6dns/s6-dns.h> + +void s6dns_finish () +{ + s6dns_engine_free(&s6dns_engine_here) ; + s6dns_rci_free(&s6dns_rci_here) ; +} diff --git a/src/libs6dns/s6dns_init.c b/src/libs6dns/s6dns_init.c new file mode 100644 index 0000000..04f94d9 --- /dev/null +++ b/src/libs6dns/s6dns_init.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <skalibs/random.h> +#include <s6dns/s6-dns.h> + +int s6dns_init (void) +{ + if (!random_init()) return 0 ; + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) return 0 ; + return 1 ; +} |