aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libslirp.h3
-rw-r--r--src/slirp.c7
-rw-r--r--src/slirp.h1
-rw-r--r--src/socket.c4
4 files changed, 12 insertions, 3 deletions
diff --git a/src/libslirp.h b/src/libslirp.h
index fb4c7e8..caea7ed 100644
--- a/src/libslirp.h
+++ b/src/libslirp.h
@@ -67,7 +67,7 @@ typedef struct SlirpCb {
} SlirpCb;
#define SLIRP_CONFIG_VERSION_MIN 1
-#define SLIRP_CONFIG_VERSION_MAX 2
+#define SLIRP_CONFIG_VERSION_MAX 3
typedef struct SlirpConfig {
/* Version must be provided */
@@ -109,6 +109,7 @@ typedef struct SlirpConfig {
*/
struct sockaddr_in *outbound_addr;
struct sockaddr_in6 *outbound_addr6;
+ bool disable_dns; /* slirp will not redirect/serve any DNS packet */
} SlirpConfig;
Slirp *slirp_new(const SlirpConfig *cfg, const SlirpCb *callbacks,
diff --git a/src/slirp.c b/src/slirp.c
index 14458e8..4053d34 100644
--- a/src/slirp.c
+++ b/src/slirp.c
@@ -338,6 +338,13 @@ Slirp *slirp_new(const SlirpConfig *cfg, const SlirpCb *callbacks, void *opaque)
slirp->outbound_addr = NULL;
slirp->outbound_addr6 = NULL;
}
+
+ if (cfg->version >= 3) {
+ slirp->disable_dns = cfg->disable_dns;
+ } else {
+ slirp->disable_dns = false;
+ }
+
return slirp;
}
diff --git a/src/slirp.h b/src/slirp.h
index 32634bc..47d861b 100644
--- a/src/slirp.h
+++ b/src/slirp.h
@@ -202,6 +202,7 @@ struct Slirp {
struct sockaddr_in *outbound_addr;
struct sockaddr_in6 *outbound_addr6;
+ bool disable_dns; /* slirp will not redirect/serve any DNS packet */
};
void if_start(Slirp *);
diff --git a/src/socket.c b/src/socket.c
index 4cd9a64..656c319 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -821,7 +821,7 @@ void sofwdrain(struct socket *so)
static bool sotranslate_out4(Slirp *s, struct socket *so, struct sockaddr_in *sin)
{
- if (so->so_faddr.s_addr == s->vnameserver_addr.s_addr) {
+ if (!s->disable_dns && so->so_faddr.s_addr == s->vnameserver_addr.s_addr) {
return get_dns_addr(&sin->sin_addr) >= 0;
}
@@ -839,7 +839,7 @@ static bool sotranslate_out4(Slirp *s, struct socket *so, struct sockaddr_in *si
static bool sotranslate_out6(Slirp *s, struct socket *so, struct sockaddr_in6 *sin)
{
- if (in6_equal(&so->so_faddr6, &s->vnameserver_addr6)) {
+ if (!s->disable_dns && in6_equal(&so->so_faddr6, &s->vnameserver_addr6)) {
uint32_t scope_id;
if (get_dns6_addr(&sin->sin6_addr, &scope_id) >= 0) {
sin->sin6_scope_id = scope_id;