]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/blobdiff - src/tlsproxy.c
Add -u option to pass through unknown hostnames.
[tlsproxy/tlsproxy.git] / src / tlsproxy.c
index 7a27f5531335368b6e80be8fa7ee159c4ea54919..25f37043394518b1c02184fb775925ef1564d4f2 100644 (file)
@@ -168,14 +168,12 @@ int main(int argc, char **argv) {
         return EXIT_FAILURE;
     }
 
-#ifdef DEBUG
     /* Fast rebinding for debug mode, could cause invalid packets. */
-    {
+    if (LOG_DEBUG <= global_log_level) {
         int socket_option = 1;
         setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR,
                    &socket_option, sizeof(socket_option));
     }
-#endif
 
     /* Bind to the listen socket. */
     memset(&server_in, 0, sizeof(server_in));
@@ -272,8 +270,9 @@ static void parse_arguments(int argc, char **argv) {
 #else
     global_log_level = LOG_WARNING;
 #endif
+    global_passthrough_unknown = 0;
 
-    while (-1 != (option = getopt(argc, argv, "d:p:t:h?"))) {
+    while (-1 != (option = getopt(argc, argv, "d:p:t:uh?"))) {
         switch (option) {
             case 'd': {
                 if (0 > atoi(optarg)) {
@@ -324,6 +323,10 @@ static void parse_arguments(int argc, char **argv) {
                 thread_count = (size_t)atoi(optarg);
                 break;
             }
+            case 'u': {
+                global_passthrough_unknown = 1;
+                break;
+            }
             case 'h':
             default: /* '?' */
                 print_usage(argv[0]);
@@ -338,12 +341,15 @@ static void parse_arguments(int argc, char **argv) {
     }
 }
 static void print_usage(const char *argv) {
-    fprintf(stderr, "Usage: %s [-d level] [-p host:port] [-t count] port\n",
+    fprintf(stderr, "Usage: %s [-d level] [-p host:port] [-t count] [-u] port\n",
                     argv);
     fprintf(stderr, "\n");
     fprintf(stderr, "-d debug level: 0=errors only, 2=debug [default: 1]\n");
     fprintf(stderr, "-p proxy hostname and port\n");
     fprintf(stderr, "-t number of threads [default: 10]\n");
+    fprintf(stderr, "-u passthrough connection if no certificate is stored \
+[default: error]\n");
+    fprintf(stderr, "   WARNING: might be a security problem!\n");
 }
 
 static void initialize_gnutls(void) {