Changeset 1309
- Timestamp:
- 11/27/08 16:47:02 (4 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 4 modified
-
docs/pdns.sgml (modified) (1 diff)
-
lua-pdns-recursor.cc (modified) (4 diffs)
-
lua-pdns-recursor.hh (modified) (1 diff)
-
pdns_recursor.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/docs/pdns.sgml
r1308 r1309 8844 8844 <para> 8845 8845 Both functions are passed the IP address of the requestor, plus the name and type being requested. In return, these functions indicate if they 8846 have taken over the request, or want to let normal proceedings take their course. 8846 have taken over the request, or want to let normal proceedings take their course. Beyond version 3.1.7, the IP address on which the question was received 8847 is inserted immediately after the IP address of the requestor - so in that case there are 4 parameters. 8847 8848 </para> 8848 8849 <para> -
trunk/pdns/pdns/lua-pdns-recursor.cc
r1206 r1309 10 10 } 11 11 12 bool PowerDNSLua::nxdomain(const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res)12 bool PowerDNSLua::nxdomain(const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res) 13 13 { 14 14 return false; 15 15 } 16 16 17 bool PowerDNSLua::preresolve(const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res)17 bool PowerDNSLua::preresolve(const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res) 18 18 { 19 19 return false; … … 114 114 } 115 115 116 bool PowerDNSLua::nxdomain(const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res)117 { 118 return passthrough("nxdomain", remote, query, qtype, ret, res);119 } 120 121 bool PowerDNSLua::preresolve(const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res)122 { 123 return passthrough("preresolve", remote, query, qtype, ret, res);116 bool PowerDNSLua::nxdomain(const ComboAddress& remote, const ComboAddress& local,const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res) 117 { 118 return passthrough("nxdomain", remote, local, query, qtype, ret, res); 119 } 120 121 bool PowerDNSLua::preresolve(const ComboAddress& remote, const ComboAddress& local,const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res) 122 { 123 return passthrough("preresolve", remote, local, query, qtype, ret, res); 124 124 } 125 125 … … 154 154 155 155 156 bool PowerDNSLua::passthrough(const string& func, const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res)156 bool PowerDNSLua::passthrough(const string& func, const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res) 157 157 { 158 158 lua_getglobal(d_lua, func.c_str()); … … 164 164 /* the first argument */ 165 165 lua_pushstring(d_lua, remote.toString().c_str() ); 166 lua_pushstring(d_lua, local.toString().c_str() ); 166 167 lua_pushstring(d_lua, query.c_str() ); 167 168 lua_pushnumber(d_lua, qtype.getCode() ); 168 169 169 if(lua_pcall(d_lua, 3, 2, 0)) { // error170 string error=string("lua error : ")+lua_tostring(d_lua, -1);170 if(lua_pcall(d_lua, 4, 2, 0)) { // error 171 string error=string("lua error in '"+func+"': ")+lua_tostring(d_lua, -1); 171 172 lua_pop(d_lua, 1); 172 173 throw runtime_error(error); -
trunk/pdns/pdns/lua-pdns-recursor.hh
r1200 r1309 12 12 ~PowerDNSLua(); 13 13 void reload(); 14 bool preresolve(const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& res, int& ret);15 bool nxdomain(const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& res, int& ret);14 bool preresolve(const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector<DNSResourceRecord>& res, int& ret); 15 bool nxdomain(const ComboAddress& remote, const ComboAddress& local, const string& query, const QType& qtype, vector<DNSResourceRecord>& res, int& ret); 16 16 private: 17 17 lua_State* d_lua; 18 bool passthrough(const string& func, const ComboAddress& remote, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res);18 bool passthrough(const string& func, const ComboAddress& remote,const ComboAddress& local, const string& query, const QType& qtype, vector<DNSResourceRecord>& ret, int& res); 19 19 bool getFromTable(const std::string& key, std::string& value); 20 20 bool getFromTable(const std::string& key, uint32_t& value); -
trunk/pdns/pdns/pdns_recursor.cc
r1286 r1309 85 85 g_tcpListenSockets_t g_tcpListenSockets; 86 86 int g_tcpTimeout; 87 87 map<int, ComboAddress> g_listenSocketsAddresses; 88 88 struct DNSComboWriter { 89 89 DNSComboWriter(const char* data, uint16_t len, const struct timeval& now) : d_mdp(data, len), d_now(now), d_tcp(false), d_socket(-1) … … 540 540 int res; 541 541 542 if(!g_pdl.get() || !g_pdl->preresolve(dc->d_remote, dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res)) {542 if(!g_pdl.get() || !g_pdl->preresolve(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res)) { 543 543 res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret); 544 544 545 545 if(g_pdl.get()) { 546 546 if(res == RCode::NXDomain) 547 g_pdl->nxdomain(dc->d_remote, dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res);547 g_pdl->nxdomain(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res); 548 548 } 549 549 } … … 1048 1048 1049 1049 Utility::setNonBlocking(fd); 1050 // g_fdm->addReadFD(fd, handleNewUDPQuestion); 1050 1051 1051 deferredAdd.push_back(make_pair(fd, handleNewUDPQuestion)); 1052 1052 g_listenSocketsAddresses[fd]=sin; 1053 1053 if(sin.sin4.sin_family == AF_INET) 1054 1054 L<<Logger::Error<<"Listening for UDP queries on "<< sin.toString() <<":"<<st.port<<endl;