Commit Diff
Diff:
32e5d54a062965b100ac5380f6fa51853dab4e48
0f80aa4db638cb5ee8fec58ec0c781c3f6e3866b
Commit:
0f80aa4db638cb5ee8fec58ec0c781c3f6e3866b
Tree:
5a3a0535411a371cc9511fd68b83efbd53478a8c
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Apr 15 19:59:46 2014 UTC
Message:
Configuration file options, these override the commandline options they are: -b option == bind IP; -i option == interface "lo0"; -n option == fork 2; -p option == port 10034; -l option == log; The format of these are the following: options "cute options" { log; } as an example. tested on OpenBSD 5.4
blob - /dev/null
blob + 4bd1aee705eacc929756b177edc869f99d0412bd (mode 644)
--- /dev/null
+++ example8.conf
@@ -0,0 +1,102 @@
+; sample config file that is in production.
+;
+version "6";
+
+options "cool stuff" {
+ interface "lo0";
+ interface "re0";
+ ;bind 127.0.0.1;
+ ;bind 192.168.34.4;
+ port 10034;
+ ;fork 2;
+ log;
+}
+
+zone "centroid.eu" {
+ centroid.eu,soa,3600,uranus.centroid.eu.,pjp.solarscale.de.,1258740680,3600,1800,7200,3600
+ centroid.eu,ns,3600,proteus.solarscale.de.
+ centroid.eu,ns,3600,uranus.centroid.eu.
+ centroid.eu,ns,3600,dione.solarscale.de.
+ ;
+ centroid.eu,a,3600,200.46.208.61
+ centroid.eu,a,3600,62.75.160.180
+ ;
+ centroid.eu,mx,3600,10,proteus.solarscale.de.
+ centroid.eu,aaaa,3600,2001:a60:f074::8
+ ;
+ www.centroid.eu,a,3600,62.75.160.180
+ www.centroid.eu,a,3600,200.46.208.61
+ ;
+ www.centroid.eu,aaaa,3600,2001:a60:f074::8
+ uranus.centroid.eu,a,3600,212.114.251.91
+ uranus.centroid.eu,aaaa,3600,2001:a60:f000:99::2
+ proteus.centroid.eu,a,3600,62.75.160.180
+ dione.centroid.eu,a,3600,200.46.208.61
+ rosalind.centroid.eu,aaaa,3600,2001:a60:f074::8
+ irc.centroid.eu,a,3600,212.114.251.91
+ irc.centroid.eu,aaaa,3600,2001:a60:f074::24
+ irc2.centroid.eu,a,3600,200.46.208.61
+ localhost.centroid.eu,a,3600,127.0.0.1
+ localhost.centroid.eu,aaaa,3600,::1
+ ; the below are new delegations (NS) records
+ ;delegation.centroid.eu,delegate,3600,ns1.server.com.
+ ; glue record
+ ;ns1.server.com.,a,3600,10.0.0.1
+ ;delegation.centroid.eu,delegate,3600,ns2.server.com.
+ ; glue record
+ ;ns2.server.com.,a,3600,10.0.0.2
+}
+zone "ipv6.centroid.eu" {
+ ipv6.centroid.eu,soa,3600,uranus.centroid.eu.,pjp.solarscale.de.,1244725285,3600,1800,7200,3600
+ ipv6.centroid.eu,aaaa,3600,2001:a60:f074::8
+ www.ipv6.centroid.eu,aaaa,3600,2001:a60:f074::8
+}
+zone "ipv6.solarscale.de" {
+ ipv6.solarscale.de,soa,3600,proteus.solarscale.de.,pjp.solarscale.de.,1234896563,3600,1800,7200,3600
+ ipv6.solarscale.de,ns,3600,proteus.solarscale.de.
+ ipv6.solarscale.de,ns,3600,uranus.centroid.eu.
+ ipv6.solarscale.de,aaaa,3600,2001:a60:f074::8
+ www.ipv6.solarscale.de,aaaa,3600,2001:a60:f074::8
+}
+zone "reverse dns" {
+ 0.4.7.0.f.0.6.a.0.1.0.0.2.ip6.arpa.,soa,3600,proteus.solarscale.de.,pjp.solarscale.de.,1234896562,3600,1800,7200,3600
+ 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.7.0.f.0.6.a.0.1.0.0.2.ip6.arpa.,ptr,3600,uranus.centroid.eu.
+ 2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.7.0.f.0.6.a.0.1.0.0.2.ip6.arpa.,ptr,3600,setebos.centroid.eu.
+}
+
+zone "root hints" {
+ .,hint,3600000,A.ROOT-SERVERS.NET.
+ A.ROOT-SERVERS.NET.,a,3600000,198.41.0.4
+ A.ROOT-SERVERS.NET.,aaaa,3600000,2001:503:BA3E::2:30
+ .,hint,3600000,B.ROOT-SERVERS.NET.
+ B.ROOT-SERVERS.NET.,a,3600000,192.228.79.201
+ .,hint,3600000,C.ROOT-SERVERS.NET.
+ C.ROOT-SERVERS.NET.,a,3600000,192.33.4.12
+ .,hint,3600000,D.ROOT-SERVERS.NET.
+ D.ROOT-SERVERS.NET.,a,3600000,199.7.91.13
+ D.ROOT-SERVERS.NET.,aaaa,3600000,2001:500:2D::D
+ .,hint,3600000,E.ROOT-SERVERS.NET.
+ E.ROOT-SERVERS.NET.,a,3600000,192.203.230.10
+ .,hint,3600000,F.ROOT-SERVERS.NET.
+ F.ROOT-SERVERS.NET.,a,3600000,192.5.5.241
+ F.ROOT-SERVERS.NET.,aaaa,3600000,2001:500:2f::f
+ .,hint,3600000,G.ROOT-SERVERS.NET.
+ G.ROOT-SERVERS.NET.,a,3600000,192.112.36.4
+ .,hint,3600000,H.ROOT-SERVERS.NET.
+ H.ROOT-SERVERS.NET.,a,3600000,128.63.2.53
+ H.ROOT-SERVERS.NET.,aaaa,3600000,2001:500:1::803f:235
+ .,hint,3600000,I.ROOT-SERVERS.NET.
+ I.ROOT-SERVERS.NET.,a,3600000,192.36.148.17
+ .,hint,3600000,J.ROOT-SERVERS.NET.
+ J.ROOT-SERVERS.NET.,a,3600000,192.58.128.30
+ J.ROOT-SERVERS.NET.,aaaa,3600000,2001:503:C27::2:30
+ .,hint,3600000,K.ROOT-SERVERS.NET.
+ K.ROOT-SERVERS.NET.,a,3600000,193.0.14.129
+ K.ROOT-SERVERS.NET.,aaaa,3600000,2001:7fd::1
+ .,hint,3600000,L.ROOT-SERVERS.NET.
+ L.ROOT-SERVERS.NET.,a,3600000,199.7.83.42
+ L.ROOT-SERVERS.NET.,aaaa,3600000,2001:500:3::42
+ .,hint,3600000,M.ROOT-SERVERS.NET.
+ M.ROOT-SERVERS.NET.,a,3600000,202.12.27.33
+ M.ROOT-SERVERS.NET.,aaaa,3600000,2001:dc3::35
+}
blob - 770a26754c56b609a6e09b36617722b382ae891f
blob + d7931d617afe419014503af58729ec7d2fdc5c29
--- main.c
+++ main.c
@@ -112,9 +112,6 @@ extern char *__progname;
extern struct logging logging;
extern int axfrport;
-static int lflag = 0;
-static int rflag = 0;
-static u_int16_t port = 53;
static int *ptr = NULL;
static int reload = 0;
static int mshutdown = 0;
@@ -122,7 +119,19 @@ static int msig;
static char *database;
static char mydatabase[512];
-int debug = 0, verbose = 0;
+int debug = 0;
+int verbose = 0;
+int bflag = 0;
+int iflag = 0;
+int lflag = 0;
+int nflag = 0;
+int rflag = 0;
+int bcount = 0;
+int icount = 0;
+u_int16_t port = 53;
+u_int32_t cachesize = 0;
+char *bind_list[255];
+char *interface_list[255];
/* singly linked list for tcp operations */
SLIST_HEAD(listhead, tcps) tcpshead;
@@ -143,7 +152,7 @@ struct tcps {
} *tn1, *tn2, *tnp;
-static const char rcsid[] = "$Id: main.c,v 1.81 2014/04/13 10:12:10 pjp Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.82 2014/04/15 19:59:46 pjp Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -164,21 +173,15 @@ main(int argc, char *argv[])
int ch, i, j;
int gai_error;
int salen, ret;
- int bflag = 0, iflag = 0;
- int nflag = 0;
- int bcount = 0, icount = 0;
int found = 0;
int on = 1;
int sp[2];
- u_int32_t cachesize = 0;
pid_t pid;
static char *ident[DEFAULT_SOCKET];
char *conffile = CONFFILE;
char buf[512];
- char *interface_list[255];
- char *bind_list[255];
char **av = NULL;
struct passwd *pw;
@@ -205,7 +208,7 @@ main(int argc, char *argv[])
case 'b':
bflag = 1;
if (bcount > 253) {
- fprintf(stderr, "too man -b flags\n");
+ fprintf(stderr, "too many -b flags\n");
exit(1);
}
bind_list[bcount++] = optarg;
blob - 28acc4c749f3d5e75fc220d676f59ae67de8b4da
blob + 1a18fecf2edff84b59d79e50b500ca202788c586
--- parse.y
+++ parse.y
@@ -58,7 +58,7 @@ typedef struct {
int lineno;
} YYSTYPE;
-static const char rcsid[] = "$Id: parse.y,v 1.10 2014/04/14 11:38:57 pjp Exp $";
+static const char rcsid[] = "$Id: parse.y,v 1.11 2014/04/15 19:59:46 pjp Exp $";
static int version = 0;
static int state = 0;
static uint8_t region = 0;
@@ -69,6 +69,18 @@ YYSTYPE yylval;
extern int errno;
extern int debug;
+extern int verbose;
+extern int bflag;
+extern int iflag;
+extern int lflag;
+extern int nflag;
+extern int rflag;
+extern int bcount;
+extern int icount;
+extern u_int16_t port;
+extern u_int32_t cachesize;
+extern char *bind_list[255];
+extern char *interface_list[255];
char *converted_name;
int converted_namelen;
@@ -159,7 +171,7 @@ parse_file(DB *db, char *filename)
%token VERSION OBRACE EBRACE REGION AXFRFOR RECURSEFOR
%token DOT COLON TEXT WOF INCLUDE ZONE COMMA CRLF
-%token ERROR AXFRPORT LOGGING
+%token ERROR AXFRPORT LOGGING OPTIONS
%token <v.string> POUND
%token <v.string> SEMICOLON
@@ -191,6 +203,7 @@ cmd :
| recurse CRLF
| logging
| comment CRLF
+ | options
;
@@ -472,7 +485,90 @@ zonestatement:
}
| comment CRLF
;
+
+
+options:
+ OPTIONS optionslabel optionscontent
+ {
+ if ((confstatus & CONFIG_VERSION) != CONFIG_VERSION) {
+ dolog(LOG_INFO, "There must be a version at the top of the first configfile\n");
+ return (-1);
+ }
+ }
+ ;
+
+optionslabel:
+ QUOTEDSTRING
+ ;
+
+optionscontent:
+ OBRACE optionsstatements EBRACE CRLF
+ | OBRACE CRLF optionsstatements EBRACE CRLF
+ ;
+
+optionsstatements:
+ optionsstatement CRLF
+ | optionsstatements optionsstatement CRLF
+ ;
+
+optionsstatement:
+
+ STRING SEMICOLON
+ {
+ if (strcasecmp($1, "recurse") == 0) {
+ dolog(LOG_DEBUG, "recursive server on\n");
+ rflag = 0; /* keep it off please! */
+ } else if (strcasecmp($1, "log") == 0) {
+ dolog(LOG_DEBUG, "logging on\n");
+ lflag = 1;
+ }
+ }
+ |
+ STRING QUOTEDSTRING SEMICOLON
+ {
+ if (strcasecmp($1, "interface") == 0) {
+ iflag = 1;
+ if (icount > 253) {
+ dolog(LOG_ERR, "too many interface keywords in options\n");
+ return (-1);
+ }
+ dolog(LOG_DEBUG, "interface \"%s\" added\n", $2);
+ interface_list[icount++] = $2;
+ }
+
+ }
+ |
+ STRING NUMBER SEMICOLON
+ {
+ if (strcasecmp($1, "fork") == 0) {
+ dolog(LOG_DEBUG, "forking %d times\n", $2);
+ nflag = $2;
+ } else if (strcasecmp($1, "port") == 0) {
+ port = $2 & 0xffff;
+ dolog(LOG_DEBUG, "listening on port %d\n", port);
+ }
+
+ }
+ |
+ STRING ipcidr SEMICOLON
+ {
+ if (strcasecmp($1, "bind") == 0) {
+ bflag = 1;
+ if (bcount > 253) {
+ dolog(LOG_ERR, "too many bind keywords in options\n");
+ return (-1);
+ }
+ dolog(LOG_DEBUG, "binding to %s\n", $2);
+ bind_list[bcount++] = $2;
+ }
+
+ }
+ | comment
+ ;
+
+/* logging below */
+
logging:
LOGGING logginglabel loggingcontent
{
@@ -868,13 +964,14 @@ struct tab * lookup(struct tab *cmdtab, char *keyword)
struct tab cmdtab[] = {
{ "axfrport", AXFRPORT, 0},
- { "version", VERSION, 0 },
- { "logging", LOGGING, 0 },
- { "region", REGION, STATE_IP },
{ "axfr-for", AXFRFOR, STATE_IP },
+ { "include", INCLUDE, 0 },
+ { "logging", LOGGING, 0 },
+ { "options", OPTIONS, 0 },
{ "recurse-for", RECURSEFOR, STATE_IP },
+ { "region", REGION, STATE_IP },
{ "wildcard-only-for", WOF, STATE_IP },
- { "include", INCLUDE, 0 },
+ { "version", VERSION, 0 },
{ "zone", ZONE, 0 },
{ NULL, 0, 0}};
repomaster@centroid.eu