* ensures the server certificate doesn't change. Normally this isn't detected
* if a trusted CA for the new server certificate is installed.
*
* ensures the server certificate doesn't change. Normally this isn't detected
* if a trusted CA for the new server certificate is installed.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* For gnutls_*() functions. */
#define GNUTLS_ERROR_EXIT(error, message) \
/* For gnutls_*() functions. */
#define GNUTLS_ERROR_EXIT(error, message) \
fprintf(stderr, "%s: %s\n", message, gnutls_strerror(error)); \
exit(EXIT_FAILURE); \
}
fprintf(stderr, "%s: %s\n", message, gnutls_strerror(error)); \
exit(EXIT_FAILURE); \
}
parse_arguments(argc, argv);
port = atoi(argv[argc - 1]);
parse_arguments(argc, argv);
port = atoi(argv[argc - 1]);
result = pthread_create(&thread, NULL,
(void * (*)(void *))&worker_thread,
NULL);
result = pthread_create(&thread, NULL,
(void * (*)(void *))&worker_thread,
NULL);
int socket_option = 1;
setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR,
&socket_option, sizeof(socket_option));
int socket_option = 1;
setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR,
&socket_option, sizeof(socket_option));
server_in.sin6_addr = in6addr_any; /* bind to any address */
server_in.sin6_port = htons((uint16_t)port); /* port to bind to */
#endif
server_in.sin6_addr = in6addr_any; /* bind to any address */
server_in.sin6_port = htons((uint16_t)port); /* port to bind to */
#endif
- if (-1 == bind(server_socket, (struct sockaddr *)&server_in,
- sizeof(server_in))) {
+ if (bind(server_socket, (struct sockaddr *)&server_in,
+ sizeof(server_in)) == -1) {
printf("tlsproxy %s\n", VERSION);
printf("Listening for connections on port %d.\n", port);
printf("tlsproxy %s\n", VERSION);
printf("Listening for connections on port %d.\n", port);
while (!done) {
/* Accept new connection. */
client_socket = accept(server_socket, NULL, NULL);
while (!done) {
/* Accept new connection. */
client_socket = accept(server_socket, NULL, NULL);
}
for (i = 0; i < thread_count; i++) {
errno = pthread_join(threads[i], NULL);
}
for (i = 0; i < thread_count; i++) {
errno = pthread_join(threads[i], NULL);
- if (NULL == (position = strchr(optarg, ':'))
- || position == optarg
- || 0 == strlen(position + 1)
- || 0 >= atoi(position + 1)
- || 0xffff < atoi(position + 1)) {
+ if ((position = strchr(optarg, ':')) == NULL
+ || optarg == position
+ || strlen(position + 1) == 0
+ || atoi(position + 1) <= 0
+ || atoi(position + 1) > 0xffff) {
- fprintf(stderr, "\ninvalid -p, format host:port\n");
+ fprintf(stderr, "\ninvalid -p: '%s', format host:port\n",
+ optarg);