summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2001-11-12 21:18:42 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2001-11-12 21:18:42 +0000
commit07386f65480afa58f8447eea1a41094e6dd93b83 (patch)
tree0396a613189251c52620269a3875ee259cd57a2f
parent770ec4c1629fdf2a4aae77cd89e416e7464b5e07 (diff)
downloadgnutls-07386f65480afa58f8447eea1a41094e6dd93b83.tar.gz
now resolves hostnames.
-rw-r--r--src/cli.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/cli.c b/src/cli.c
index 0428f78ae6..11d6c28687 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -30,6 +30,7 @@
#include "../lib/gnutls.h"
#include <sys/time.h>
#include <signal.h>
+#include <netdb.h>
#ifndef SHUT_WR
# define SHUT_WR 1
@@ -172,11 +173,12 @@ int main(int argc, char** argv)
int user_term = 0;
SRP_CLIENT_CREDENTIALS cred;
X509PKI_CLIENT_CREDENTIALS xcred;
-
+ struct hostent* server_host;
+
signal( SIGPIPE, SIG_IGN);
if (argc!=3) {
- fprintf(stderr, "Usage: cli [IP] [PORT]\n");
+ fprintf(stderr, "Usage: cli [HOST] [PORT]\n");
exit(1);
}
@@ -185,7 +187,12 @@ int main(int argc, char** argv)
exit(1);
}
-
+ /* get server name */
+ server_host = gethostbyname( argv[1]);
+ if (server_host==NULL) {
+ fprintf(stderr, "Cannot resolve %s\n", argv[1]);
+ exit(1);
+ }
/* X509 stuff */
if (gnutls_allocate_x509_client_sc( &xcred, 1) < 0) { /* space for 1 certificate */
@@ -209,16 +216,18 @@ int main(int argc, char** argv)
memset(&sa, '\0', sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(atoi(argv[2]));
- inet_pton( AF_INET, argv[1], &sa.sin_addr);
+ sa.sin_addr.s_addr = *((unsigned int*)server_host->h_addr);
+
+ inet_ntop( AF_INET, &sa.sin_addr, buffer, MAX_BUF);
+ fprintf(stderr, "Connecting to '%s'...\n", buffer);
+
err = connect(sd, (SA *) & sa, sizeof(sa));
ERR(err, "connect");
#ifdef RESUME
gnutls_init(&state, GNUTLS_CLIENT);
- gnutls_set_max_record_size( state, 512);
-
gnutls_set_protocol_priority( state, GNUTLS_TLS1, GNUTLS_SSL3, 0);
gnutls_set_cipher_priority( state, GNUTLS_3DES_CBC, GNUTLS_RIJNDAEL_CBC, 0);
gnutls_set_compression_priority( state, GNUTLS_ZLIB, GNUTLS_NULL_COMPRESSION, 0);