<div dir="ltr"><div><div><div><div><div><div><div>Hello!<br><br></div>I'm developing a dynamic name resolution service using lua backend to provide cdn capabilities to some websites.<br><br></div>Consider this simple <b><a href="http://example.com">example.com</a></b> zone:<br>
<br></div><div><b><i>name | type | content | flag cdn</i></b><br></div><div><br></div><a href="http://example.com">example.com</a> | <b>A</b> | 1.1.1.1 | true<br></div><a href="http://www.example.com">www.example.com</a> | <b>CNAME</b> | <a href="http://example.com">example.com</a> | false<br>
<br></div><div>Another considerations:<br><br></div><div>- when flag is enabled any query should return cdn server ip<br></div></div>- CDN server IP: 2.2.2.2<br></div><div><br><div><div><br></div><div>Queries and expected responses:<br>
<br></div><div>1) query to <b><a href="http://example.com">example.com</a></b> should return 2.2.2.2<br>2) query to <b><a href="http://www.example.com">www.example.com</a></b> should return <b>CNAME <a href="http://example.com">example.com</a></b> and <b>A 1.1.1.1</b><br>
</div><div><br></div><div></div><div>In this case, the record <b><a href="http://example.com">example.com</a></b> has a flag enabled that makes all name resolutions to it dynamic, so when querying <b><a href="http://example.com">example.com</a> </b>luabackend returns a record pointing to <b>2.2.2.2 </b>and not <b>1.1.1.1.</b> This is ok and works fine.<br>
<br></div><div>The problem occurs when querying <b><a href="http://www.example.com">www.example.com</a> </b>that does not use this cdn flag . Here the step by step in the lua backend:<br><br></div><div>1) getsoa <b><a href="http://www.example.com">www.example.com</a></b><br>
</div><div>2) getsoa <b><a href="http://example.com">example.com</a></b><br></div><div>3) lookup <b><a href="http://www.example.com">www.example.com</a></b><br></div><div>4) get <b><a href="http://www.example.com">www.example.com</a></b><br>
</div><div>5) lookup <b><a href="http://example.com">example.com</a></b><br></div><div>6) get <b><a href="http://example.com">example.com</a></b><br></div><div><br></div><div>The returning record is <b>2.2.2.2</b>, because the flag is enabled in <b><a href="http://example.com">example.com</a></b>, but I want to dynamic disable this flag when it's a recursive query.<br>
<br></div><div>The
first possibility that I see to resolve this problem is to determine if
a specific query is after recursion or not. Is it possible to identify
in lua backend when it's a recursive query? <br><br>Another approach would be return in the <b>step 3 </b>both records, to avoid powerdns make recursive query in <b><a href="http://example.com">example.com</a></b> with the flag enabled.<br>
<br><a href="http://www.example.com">www.example.com</a> <b>CNAME</b> <a href="http://example.com">example.com</a><br></div><div><a href="http://example.com">example.com</a> <b>A</b> 1.1.1.1 ***<br><br></div><div>*** the problem is how to make pdns stop querying for <a href="http://example.com">example.com</a> again. I tried to change <b>qname</b> to <b><a href="http://example.com">example.com</a></b> instead <b><a href="http://www.example.com">www.example.com</a></b> but it didn't work.<br>
</div><div><br></div><div>I know that it seems a little bit confused, but I appreciate any help.<br><br></div><div>Tks,<br><br>Guilherme<br></div></div></div></div>