Jelajahi Sumber

- accidental commit of local unfinished changes reverted

Jan Janak 19 tahun lalu
induk
melakukan
8737eaf4bc
1 mengubah file dengan 139 tambahan dan 2 penghapusan
  1. 139 2
      cfg.y

+ 139 - 2
cfg.y

@@ -96,6 +96,9 @@
 #include "select.h"
 
 #include "config.h"
+#ifdef USE_TLS
+#include "tls/tls_config.h"
+#endif
 
 #ifdef DEBUG_DMALLOC
 #include <dmalloc.h>
@@ -124,6 +127,7 @@ static select_t sel;
 static select_t* sel_ptr;
 static struct action *mod_func_action;
 
+static void warn(char* s);
 static struct socket_id* mk_listen_id(char*, int, int);
 
 %}
@@ -249,7 +253,20 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token TCP_POLL_METHOD
 %token TCP_MAX_CONNECTIONS
 %token DISABLE_TLS
+%token TLSLOG
 %token TLS_PORT_NO
+%token TLS_METHOD
+%token TLS_HANDSHAKE_TIMEOUT
+%token TLS_SEND_TIMEOUT
+%token SSLv23
+%token SSLv2
+%token SSLv3
+%token TLSv1
+%token TLS_VERIFY
+%token TLS_REQUIRE_CERTIFICATE
+%token TLS_CERTIFICATE
+%token TLS_PRIVATE_KEY
+%token TLS_CA_LIST
 %token ADVERTISED_ADDRESS
 %token ADVERTISED_PORT
 %token DISABLE_CORE
@@ -324,7 +341,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %type <attr> attr_id_ass
 %type <attr> attr_id_val
 %type <attr> attr_id_any
-/* %type <intval> class_id */
+//%type <intval> class_id
 %type <intval> assign_op
 %type <select> select_id
 /*%type <route_el> rules;
@@ -556,6 +573,121 @@ assign_stm:
 		#endif
 	}
 	| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
+	| DISABLE_TLS EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_disable=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| DISABLE_TLS EQUAL error { yyerror("boolean value expected"); }
+	| TLSLOG EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_log=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLSLOG EQUAL error { yyerror("int value expected"); }
+	| TLS_PORT_NO EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_port_no=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_PORT_NO EQUAL error { yyerror("number expected"); }
+	| TLS_METHOD EQUAL SSLv23 {
+		#ifdef USE_TLS
+			tls_method=TLS_USE_SSLv23;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_METHOD EQUAL SSLv2 {
+		#ifdef USE_TLS
+			tls_method=TLS_USE_SSLv2;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_METHOD EQUAL SSLv3 {
+		#ifdef USE_TLS
+			tls_method=TLS_USE_SSLv3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_METHOD EQUAL TLSv1 {
+		#ifdef USE_TLS
+			tls_method=TLS_USE_TLSv1;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_METHOD EQUAL error {
+		#ifdef USE_TLS
+			yyerror("SSLv23, SSLv2, SSLv3 or TLSv1 expected");
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_VERIFY EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_verify_cert=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_VERIFY EQUAL error { yyerror("boolean value expected"); }
+	| TLS_REQUIRE_CERTIFICATE EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_require_cert=$3;
+		#else
+			warn( "tls support not compiled in");
+		#endif
+	}
+	| TLS_REQUIRE_CERTIFICATE EQUAL error { yyerror("boolean value expected"); }
+	| TLS_CERTIFICATE EQUAL STRING {
+		#ifdef USE_TLS
+			tls_cert_file=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_CERTIFICATE EQUAL error { yyerror("string value expected"); }
+	| TLS_PRIVATE_KEY EQUAL STRING {
+		#ifdef USE_TLS
+			tls_pkey_file=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_PRIVATE_KEY EQUAL error { yyerror("string value expected"); }
+	| TLS_CA_LIST EQUAL STRING {
+		#ifdef USE_TLS
+			tls_ca_file=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_CA_LIST EQUAL error { yyerror("string value expected"); }
+	| TLS_HANDSHAKE_TIMEOUT EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_handshake_timeout=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_HANDSHAKE_TIMEOUT EQUAL error { yyerror("number expected"); }
+	| TLS_SEND_TIMEOUT EQUAL NUMBER {
+		#ifdef USE_TLS
+			tls_send_timeout=$3;
+		#else
+			warn("tls support not compiled in");
+		#endif
+	}
+	| TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
 	| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
 	| SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
 	| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
@@ -1126,7 +1258,6 @@ select_param:
 		sel.n++;
 	}
 	;
-
 select_params:
 	select_params DOT select_param
 	| select_param
@@ -1498,6 +1629,12 @@ func_param:
 extern int line;
 extern int column;
 extern int startcolumn;
+static void warn(char* s)
+{
+	LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn,
+			column, s);
+	cfg_errors++;
+}
 
 static void yyerror(char* s)
 {