/*
- PowerDNS Versatile Database Driven Nameserver
- Copyright (C) 2002 - 2011 PowerDNS.COM BV
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2
- as published by the Free Software Foundation
-
- Additionally, the license of this program contains a special
- exception which allows to distribute the program in binary form when
- it is linked against OpenSSL.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
/* accepts a named.conf or a zone as parameter and outputs heaps of sql */
#ifdef HAVE_CONFIG_H
cout<<"BEGIN TRANSACTION;"<<endl;
}
-static void emitDomain(const DNSName& domain, const vector<string> *masters = 0) {
+static void emitDomain(const DNSName& domain, const vector<ComboAddress> *masters = 0) {
string iDomain = domain.toStringRootDot();
if(!::arg().mustDo("slave")) {
if(g_mode==POSTGRES || g_mode==MYSQL || g_mode==SQLITE) {
if(g_mode==POSTGRES || g_mode==MYSQL || g_mode==SQLITE) {
string mstrs;
if (masters != 0 && ! masters->empty()) {
- for(const string& mstr : *masters) {
- mstrs.append(mstr);
+ for(const auto& mstr : *masters) {
+ mstrs.append(mstr.toStringWithPortExcept(53));
mstrs.append(1, ' ');
}
}
else if(g_mode==POSTGRES) {
cout<<"insert into records (domain_id, name, ordername, auth, type,content,ttl,prio,disabled) select id ,"<<
sqlstr(toLower(qname))<<", "<<
- sqlstr(toLower(labelReverse(makeRelative(qname, zname))))<<", '"<< (auth ? 't' : 'f') <<"', "<<
+ sqlstr(DNSName(qname).makeRelative(DNSName(zname)).makeLowerCase().labelReverse().toString(" ", false))<<", '"<< (auth ? 't' : 'f') <<"', "<<
sqlstr(qtype)<<", "<<
sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", '"<<(disabled ? 't': 'f') <<
"' from domains where name="<<toLower(sqlstr(zname))<<";\n";
try
{
reportAllTypes();
-#if __GNUC__ >= 3
std::ios_base::sync_with_stdio(false);
-#endif
-
+
::arg().setSwitch("gpgsql","Output in format suitable for default gpgsqlbackend")="no";
::arg().setSwitch("gmysql","Output in format suitable for default gmysqlbackend")="no";
::arg().setSwitch("mydns","Output in format suitable for default mydnsbackend")="no";
::arg().set("soa-expire-default","Do not change")="0";
::arg().setCmd("help","Provide a helpful message");
+ ::arg().setCmd("version","Print the version");
S.declare("logmessages");
string zonefile="";
::arg().parse(argc, argv);
+
+ if(::arg().mustDo("version")) {
+ cerr<<"zone2sql "<<VERSION<<endl;
+ exit(0);
+ }
if(::arg().mustDo("help")) {
cout<<"syntax:"<<endl<<endl;
++i)
{
if(i->type!="master" && i->type!="slave") {
- cerr<<" Warning! Skipping '"<<i->type<<"' zone '"<<i->name.toString()<<"'"<<endl;
+ cerr<<" Warning! Skipping '"<<i->type<<"' zone '"<<i->name<<"'"<<endl;
continue;
}
try {