Rev | Line | |
---|
[151] | 1 | #include <fcntl.h> |
---|
| 2 | |
---|
| 3 | #include <netdb.h> |
---|
| 4 | #include <netinet/in.h> |
---|
| 5 | |
---|
| 6 | #include <openssl/ssl.h> |
---|
| 7 | #include <openssl/err.h> |
---|
| 8 | #include <openssl/crypto.h> |
---|
| 9 | #include <openssl/x509.h> |
---|
| 10 | #include <openssl/pem.h> |
---|
| 11 | #include <openssl/bio.h> |
---|
| 12 | |
---|
| 13 | #include <pthread.h> |
---|
| 14 | |
---|
| 15 | #include <sys/types.h> |
---|
| 16 | #include <sys/socket.h> |
---|
| 17 | #include <string.h> |
---|
| 18 | #include <stdio.h> |
---|
| 19 | #include <stdlib.h> |
---|
| 20 | |
---|
| 21 | #include <unistd.h> |
---|
| 22 | |
---|
| 23 | #ifndef __CLIENTS__ |
---|
| 24 | #define __CLIENTS__ 10 |
---|
| 25 | #endif |
---|
| 26 | |
---|
| 27 | #define SOCKET_ERROR -1 |
---|
| 28 | #define BUFFER_SIZE 4096 |
---|
| 29 | #define MESSAGE "This is the message I'm sending back and forth" |
---|
| 30 | #define QUEUE_SIZE 5 |
---|
| 31 | |
---|
| 32 | /* Make these what you want for certificate & key files */ |
---|
| 33 | #define CERT_FILE "mycert.pem" |
---|
| 34 | #define KEY_FILE "mycert.pem" |
---|
| 35 | |
---|
| 36 | /*Cipher list to be used*/ |
---|
| 37 | #define CIPHER_LIST "RC4-MD5" |
---|
| 38 | |
---|
| 39 | /*Trusted CAs location*/ |
---|
| 40 | #define CA_FILE CERT_FILE |
---|
| 41 | #define CA_DIR NULL |
---|
| 42 | |
---|
| 43 | /*Password for the key file*/ |
---|
| 44 | #define KEY_PASSWD "" |
---|
| 45 | |
---|
| 46 | #ifndef __CLEAR_SCREEN__ |
---|
| 47 | #define __CLEAR_SCREEN__ "clear" |
---|
| 48 | #endif |
---|
| 49 | |
---|
| 50 | struct client |
---|
| 51 | { |
---|
| 52 | int fd; |
---|
| 53 | struct sockaddr_in sockaddr; |
---|
| 54 | pthread_t thread; |
---|
| 55 | SSL * myssl; |
---|
| 56 | time_t last; |
---|
| 57 | struct client * next; |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | void * handler(void *); |
---|
| 61 | |
---|
| 62 | void usage (void) |
---|
| 63 | { |
---|
| 64 | puts("usage: ./server <PORT>\n\n"); |
---|
| 65 | exit (-1); |
---|
| 66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.