leap_frog/ 40755 764 764 0 6772226654 10574 5ustar awrawrleap_frog/src/ 40755 764 764 0 6772223323 11351 5ustar awrawrleap_frog/src/include/ 40755 764 764 0 6772223332 12774 5ustar awrawrleap_frog/src/include/credits.h100640 764 764 1115 6771536560 14702 0ustar awrawr#define CREDITS " \n\r" \ "*********************************************************************\n\r" \ "* *\n\r" \ "* CREDITS *\n\r" \ "* *\n\r" \ "* *\n\r" \ "* Programmer: Bert AKA AL www.cotse.com awr@cotse.com *\n\r" \ "* *\n\r" \ "*********************************************************************\n\r" leap_frog/src/include/link.h100664 764 764 5230 6771670413 14206 0ustar awrawr#include #include "config.h" #include #ifdef REDHAT4 #include #endif #ifdef REDHAT5 #include #endif #ifdef SOLARIS #include #endif /* flags */ #define PANIC 1 #define INPUT_READY (1<<1) #define LAST_CHAR_WAS_N (1<<2) #define LAST_CHAR_WAS_R (1<<3) #define DO_LOCAL_ECHO (1<<4) #define PASSWORD_MODE (1<<5) #define IBUFFER_LENGTH 512 #define NAME_LENGTH 20 #define PASSWORD 1 #define PROMPT (1<<7) #define _VERBOSE (1<<8) #define LOGIN (1<<9) #define CHUCKOUT (1<<10) #define EOR_ON (1<<11) #define IAC_GA_DO (1<<12) #define SITE_LOG (1<<13) /* output bit */ #define DOCRLF (1<<2) /* stupid stuff */ #define CRLF "\n\r" // commands struct frog; typedef void command_func(struct frog *, char *); /* terms */ struct terminal { char *name; char *bold; char *off; char *cls; }; // main struct for leap frogging struct frog { char name[50]; int term; int count; int flags; int booted; int bytes_read; char port[50]; unsigned long temp_long; struct sockaddr_in address; fd_set select_1; fd_set select_2; struct hostent *host_entry; struct hostent *host_entry_add; unsigned short remote_port; char inetaddr[50]; char num_addr[50]; char buffer[255]; int remote_sock; int remote2_sock; pthread_t tid; /* thread id */ struct sockaddr_in remote_addr; int socket; char *stack; char *oldstack; char *totell; // review char char *data; char *the_data; char *command; char *line; int pid; // ps id # int ppid; // ps ppid # int no_days,no_hours,no_mins,no_secs; double totaltime; // all time time_t start_logtime; time_t logtime; time_t idle; command_func *fn; // call fucntion next int x; // back to me struct frog *next; struct frog *prev; }; typedef struct frog FROG; struct saved_player { char inetaddr[50]; char remote[50]; unsigned short port; }; /* thread for threads */ struct player_t { int socket; int pid; char sin_addr[50]; char *numerical_address; }; // demo use of command_func extern command_func send_fd; extern command_func time_up; extern command_func view_commands; extern command_func cls; extern int logins; // this is the struct for all commands in cooperation that data is // passed to functions command_func ie: p()() struct command { char *text; command_func *function; int a; int level; int andlevel; int space; char *help; int type; }; leap_frog/src/include/linked_list.h100640 764 764 26732 6765755406 15607 0ustar awrawr/* Linked List Abstract Data Type Written by: G & F Date: 2/98 Copyright 1998 Brooks/Cole Publishing Company An International Thomson Publishing Company All Rights Reserved */ /* List ADT Type Defintions */ typedef struct node { void *dataPtr; struct node *link; } NODE; typedef struct { int count; NODE *pos; NODE *head; NODE *rear; int (*compare) (void *argu1, void *argu2); } LIST; /* Prototype Declarations */ LIST *createList (int (*compare) (void *argu1, void *argu2)); LIST *destroyList (LIST *list); int addNode (LIST *pList, void *dataInPtr); int removeNode (LIST *pList, void *keyPtr, void **dataOutPtr); int searchList (LIST *pList, void *pArgu, void **pDataOut); static int retrieveNode (LIST *pList, void *pArgu, void **dataOutPtr); int traverse (LIST *pList, int fromWhere, void **dataOutPtr); int listCount (LIST *pList); int emptyList (LIST *pList); int fullList (LIST *pList); static int _insert (LIST *pList, NODE *pPre, void *dataInPtr); static void _delete (LIST *pList, NODE *pPre, NODE *pLoc, void **dataOutPtr); static int _search (LIST *pList, NODE **pPre, NODE **pLoc, void *pArgu); /* End of List ADT Definitions */ /* =============== createList ============== */ /* Allocates dynamic memory for a linked list head node and returns its address to caller Pre compare is address of compare function used whenever two nodes need to be compared. Post head has allocated or error returned Return head node pointer or null if memory overflow */ LIST *createList (int (*compare) (void *argu1, void *argu2)) { /* Local Declarations */ LIST *list; /* Statements */ list = (LIST *) malloc (sizeof (LIST)); if (list) { list->head = NULL; list->pos = NULL; list->rear = NULL; list->count = 0; list->compare = compare; } /* if */ return list; } /* createList */ /* =============== addNode ============== */ /* Inserts data into linked list. Pre pList is a pointer to a valid list dataInPtr is a pointer to data to be inserted Post data inserted unless dupe key or overflow Return -1 if overflow, 0 if successful, 1 if dupe key */ int addNode (LIST *pList, void *dataInPtr) { /* Local Declarations */ int found; int success; NODE *pPre; NODE *pLoc; /* Statements */ found = _search (pList, &pPre, &pLoc, dataInPtr); // if (found == 1) /* Duplicate keys not allowed */ // return (+1); success = _insert (pList, pPre, dataInPtr); if (!success) /* Overflow */ return (-1); return (0); } /* addNode */ /* =============== _insert ============== */ /* Inserts data pointer into a new node in the linked list. Pre pList is a pointer to a valid list pPre is a pointer to the data's predecessor dataInPtr contains data pointer to be inserted Post data have been inserted in sequence Return boolean, true if successful, false if memory overflow. */ static int _insert (LIST *pList, NODE *pPre, void *dataInPtr) { /* Local Declarations */ NODE *pNew; /* Statements */ if (!(pNew = (NODE *) malloc(sizeof(NODE)))) return 0; pNew->dataPtr = dataInPtr; pNew->link = NULL; if (pPre == NULL) { /* Adding before first node or to empty list. */ pNew->link = pList->head; pList->head = pNew; if (pList->count == 0) /* Adding to empty list. Set rear */ pList->rear = pNew; } /* if pPre */ else { /* Adding in middle or at end */ pNew->link = pPre->link; pPre->link = pNew; /* Now check for add at end of list */ if (pNew->link == NULL) pList->rear = pNew; } /* if else */ (pList->count)++; return 1; } /* _insert */ /* =============== removeNode ============== */ /* Removes data from linked list. Pre pList is a pointer to a valid list keyPtr is pointer to key to be deleted dataOutPtr is a pointer to data pointer Post Node deleted or error returned. Return false (0) if not found; true (1) if deleted */ int removeNode (LIST *pList, void *keyPtr, void **dataOutPtr) { /* Local Declarations */ int found; NODE *pPre; NODE *pLoc; /* Statements */ found = _search (pList, &pPre, &pLoc, keyPtr); if (found) _delete (pList, pPre, pLoc, dataOutPtr); return found; } /* removeNode */ /* =============== _delete ============== */ /* Deletes data from a linked list and returns pointer to data to calling module. Pre pList is a pointer to a valid list. pPre is a pointer to predecessor node pLoc is a pointer to target node dataOutPtr is pointer to data pointer Post Data have been deleted and returned Data memory has been freed */ void _delete (LIST *pList, NODE *pPre, NODE *pLoc, void **dataOutPtr) { /* Statements */ *dataOutPtr = pLoc->dataPtr; if (pPre == NULL) /* Deleting first node */ pList->head = pLoc->link; else /* Deleting any other node */ pPre->link = pLoc->link; /* Test for deleting last node */ if (pLoc->link == NULL) pList->rear = pPre; (pList->count)--; free (pLoc); return; } /* _delete */ /* =============== searchList ============== */ /* Interface to search function. Pre pList is a pointer to an initialized list. pArgu is pointer to key being sought Post pDataOut contains pointer to found data -or- NULL if not found Return boolean true if successful, false if not found. */ int searchList (LIST *pList, void *pArgu, void **pDataOut) { /* Local Declarations */ int found; NODE *pPre; NODE *pLoc; /* Statements */ found = _search (pList, &pPre, &pLoc, pArgu); if (found) *pDataOut = pLoc->dataPtr; else *pDataOut = NULL; return found; } /* searchList */ /* =============== _search ============== */ /* Searches list and passes back address of node containing target and its logical predecessor. Pre pList is a pointer to an initialized list. pPre is pointer variable to receive predecessor pLoc is pointer variable to receive node pArgu is pointer to key being sought Post pLoc points to first node equal/greater key -or- null if target > key of last node pPre points to largest node smaller than key -or- null if target < key of first node Return boolean true if successful, false if not found. */ int _search (LIST *pList, NODE **pPre, NODE **pLoc, void *pArgu) { /* Macro Definition */ #define COMPARE (((* pList->compare) (pArgu, (*pLoc)->dataPtr))) #define COMPARE_LAST ((* pList->compare) (pArgu, pList->rear->dataPtr)) /* Local Declarations */ int result; /* Statements */ *pPre = NULL; *pLoc = pList->head; if (pList->count == 0) return 0; /* Test for argument > last node in list */ if ( COMPARE_LAST > 0) { *pPre = pList->rear; *pLoc = NULL; return 0; } /* if */ while ( (result = COMPARE) > 0 ) { /* Have not found search argument location */ *pPre = *pLoc; *pLoc = (*pLoc)->link; } /* while */ if (result == 0) /* argument found--success */ return 1; else return 0; } /* _search */ /* =============== retrieveNode ============== */ /* This algorithm retrieves data in the list without changing the list contents. Pre pList is a pointer to an initialized list. pArgu is a pointer to key of data to be retrieved Post Data (pointer) passed back to caller Return boolean true if successful, false if underflow. */ static int retrieveNode (LIST *pList, void *pArgu, void **dataOutPtr) { /* Local Declarations */ int found; NODE *pPre; NODE *pLoc; /* Statements */ found = _search (pList, &pPre, &pLoc, pArgu); if (found) { *dataOutPtr = pLoc->dataPtr; return 1; } /* if */ *dataOutPtr = NULL; return 0; } /* retrieveNode */ /* =============== emptyList ============== */ /* Returns boolean indicating whether or not the list is empty Pre pList is a pointer to a valid list Return boolean true if empty, false if list has data */ int emptyList (LIST *pList) { /* Statements */ return (pList->count == 0); } /* emptyList */ /* =============== fullList ============== */ /* Returns boolean indicating no room for more data. The list is full if memory cannot be allocated for another node. Pre pList is a pointer to a valid list Return boolean true if full, false if room for another node. */ int fullList (LIST *pList) { /* Local Declarations */ NODE *temp; /* Statements */ if ((temp = (NODE *)malloc (sizeof (NODE)))) { free (temp); return 0; } /* Dynamic memory full */ return 1; } /* fullList */ /* =============== listCount =============== */ /* Returns integer representing number of nodes in list. Pre pList is a pointer to a valid list Return count for number of nodes in list */ int listCount(LIST *pList) { /* Statements */ return pList->count; } /* listCount */ /* =============== traverse ============== */ /* Traverses a linked list. Each call either starts at the beginning of list or returns the location of the element in the list that was last returned. Pre pList is a pointer to a valid list fromWhere is 0 to start at the first element dataPtrOut is address of a pointer to data Post if another element, address placed in dataPtr Return true if another element located, false if end of list */ int traverse (LIST *pList, int fromWhere, void **dataPtrOut) { /* Local Declarations */ int success; /* Statements */ if (fromWhere == 0) { /*Start from first node */ if (pList->count == 0) success = 0; else { pList->pos = pList->head; *dataPtrOut = pList->pos->dataPtr; success = 1; } /* if else */ } /* if fromwhere */ else { /* Start from current position */ if (pList->pos->link == NULL) success = 0; else { pList->pos = pList->pos->link; *dataPtrOut = pList->pos->dataPtr; success = 1; } /* if else */ } /* if fromwhere else */ return success; } /* traverse */ /* =============== destroyList ============== */ /* Deletes all data in list and recycles memory Pre List is a pointer to a valid list. Post All data and head structure have been deleted. Return null head pointer */ LIST *destroyList (LIST *pList) { /* Local Declarations */ NODE *deletePtr; /* Statements */ if (pList) { while (pList->count > 0) { /* First delete data */ free (pList->head->dataPtr); /* Now delete node */ deletePtr = pList->head; pList->head = pList->head->link; pList->count--; free (deletePtr); } free (pList); } /* if */ return NULL; } /* destroyList */ leap_frog/src/include/proto.h100664 764 764 3445 6771555324 14425 0ustar awrawr/* Protos */ #define VERBOSE 1 // files.c extern int read_in(struct frog *p); extern int write_out(struct frog *p); extern int read_modify_write(struct frog *p); // from main extern struct command all[]; extern struct terminal terms[]; extern pthread_mutex_t linked_list; extern int input(struct frog *p); // color.c extern char *getcolor(FROG *p, char col); extern int valid_char_col(char ctest); extern char *review_sendfd(FROG *p, char *str); /* link.c */ int Compare(void *p1,void *p2); /* link.h */ extern struct frog *start; extern struct frog *last; extern struct frog *find(char *); extern int match(struct frog *p, char *str); extern struct frog frog_struct; extern struct note_struct notes; extern struct player_t players_t; extern int current_online; extern struct saved_player *start_saved; extern struct saved_player *last_saved; /* strings.c */ extern void SENDFD(struct frog *p, char *format, ...); extern char *word_time(int t); extern void password_mode_on(struct frog *p); extern void password_mode_off(struct frog *p); extern char *parse(char *line, int count, char *st); extern void view_commands(struct frog *p, char *str); extern char *astrstrb(char *s,char *t); extern int do_match(struct frog *p, char *str, struct command *com_entry); /*main*/ extern int RAMUSED; int do_match(struct frog *p, char *str, struct command *com_entry); extern void execute_command(struct frog *p, struct command *com, char *str, int command); extern void _tell(struct frog *p, char *str); extern void send_fd(struct frog *p, char *str); extern void close_socket(struct frog *current); extern void view_history(struct frog *p, char *str); void log_file(char *file, char *string, ...); extern char *word_time(int t); /* commands */ void cls(struct frog *p, char *str); leap_frog/src/include/version.h100640 764 764 112 6771536617 14711 0ustar awrawr/* version file */ #define VERSION "1.0" #define VERSION_DATE "09/21/99" leap_frog/src/include/originalconfig.h100640 764 764 227 6772162053 16213 0ustar awrawr//#define LINUX 1 //#define SOLARIS 2 #ifdef LINUX #define GLIBC 1 #define REDHAT5 1 #endif #define USERS_ADDRESS_FILE "users_ip" #define LOGGING 1 leap_frog/src/color.c100664 764 764 5647 6771535761 12761 0ustar awrawr// this file is for generating colors to te users session // valid colors #include "include/link.h" #include "include/proto.h" #include char *getcolor(FROG *p, char col); int valid_char_col(char ctest); char *review_sendfd(FROG *p, char *str); // standard format is ^GFrog would show Frog in the color green // now this assumes that the term is set to accept color, if not // the color will be bolded int valid_char_col(char ctest) { ctest = tolower(ctest); if (ctest == 'a' || ctest == 'b' || ctest == 'c' || ctest == 'g' || ctest == 'h' || ctest == 'i' || ctest == 'k' || ctest == 'n' || ctest == 'p' || ctest == 'r' || ctest == 's' || ctest == 'u' || ctest == 'y') return 1; return 0; } // go through the color patterns char *getcolor(FROG *p, char col) { switch (col) { case 'a': return "\033[1;30m"; break; case 'A': return "\033[0;37m"; break; case 'b': return "\033[0;34m"; break; case 'B': return "\033[1;34m"; break; case 'c': return "\033[0;36m"; break; case 'C': return "\033[1;36m"; break; case 'g': return "\033[0;32m"; break; case 'G': return "\033[1;32m"; break; case 'I': case 'i': return "\033[7m"; break; case 'K': case 'k': return "\033[5m"; break; case 'N': case 'n': return terms[(p->term-1)].off; break; case 'p': return "\033[0;35m"; break; case 'P': return "\033[1;35m"; break; case 'r': return "\033[0;31m"; break; case 'R': return "\033[1;31m"; break; case 'U': case 'u': return "\033[4m"; break; case 'S': case 's': return "\033[3m"; break; case 'H': case 'h': return "\033[0;1m"; break; case 'y': return "\033[0;33m"; break; case 'Y': return "\033[1;33m"; break; } return ""; } // check the send to fd to strip out any ^? color codes char *review_sendfd(FROG *p, char *str) { char *start1,*start2,*str2; char col_buf[15]; int x; start1=str; str2=p->totell; start2=str2; strcpy(col_buf,getcolor(p,'N')); if (strlen(col_buf)>0) for (x=0;xterm!=11) // java { if (valid_char_col(*str)) { strcpy(col_buf,getcolor(p,*str)); if (strlen(col_buf)>0) for (x=0;x0) for (x=0;x int Compare(void *p1,void *p2); // all you need to do is have the compare check for whatever you are comparing....*>?? int Compare(void *p1,void *p2) { if (!strcasecmp((( *)p1)->to,((MAIL *)p2)->to)) return 1; else return 0; } leap_frog/src/main.c100664 764 764 120471 6771741375 12620 0ustar awrawr/* Leap Frog Program www.cotse.com DISCLAIMER: This program is meant for educational purposes only, it is not intended to be a hacking tool. Breif Description: This is a simple proxing telnet server.... There are a lot of mem extras in which I need to remove, as well as multiple close calls. I have not done so yet....The program should run with 10-20 connections at .02-.04 % and should take about ~ 2mb... Written by: Bert... Use at your own discretion.... This software is not intended to be a "hacking" tool, it is merley a nice portal for Sys admins, and programmers alike....It is also a building block for C programming to network ports And it is also a nice interface for connection of multi ip's as it is a threaded app You can use this code as long as the previous disclaimer is intact and left as is Modifications: None Yet Code within written by: Bert (with the exception of the linked_list functions, why re-invent the wheel) Notice that i have also include the color.c file which enables you (if the term allows colors) to send to the users terminal color/highlight/blinks/etc via the send_fd,SENDFD (send to file descriptor) Also if you want to make a little more fucntionality, that is if you want to have functions in which the users can access while connected follow the command strcut and add the functions as done withe the command_func from link.h f()() is all, Follow the all[] array and the foramt i have created, nothing tricky here. You can use the input( arg ) function (takes a struct frog *). Just follow the examples I have created in the port+1 section of the code. Get input gets keyed/data input and returns 1 on good input and -1 if the user has not hit a key within 30seconds (timeout). Linked_list taken from: Brooks/Cole Publishing Company, see linked_list.h for disclaimer To change port to bind to edit include/config.h for user configs and then run make again NOTES: if you are going through a firewall connections may need to go through opened firewall ports WISH LIST: Next version I will clean up the code, and allow the user to drop to a shell localy Also I will create a nice admin interface on the port+1 to do local things... Web Site: www.cotse.com */ /* server */ /* #define _REENTRANT */ #include "include/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef SOLARIS #include #endif #include #include "include/link.h" #include "include/linked_list.h" #include "include/proto.h" #include "include/version.h" // the old redhat4 defs go back to previos redhat implentations before pthreads came standard #ifdef REDHAT4 #include #endif #ifdef REDHAT5 #include #endif #define IPROTO 0 #ifdef SOLARIS extern int close (int); extern int socket (int, int, int); #if !defined(LINUX) //extern int getsockopt (int, int, int, char *, int *); extern void bzero (char *, int); #endif /* LINUX */ extern int listen (int, int); #endif /* SOLARIS */ /* Local Function Prototypes */ char *first_char(char *line); void init_socket(int port); void who(struct frog *p, char *str); void send_fd(struct frog *p, char *str); void cls(struct frog *p, char *str); void close_socket(struct frog *current); void get_input(struct frog *current); void show_login(struct frog *p); void password_mode_on(struct frog *p); void password_mode_off(struct frog *p); void do_prompt(struct frog *p); void hitells(struct frog *p, char *str); void shut_down(struct frog *p, char *str); void time_logged_in(struct frog *p, int x); void init_signals(); void log_file(char *file, char *string, ...); void alive_connect(void); char *sys_time(void); int input(struct frog *p); struct terminal terms[] = { {"xterm", "\033[1m", "\033[m", "\033[H\033[2J"}, {"vt220", "\033[1m", "\033[m", "\033[H\033[J"}, {"vt100", "\033[1m", "\033[m", "50\033[;H\0332J"}, {"vt102", "\033[1m", "\033[m", "50\033["}, {"ansi", "\033[1m", "\033[0m", "50\033[;H\0332J"}, {"wyse-30", "\033G4", "\033G0", ""}, {"tvi912", "\033l", "\033m", "\032"}, {"sun", "\033[1m", "\033[m", "\014"}, {"adm", "\033)", "\033(", "1\032"}, {"hp2392", "\033&dB", "\033&d@", "\033H\033J"}, {"java","","",""}, {0, "", "", ""} }; // struct to hold any function calls made by connected, will work for admin tools struct command all[] = { {"cls",cls,0,0,0,0}, {"help",view_commands,0,0,0,0}, {"time",time_up,0,0,0,0}, {0, 0, 0, 0, 0, 0, 0} }; /* Local/global Variables */ int RAMUSED; int mainsock; pid_t pid; FILE *wt; int in_current=0; int in_pack_current=0; int out_current=0; int out_pack_current=0; int logins; int current_online; int alive_descriptor; // mutexs not used in this program, can be used though pthread_mutex_t linked_list = PTHREAD_MUTEX_INITIALIZER; void* serverWatch( void* ); void* serverClient( struct player_t *p_t); void* configWatch( void* ); void* configClient( struct player_t *p_t); // port to def listen on int main_descriptor; // port to def+1 listen on config thread int config_descriptor; // time value time_t timeval; int main ( void ) { pthread_t watcher_thr,watcher_thr2; RAMUSED=0; log_file("server","Trying to connect to port....\n"); if (VERBOSE) printf("trying to connect to port..\n"); // init the socket for use on SERVERPORT init_socket(SERVERPORT); // create thread for def port pthread_create(&watcher_thr,NULL,serverWatch,(void*)NULL); // create thread for def+1 port config thread we pass null b/c we have nothing to pass pthread_create(&watcher_thr2,NULL,configWatch,(void*)NULL); /* random number generation */ srand((unsigned int)getpid()); // Start our signal Handlers init_signals(); for (;;) { // we will sleep here for 30 minutes then will sync all files at that time // that is 1800 seconds == 30 mins sleep(1800); if (1) { // do whatever in here I write out to a log for sanity every 30mins log_file("sync.fil","Sanity\n"); } else { // ditto log_file("sync.fil","Ratts No Sanity?\n"); } } exit(0); } /* log files */ void log_file(char *file, char *string, ...) { va_list argnum; char stack[255],data[255]; int fd, length; // they dont/do want logging #if !defined(LOGGING) return; #endif va_start(argnum, string); vsprintf(data,string,argnum); va_end(argnum); sprintf(stack, "%slogs/%s.log", ROOT, file); fd = open(stack, O_CREAT | O_WRONLY | O_SYNC, S_IRUSR | S_IWUSR); length = lseek(fd, 0, SEEK_END); write(fd, data, strlen(data)); close(fd); } /* not areal lot done here just old style signal handler */ void sig_exit(int crap) { char buf[255]; if (VERBOSE) printf("Signal Caught sig_exit. Exiting Cleanly.\n"); sprintf(buf,"Signal %d caught sig_exit exiting cleanly?\n",crap); log_file("signals",buf); } void sig_segv(int crap) { char buf[255]; if (VERBOSE) printf("Segmentation Violation Caught. Exiting Cleanly\n"); sprintf(buf,"Signal %d caught exiting cleanly? Seg Violation\n",crap); log_file("signals",buf); // lets try to sync all the files now.... pthread_mutex_unlock(&linked_list); exit(crap); } void sig_kill(int crap) { char buf[255]; if (VERBOSE) printf("Signal %d caught, Kill caught, exiting cleanly?\n",crap); sprintf(buf,"Signal %d caught, Kill caught, exiting cleanly?\n",crap); log_file("signals",buf); exit(crap); return; } void sig_usr(int crap) { char buf[255]; if (VERBOSE) printf("Signal %d caught, sig usr 1 or 2 or neither, exiting cleanly?\n",crap); if ((crap==SIGUSR1)) sprintf(buf,"Signal %d caught, sig usr2, exiting cleanly?\n",crap); else if ((crap==SIGUSR2)) sprintf(buf,"Signal %d caught, sig usr2, exiting cleanly?\n",crap); else sprintf(buf,"Signal %d caught, in sig usr neither 1 or 2, exiting cleanly?\n",crap); log_file("signals",buf); exit(crap); return; } void sig_pipe(int crap) { if (VERBOSE) printf("SIGPIPE CAUGHT\n"); log_file("signals","SIGPIPE error ratts"); signal(SIGPIPE,sig_pipe); return; } void sig_term(int crap) { if (VERBOSE) printf("SIGTERM CAUGHT\n"); log_file("signals","SIGTERM error ratts"); signal(SIGTERM,sig_term); return; } void init_signals() { signal(SIGPIPE, sig_pipe); signal(SIGHUP, sig_exit); signal(SIGINT, sig_exit); signal(SIGQUIT, sig_exit); signal(SIGILL, sig_exit); signal(SIGTRAP, sig_exit); signal(SIGIOT, sig_exit); signal(SIGBUS, sig_exit); signal(SIGFPE, sig_exit); signal(SIGKILL, sig_kill); signal(SIGSEGV, sig_segv); signal(SIGALRM, sig_exit); signal(SIGTERM, sig_term); signal(SIGCHLD, sig_exit); signal(SIGCONT, sig_exit); signal(SIGSTOP, sig_exit); signal(SIGTSTP, sig_exit); signal(SIGTTIN, sig_exit); signal(SIGTTOU, sig_exit); signal(SIGURG, sig_exit); signal(SIGXCPU, sig_exit); signal(SIGXFSZ, sig_exit); signal(SIGVTALRM, sig_exit); signal(SIGPROF, sig_exit); signal(SIGWINCH, sig_exit); signal(SIGIO, sig_exit); signal(SIGPWR, sig_exit); } // initilize the main socket void init_socket(int port) { struct sockaddr_in main_socket, config_socket; int dummy = 1,dummy_2=1,config_port; char *hostname; struct hostent *hp; /* grab the main socket */ hostname=(char *)malloc(101); RAMUSED+=sizeof(hostname); bzero((char *)&main_socket, sizeof(struct sockaddr_in)); bzero((char *)&config_socket, sizeof(struct sockaddr_in)); gethostname(hostname,100); hp=gethostbyname(hostname); if ( hp == NULL) { printf("Error: Host machine does not exist!\n"); } main_socket.sin_family=hp->h_addrtype; main_socket.sin_port=htons(port); config_socket.sin_family=hp->h_addrtype; config_port=port+1; config_socket.sin_port=htons(config_port); main_descriptor = socket(AF_INET, SOCK_STREAM, IPROTO); if (main_descriptor < 0) { printf("Couldn't grab main socket!!!\n"); exit(-1); } config_descriptor = socket(AF_INET, SOCK_STREAM, IPROTO); if (config_descriptor < 0) { printf("Couldn't grab config socket!!!\n"); exit(-1); } if (setsockopt(main_descriptor, SOL_SOCKET, SO_REUSEADDR, (char *) &dummy, sizeof(dummy)) < 0) printf("Couldn't setsockopt() main\n"); if (setsockopt(config_descriptor, SOL_SOCKET, SO_REUSEADDR, (char *) &dummy_2, sizeof(dummy_2)) < 0) printf("Couldn't setsockopt() config\n"); // we do not need to set it non block but here is the code to do it att & bsd /* flags=fcntl(main_descriptor,F_GETFL,0); fcntl(main_descriptor,F_SETFL,O_NONBLOCK|flags); if (ioctl(main_descriptor, FIONBIO, &dummy) < 0) printf("Can't set non-blocking\n"); */ if (bind(main_descriptor, (struct sockaddr *) & main_socket, sizeof(main_socket)) < 0) { if (VERBOSE) printf("Couldn't bind main socket!!! ... check if something is already listening on that port!\n"); log_file("server","Couldn't bind main socket!!! ... check if something is alreadyn listening on that port!\n"); exit(-2); } if (bind(config_descriptor, (struct sockaddr *) & config_socket, sizeof(config_socket)) < 0) { if (VERBOSE) printf("Couldn't bind config socket!!! ... check if something is already listening on that port!\n"); log_file("server","Couldn't bind config socket!!! ... check if something is alreadyn listening on that port!\n"); exit(-2); } if (listen(main_descriptor, 5) < 0) printf("Listen refused main\n"); if (listen(config_descriptor, 5) < 0) printf("Listen refused config\n"); pid=getpid(); (void)time(&timeval); if (VERBOSE) { printf ("\n\nServer %s's main socket is set to receive on port - %d pid =%d\n", hostname,port,(int)pid); printf("starting date and time %s \n",ctime(&timeval)); printf("\n\nServer Config socket is set to receive on port %d\n",port+1); } log_file("server","\n\nServer %s's main socket is set to receive on port - %d pid =%d\n", hostname,port,pid); log_file("server","\n\nServer Config is set to receive on port %d\n",port+1); log_file("server","starting date and time : %s \n",ctime(&timeval)); } // config descriptor thread void* configWatch(void* dummy) { pthread_t dummy_thr; int accepted_socket; int test,size; struct sockaddr_in accept_addr; struct player_t *passed_t; struct hostent *addy; fd_set read_set; int ready_fd; test=0; // loop forever for (;;) { /* wait for client to connect up */ // dont forget to zero out the set and reset what we are looking for every time we go into the loop FD_ZERO(&read_set); FD_SET(config_descriptor, &read_set); // listen on the main socket and wait for someone to connect // bc we are threaded block, non block is not important do { ready_fd= select(FD_SETSIZE, &read_set, NULL,NULL,NULL); } while (ready_fd<=0 || !FD_ISSET(config_descriptor, &read_set)); /* client has now connected */ /* pass a thread data structure to the thread instead of just the fd */ passed_t=(struct player_t *)malloc(sizeof(players_t)); RAMUSED+=sizeof(passed_t); size = sizeof(accept_addr); accepted_socket = accept(config_descriptor, (struct sockaddr*)&accept_addr, &size); passed_t->socket=accepted_socket; strcpy(passed_t->sin_addr,inet_ntoa(accept_addr.sin_addr)); addy=(void *)0; addy = gethostbyaddr((char *) &(accept_addr.sin_addr.s_addr), sizeof(accept_addr.sin_addr.s_addr), AF_INET); if (addy) passed_t->numerical_address = strdup(addy->h_name); else passed_t->numerical_address = passed_t->sin_addr; /* your pid */ passed_t->pid=getpid(); /* create a new thread and pass the thread data structure we created to it..nice way to encapsulate data */ // we dont care about thread syncing per-se that is why we are not keeping track in any conventional manner pthread_create(&dummy_thr, NULL, (void *) configClient, (struct player *) passed_t); } } // main descriptor thread void* serverWatch(void* dummy) { pthread_t dummy_thr; int accepted_socket; int test,size; struct sockaddr_in accept_addr; struct player_t *passed_t; struct hostent *addy; fd_set read_set; int ready_fd; test=0; // loop forever for (;;) { /* wait for client to connect up */ // dont forget to zero out the set and reset what we are looking for every time we go into the loop FD_ZERO(&read_set); FD_SET( main_descriptor, &read_set); // listen on the main socket and wait for someone to connect // bc we are threaded block, non block is not important do { ready_fd= select(FD_SETSIZE, &read_set, NULL,NULL,NULL); } while (ready_fd<=0 || !FD_ISSET(main_descriptor, &read_set)); /* client has now connected */ /* pass a thread data structure to the thread instead of just the fd */ passed_t=(struct player_t *)malloc(sizeof(players_t)); RAMUSED+=sizeof(passed_t); size = sizeof(accept_addr); accepted_socket = accept(main_descriptor, (struct sockaddr*)&accept_addr, &size); passed_t->socket=accepted_socket; strcpy(passed_t->sin_addr,inet_ntoa(accept_addr.sin_addr)); addy=(void *)0; addy = gethostbyaddr((char *) &(accept_addr.sin_addr.s_addr), sizeof(accept_addr.sin_addr.s_addr), AF_INET); if (addy) passed_t->numerical_address = strdup(addy->h_name); else passed_t->numerical_address = passed_t->sin_addr; /* your pid */ passed_t->pid=getpid(); /* create a new thread and pass the thread data structure we created to it..nice way to encapsulate data */ // we dont care about thread syncing per-se that is why we are not keeping track in any conventional manner pthread_create(&dummy_thr, NULL, (void *) serverClient, (struct player *) passed_t); } } /* config client to the socket for configuration issues */ void* configClient(struct player_t *p_t) { int dummy = 1; struct frog *p; time_t time_now; char hostname[101]; char host_name[20]; int y,x; int run_command; logins++; /* set non blocking of io */ if (ioctl(p_t->socket, FIONBIO, &dummy) < 0) printf("Can't set non-blocking\n"); gethostname(hostname,100); x=0; while(xstack=(char *)malloc(200*sizeof(char)); p->totell=(char *)malloc(200*sizeof(char)); /* zero them out now */ memset(p, 0, sizeof(p)); /* get ip# and hostname if they have one */ strcpy(p->num_addr,p_t->sin_addr); strncpy(p->inetaddr, p_t->numerical_address, 50 - 2); (void *)p->socket=(void *)p_t->socket; p->term=1; p->oldstack=p->stack; /* log every connection */ (void)time(&time_now); log_file("config_logins","server name:%s inet addr:%s - %s",p->name,p->inetaddr,ctime(&time_now)); send_fd(p,"\n\n\t\t\tWelcome To ^GLeap Frog^N:\n"); send_fd(p,"\n\n\t\t^Gwww.cotse.com^N (^GC^Nhurch ^GO^Nf"); send_fd(p," ^GT^Nhe ^GS^Nwimming ^GE^Nlephant)\n\n"); send_fd(p,"\tNOTE: You have connected to the configuration utility\n"); send_fd(p,"\tThe New configuration (if it can be resolved) will be cached\n"); send_fd(p,"\tIf this is the first time you are connecting (resolved queries) will be cached\n"); send_fd(p,"\nPlease enter Server and port (default is 23) Followed by a carriage return\n"); send_fd(p,"Help is Available: type -> help\n"); send_fd(p,"Example foo.bar.com 4365\n\n"); run_command=0; while(run_command>-1) { send_fd(p,"Type In server and port to ^GLeap Frog^N To\n> "); if(!(input(p))) { free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } if (p->flags & PANIC) { free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } x=0; while(xbuffer) && p->buffer[x]!=' ') p->name[x]=p->buffer[x++]; p->name[x]='\0'; if (!strcasecmp(p->name,"quit")) { free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } // here is where you can check for commands a function would be better, but i will do it here for now run_command=do_match(p,p->buffer,all); if (run_command>-1) execute_command(p, all, " ", run_command); } y=0; while (xbuffer) && p->buffer[x]==' ') x++; while(xbuffer) && p->buffer[x]!=' ') p->port[y++]=p->buffer[x++]; p->port[y]='\0'; p->remote_port=atoi(p->port); if (p->remote_port==0) p->remote_port=23; SENDFD(p,"ok trying %s %d\nPlease Wait connecting\n",p->name,p->remote_port); // now lets do the connection to the desired location // we cannot let them log back into us p->temp_long=inet_addr(p->name); if (!(p->host_entry = gethostbyname(p->name)) && !(p->host_entry = gethostbyaddr((char *)&p->temp_long, 4, AF_INET))) { if (p->name) SENDFD(p,"The address %s you have given could not be resolved\n",p->name); else send_fd(p,"Could not resolve that address\n"); (void)time(&time_now); log_file("failed_connect","addr:%s could not connect to %s - %s",p->inetaddr,(p->name ? p->name : "NO NAME"),ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } p->host_entry_add=gethostbyaddr((char *)&p->temp_long, 4, AF_INET); if (p->name) { if (!strcasecmp((char *)p->name, hostname) || !strcasecmp((char *)p->name,host_name) || !strcasecmp((char *)p->name,"localhost")) { SENDFD(p,"Sorry But you cannot connect back to me!\n"); (void)time(&time_now); log_file("reconnect","server name:%s inet addr:%s attempted to reconnect to us - %s",p->name,p->inetaddr,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } } else if (!strcasecmp((char *)p->host_entry_add,p->inetaddr)) { SENDFD(p,"Sorry But you cannot connect back to me!\n"); (void)time(&time_now); log_file("reconnect","server name:%s inet addr:%s attempted to reconnect to us - %s",p->name,p->inetaddr,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } (void)time(&time_now); log_file("login_attempt","server name:%s is attempting to connect to %s on port %d - %s",p->inetaddr,p->name,p->remote_port,ctime(&time_now)); if ((p->remote_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { SENDFD(p,"Ratts Could not get socket()\n"); (void)time(&time_now); log_file("socket","Could not get socket - %s",ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } p->remote_addr.sin_family = p->host_entry->h_addrtype; p->remote_addr.sin_port = htons(p->remote_port); memcpy(&p->remote_addr.sin_addr, p->host_entry->h_addr, p->host_entry->h_length); p->address.sin_family=AF_INET; p->address.sin_port=p->remote_port; p->address.sin_addr=*(struct in_addr *)*p->host_entry->h_addr_list; if (connect(p->remote_sock, (struct sockaddr *)&p->remote_addr, sizeof(p->remote_addr))) { SENDFD(p,"Could not connect to %s on port %d\n",p->name,p->remote_port); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } (void)time(&time_now); // close this fd close(p->remote_sock); SENDFD(p,"Got A good connection to %s on port %d\n",p->name,p->remote_port); if(read_modify_write(p)) { send_fd(p,"Cached Data\n"); SENDFD(p,"To get to the ^GLeap Frog^N\n"); SENDFD(p,"Type: ^Rtelnet %s %d^N\n",hostname,SERVERPORT); } else send_fd(p,"Sorry could not update/add cache\n"); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } int input(struct frog *p) { double idle_out; time_t time_now; fd_set my_set; // select static struct timeval timeout; // select call int my_fd; // select p->count=0; p->idle=time((time_t *)0); p->flags &= ~(LAST_CHAR_WAS_R | LAST_CHAR_WAS_N); while (!(p->flags & LAST_CHAR_WAS_N)) { do { FD_ZERO(&my_set); FD_SET( p->socket, &my_set); timeout.tv_sec=(long)0; timeout.tv_usec=(long)3; // this seems like enough time my_fd= select(FD_SETSIZE, &my_set, NULL,NULL,&timeout); if ((idle_out=difftime(time((time_t *)0),p->idle))>30) // 30 secs before you idle out { (void)time(&time_now); log_file("idle_out","server name:%s inet addr:%s idled out - %s",p->name,p->inetaddr,ctime(&time_now)); send_fd(p,"Sorry But you are not going to suck up a line on me 30sec idleout\n"); p->flags|=PANIC; p->booted=1; return -1; } } while (my_fd<=0 || !FD_ISSET(p->socket, &my_set)); // stuf is wating now get it get_input(p); } // just to tiddy up p->flags &= ~(LAST_CHAR_WAS_R | LAST_CHAR_WAS_N); p->count=0; return 1; } /* serve the client on the spec socket from thread call */ void* serverClient( struct player_t *p_t) { int count; struct frog *p; time_t time_now; char buf[4096]; fd_set my_set; // select static struct timeval timeout; // select call int my_fd; // select double idle_out; int x,y; int dummy = 1; char hostname[101]; char host_name[20]; char stack[255]; int found=0; logins++; gethostname(hostname,100); x=0; while(xsocket, FIONBIO, &dummy) < 0) printf("Can't set non-blocking\n"); count=1; p=(struct frog*)malloc(sizeof(FROG)); p->stack=(char *)malloc(200*sizeof(char)); p->totell=(char *)malloc(200*sizeof(char)); /* zero them out now */ memset(p, 0, sizeof(p)); /* get ip# and hostname if they have one */ strcpy(p->num_addr,p_t->sin_addr); strncpy(p->inetaddr, p_t->numerical_address, 50 - 2); (void *)p->socket=(void *)p_t->socket; p->term=1; p->oldstack=p->stack; /* log every connection */ (void)time(&time_now); log_file("logins","server name:%s inet addr:%s - %s",p->name,p->inetaddr,ctime(&time_now)); // lets see if they have connected to us before sprintf(stack,"%s/files/%s",ROOT,USERS_ADDRESS_FILE); if (read_in(p)) { found=1; p->flags &= ~ _VERBOSE; } else { found=0; p->flags |=_VERBOSE; } // my intro message if (p->flags & _VERBOSE) { SENDFD(p,"\t\tWelcome to ^GLeap Frog^N\n\n"); send_fd(p,"\n\n\t\t^Gwww.cotse.com^N (^GC^Nhurch ^GO^Nf"); send_fd(p," ^GT^Nhe ^GS^Nwimming ^GE^Nlephant)\n\n"); } if (p->flags & _VERBOSE) send_fd(p,"Enter Location and port (default is 23) to telnet to followed by enter.\nExample: foo.bar.com 8976\n"); // read data from session opened p->count=0; p->idle=time((time_t *)0); p->flags &= ~(LAST_CHAR_WAS_R | LAST_CHAR_WAS_N); if (!found) { while (!(p->flags & LAST_CHAR_WAS_N)) { do { FD_ZERO(&my_set); FD_SET( p->socket, &my_set); timeout.tv_sec=(long)0; timeout.tv_usec=(long)3; // this seems like enough time my_fd= select(FD_SETSIZE, &my_set, NULL,NULL,&timeout); if ((idle_out=difftime(time((time_t *)0),p->idle))>30) // 30 secs before you idle out { (void)time(&time_now); log_file("idle_out","server name:%s inet addr:%s idled out - %s",p->name,p->inetaddr,ctime(&time_now)); send_fd(p,"Sorry But you are not going to suck up a line on me 30sec idleout\n"); p->flags|=PANIC; p->booted=1; free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; break; } } while (my_fd<=0 || !FD_ISSET(p->socket, &my_set)); // ok now get the input from the fd get_input(p); } // just to tiddy up p->flags &= ~(LAST_CHAR_WAS_R | LAST_CHAR_WAS_N); p->count=0; // get the host/port now x=0; while(xbuffer) && p->buffer[x]!=' ') p->name[x]=p->buffer[x++]; p->name[x]='\0'; y=0; while (xbuffer) && p->buffer[x]==' ') x++; while(xbuffer) && p->buffer[x]!=' ') p->port[y++]=p->buffer[x++]; p->port[y]='\0'; p->remote_port=atoi(p->port); if (p->remote_port==0) p->remote_port=23; } // end of not found // now lets resolve the desired address // we cannot let them log back into us p->temp_long=inet_addr(p->name); if (!(p->host_entry = gethostbyname(p->name)) && !(p->host_entry = gethostbyaddr((char *)&p->temp_long, 4, AF_INET))) { if (p->name) SENDFD(p,"The address %s you have given could not be resolved\n",p->name); else send_fd(p,"Could not resolve that address\n"); (void)time(&time_now); log_file("failed_connect","addr:%s could not connect to %s - %s",p->inetaddr,(p->name ? p->name : "NO NAME"),ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } p->host_entry_add=gethostbyaddr((char *)&p->temp_long, 4, AF_INET); if (p->name) { if (!strcasecmp((char *)p->name, hostname) || !strcasecmp((char *)p->name,host_name) || !strcasecmp((char *)p->name,"localhost")) { SENDFD(p,"Sorry But you cannot connect back to me!\n"); (void)time(&time_now); log_file("reconnect","server name:%s inet addr:%s attempted to reconnect to us - %s",p->name,p->inetaddr,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } } else if (!strcasecmp((char *)p->host_entry_add,p->inetaddr)) { SENDFD(p,"Sorry But you cannot connect back to me!\n"); (void)time(&time_now); log_file("reconnect","server name:%s inet addr:%s attempted to reconnect to us - %s",p->name,p->inetaddr,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } if (p->flags & _VERBOSE) SENDFD(p,"Attempting a connection to %s on port %d\nPlease Wait...\n",p->name,p->remote_port); (void)time(&time_now); log_file("login_attempt","server name:%s is attempting to connect to %s on port %d - %s",p->inetaddr,p->name,p->remote_port,ctime(&time_now)); if ((p->remote_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { SENDFD(p,"Ratts Could not get socket()\n"); (void)time(&time_now); log_file("socket","Could not get socket - %s",ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } p->remote_addr.sin_family = p->host_entry->h_addrtype; p->remote_addr.sin_port = htons(p->remote_port); memcpy(&p->remote_addr.sin_addr, p->host_entry->h_addr, p->host_entry->h_length); p->address.sin_family=AF_INET; p->address.sin_port=p->remote_port; p->address.sin_addr=*(struct in_addr *)*p->host_entry->h_addr_list; if (connect(p->remote_sock, (struct sockaddr *)&p->remote_addr, sizeof(p->remote_addr))) { SENDFD(p,"Could not connect to %s on port %d\n",p->name,p->remote_port); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } p->remote2_sock=p_t->socket; (void)time(&time_now); log_file("login_success","server %s logged into %s port %d - %s",p->inetaddr,p->name,p->remote_port,ctime(&time_now)); // enter the connect loop // if not originally found then log it if (!found) { write_out(p); } while (1) { FD_ZERO(&p->select_1); FD_ZERO(&p->select_2); FD_SET(p->remote2_sock,&p->select_1); FD_SET(p->remote2_sock,&p->select_2); FD_SET(p->remote_sock,&p->select_1); FD_SET(p->remote_sock,&p->select_2); if (select(20, &p->select_1, NULL, &p->select_2, NULL) == -1) { free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } if (FD_ISSET(p->remote2_sock,&p->select_1) || FD_ISSET(p->remote2_sock,&p->select_2)) { if ((p->bytes_read = read(p->remote2_sock,buf,4096)) <= 0) { (void)time(&time_now); log_file("closed_socket","closed socket for %s connect to %s - %s",p->inetaddr,p->name,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); pthread_exit(NULL); return 0; } if ((write(p->remote_sock,buf,p->bytes_read)) <= 0) { (void)time(&time_now); log_file("closed_socket","closed socket for %s connect to %s - %s",p->inetaddr,p->name,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); // close this fd close(p->remote_sock); pthread_exit(NULL); return 0; } } else if (FD_ISSET(p->remote_sock,&p->select_1) || FD_ISSET(p->remote_sock,&p->select_2)) { if ((p->bytes_read = read(p->remote_sock,buf,4096)) <= 0) { (void)time(&time_now); log_file("closed_socket","closed socket for %s connect to %s - %s",p->inetaddr,p->name,ctime(&time_now)); free(p->stack); free(p->totell); free(p); close(p_t->socket); // close this fd close(p->remote_sock); pthread_exit(NULL); return 0; } if ((write(p->remote2_sock,buf,p->bytes_read)) <= 0) { (void)time(&time_now); log_file("closed_socket","closed socket for %s connect to %s - %s",p->inetaddr,p->name,ctime(&time_now)); close(p_t->socket); // close this fd close(p->remote_sock); pthread_exit(NULL); return 0; } } } free(p->stack); free(p->totell); free(p); close(p_t->socket); // close this fd close(p->remote_sock); pthread_exit(NULL); return 0; } void show_login(struct frog *p) { p->term=1; // use this if you want a more elaborte welcome } // not used could be to clean the code up.... void close_socket(struct frog *current) { close((int)current->socket); RAMUSED-=sizeof(current->the_data); RAMUSED-=sizeof(current->data); RAMUSED-=sizeof(current->command); RAMUSED-=sizeof(current->line); RAMUSED-=sizeof(current->stack); RAMUSED-=sizeof(current->oldstack); RAMUSED-=sizeof(current->totell); } /* backspace */ void backspace(struct frog * p) { p->buffer[p->count] = 0; if (p->count > 0) p->count--; } // used for all those telnet options... void telnet_options(struct frog *p) { unsigned char c; if (read(p->socket, &c, 1) != 1) return; switch (c) { case EC: backspace(p); break; case EL: p->count = 0; break; case IP: close_socket(p); break; case WILL: case DO: if (read(p->socket, &c, 1) != 1) return; switch (c) { case TELOPT_ECHO: break; case TELOPT_SGA: break; case TELOPT_EOR: send_fd(p, "\377\031"); break; } break; case WONT: case DONT: if (read(p->socket, &c, 1) != 1) return; switch (c) { case TELOPT_ECHO: break; case TELOPT_SGA: break; case TELOPT_EOR: break; } break; } } // get some input void get_input(struct frog *p) { int chars_ready = 0; char c; errno = 0; if (ioctl(p->socket, FIONREAD, &chars_ready) == -1) { log_file("ioctl","IOCTL Error getinput: user disconnect?"); log_file("ioctl",p->name); close_socket(p); p->flags|=PANIC; pthread_exit(NULL); return; } // need bc of non blockio if (!chars_ready) { log_file("ioctl","Chars ready==0"); log_file("ioctl",p->name); close_socket(p); p->flags|=PANIC; pthread_exit(NULL); return; } for (; !(p->flags & PANIC) && chars_ready; chars_ready--) if (read(p->socket, &c, 1) != 1) { p->flags|=PANIC; log_file("error","Read Error on get input"); close_socket(p); pthread_exit(NULL); return; } else switch (c) { case -1: p->flags &= ~(LAST_CHAR_WAS_R | LAST_CHAR_WAS_N); telnet_options(p); return; break; case '\n': p->flags |= LAST_CHAR_WAS_N; p->buffer[p->count] = 0; return; break; default: p->flags &= ~(LAST_CHAR_WAS_R | LAST_CHAR_WAS_N); if (c == 8 || c == 127 || c == -9) { backspace(p); break; } if ((c > 31) && (p->count < (IBUFFER_LENGTH - 3))) { p->buffer[p->count] = c; p->count++; out_current++; out_pack_current++; } else { } break; } } // used to clear a screen if the correct term is set void cls(struct frog *p, char *str) { if (p->term>0) { send_fd(p,terms[(p->term)-1].cls); } else { send_fd(p,"Sorry you must set a term type first"); } } // this sends to the fd just text no vsprintf that is the SENDFD void send_fd(struct frog *p, char *str) { char *str2; if (!str) return; if (!p) return; if ((p->socket<0) || (p->flags & PANIC)) return; if ((p->socket<0) || (p->flags & PANIC)) return; str2=review_sendfd(p,str); if (!str2) return; if (write((int)p->socket,str2,strlen(str2))<0) { p->flags|=PANIC; log_file("sigpipe","Sigipipe: from output to frog, at time ->"); return; } } // use this when impleting a ll to send data/??? to other open fd on the server void _sendfd(struct frog *p, char *str) { char *name; struct frog *info; info=NULL; if (!str) { send_fd(p,"usage: sendfd {connected_ip} {message/data}\n"); return; } /* we are only expecting one name at a time for now */ if (!(name=parse(str,1," "))) { send_fd(p,"usage: sendfd {connected_ip} {message/data}\n"); return; } if ((p==info)) { send_fd(p,"Hey Dumb ass that is your ip\n"); return; } if (!((char *)str = strchr(str,' '))) { send_fd(p,"usage: sendfd {connected_ip} {message/data}\n"); return; } str++; SENDFD(info,"%s sends to you %s\n",p->name,str); SENDFD(p," %s sent to %s\n",info->name,str); } // again could be used by admin command on port+1 void shut_down(struct frog *p, char *str) { char buf[255]; sprintf(buf,"%s is shutting down from ip# %s",p->name,p->inetaddr); log_file("shutdown","SHUTTING DOWN "); log_file("shutdown",buf); send_fd(p,"SHutting Down....\n"); exit(-1); return; } // old functions to keep time/mem of daemon...internal functions void time_frog_server_up(struct frog *p) { double time_on; time_t time_now; int x,y; p->no_secs=0; p->no_mins=0; p->no_hours=0; p->no_days=0; time_now=time((time_t *)0); time_on=(double )difftime(time_now,timeval); if (time_on>86380) { p->no_secs=((int)time_on % 60); x=(time_on/60); p->no_mins=(x % 60); y=(x/60); p->no_hours=(y % 24); p->no_days=(y/24); return; } if (time_on>3600) { p->no_secs=((int)time_on % 60); x=(time_on/60); p->no_mins=(x%60); p->no_hours=(x/60); return; } if (time_on>60) { p->no_secs=((int)time_on % 60); p->no_mins=((int)time_on / 60); return; } /* sec only */ p->no_secs=time_on; } // same as above...except a small twist void time_up(struct frog *p, char *str) { time_t time_rightnow; (void)time(&time_rightnow); SENDFD(p,"MY Code is now in version #%s since date %s\n",VERSION,VERSION_DATE); SENDFD(p,"The date is: %s\r",ctime(&timeval)); SENDFD(p,"And Has Been Up For: "); time_frog_server_up(p); if (p->no_days) { SENDFD(p," %d days",p->no_days); } if (p->no_hours) { SENDFD(p," %d hour(s)",p->no_hours); } if (p->no_mins) { SENDFD(p," %d minute(s)",p->no_mins); } if (p->no_secs) { SENDFD(p," %d second(s)",p->no_secs); } SENDFD(p,"\r\nAnd "); if (logins<2) SENDFD(p,"%d people have used leap frog.\n",logins); else SENDFD(p,"%d people have used leap frog.\n",logins); } leap_frog/src/strings.c100664 764 764 14566 6771710154 13343 0ustar awrawr// Strictly string and string i/o in here #include #include #include #include #include #include "include/link.h" #include "include/proto.h" // local functions char *parse(char *line,int count, char *st); char *first_char(char *line); void SENDFD(struct frog *p, char *format, ...); char *word_time(int t); void password_mode_on(struct frog *p); void password_mode_off(struct frog *p); char *sys_time(); void view_commands(struct frog *p, char *str); void execute_command(struct frog *p, struct command *com, char *str, int command); char *astrstrb(char *s,char *t); int do_match(struct frog *p, char *str, struct command *com_entry); // function call start /* function to execute a command */ void execute_command(struct frog *p, struct command *com, char *str, int command) { (*com[command].function) (p, str); } /* partial match */ char *astrstrb(char *s,char *t) { char *temp1,*temp2; if (s==NULL) return NULL; if (t==NULL) return NULL; temp1=s; temp2=t; if(strlen(temp1)<2) return NULL; if (strlen(temp1)>strlen(temp2)) return NULL; while (*s && *t) if (tolower(*s)==tolower(*t)) { s++;t++;} else return NULL; return temp1; } int do_match(struct frog *p, char *str, struct command *com_entry) { int x; for (x=0;com_entry[x].text;x++) if ((!strcasecmp(str,com_entry[x].text))) return x; return -1; } //funct ion call end char *sys_time() { time_t st; static char time_string[25]; st = time((time_t *)0); strftime(time_string, 25, "%H:%M:%S - %d/%m/%Y", localtime(&st)); return time_string; } // get some char from a list char *parse(char *line,int count, char *st) { char *word,temp[255],hold[255]; int i; if ((!line) | (line[0]==13)) return '\0'; word="\0"; strcpy(temp,line); strcpy(hold,line); word=strtok(temp,st); if (word) /* printf("word = %s len=%d\n\n",word,strlen(word)); */ for (i=2;i<=count;i++) { word=strtok('\0',st); /*if (word) * printf("i=%d word=%s len=%d \n",i,word,strlen(word)); */ } /* printf("temp=%s word=%s line=%s hold=%s \n",temp,word,line,hold); */ line=hold; return (char *)word; } // get the first char char *first_char(char *line) { while ((*line) && (*line==' ')) line++; return line; } /* tell_with vprintf */ void SENDFD(struct frog *p, char *format, ...) { va_list argum; p->oldstack = p->stack; va_start(argum, format); vsprintf(p->stack, format, argum); va_end(argum); p->stack = strchr(p->stack,0); send_fd(p, p->oldstack); p->stack = p->oldstack; } // return the time in words char *word_time(int t) { static char time_string[100], *fill; int neg=0, days, hrs, mins, secs; if (!t) return "no time at all - doh!"; if (t < 0) { neg = 1; t = 0-t; } days = t / 86400; hrs = (t / 3600) % 24; mins = (t / 60) % 60; secs = t % 60; fill = time_string; if (neg) { sprintf(fill, "negative "); while (*fill) fill++; } if (days) { sprintf(fill, "%d day", days); while (*fill) fill++; if (days != 1) *fill++ = 's'; if (hrs || mins || secs) { *fill++ = ','; *fill++ = ' '; } } if (hrs) { sprintf(fill, "%d hour", hrs); while (*fill) fill++; if (hrs != 1) *fill++ = 's'; if (mins && secs) { *fill++ = ','; *fill++ = ' '; } if ((mins && !secs) || (!mins && secs)) { strcpy(fill, " and "); while (*fill) fill++; } } if (mins) { sprintf(fill, "%d min", mins); while (*fill) fill++; if (mins != 1) *fill++ = 's'; if (secs) { strcpy(fill, " and "); while (*fill) fill++; } } if (secs) { sprintf(fill, "%d sec", secs); while (*fill) fill++; if (secs != 1) *fill++ = 's'; } *fill++ = 0; return time_string; } /* turn on and off echo for passwords or anything like that*/ void password_mode_on(struct frog *p) { send_fd(p,"\377\373\001"); } void password_mode_off(struct frog *p) { send_fd(p,"\377\374\001"); } void view_commands(struct frog *p, char *str) { struct command *com_entry=all; char buffer[1000]; int x,y,z; y=0; z=0; buffer[0]=0; send_fd(p,"\nWWW.^RC^GO^BT^YS^gE^N.COM\n"); send_fd(p,"To ^GLeap Frog^N Type Server and port followed by enter.\nOr type in any Admin commands listed below\n"); send_fd(p,"\nAvailable commands are:\n"); for (x=0;com_entry[x].text;x++) { y+=strlen(com_entry[x].text); z+=y; if (y>67) { y=0; strcat(buffer,"\n"); z+=2; } if (z>9999) break; strcat(buffer,com_entry[x].text); strcat(buffer," "); y++;z++; } send_fd(p,buffer); send_fd(p,"\nEnd of available Commands\n\n"); } leap_frog/src/README100644 764 764 4513 6771505521 12333 0ustar awrawrLeap Frog: 1.0 http://www.cotse.com This is a small program which will create a daemon on port (5000 default) and listen for indbound telnet traffic to it...Upon telneting to the host running the daemon on the port (again default to 5000) you can then enter in a hostname (along with fuly qualified domain name) and desired port number and you will then have an open portal to that desired machine (assuming that port is open and is accepting connections); The machine you have connected to will not see your "real" ip/mac as the leap frogger will handle all intermediate traffic... I have tried to make the code as least bloated as possible (it is bloated though in too many places) (many specifc areas memory needs to be cleaned up a bit) Workings: after you have compiled the program and it is running on port (default 5000) you can telnet to port 5000 (telnet 0 5000). The listening program will ask you where you want to telnet to and which port (if you do not tell it a port it defaults to port 23, telnet). The next time you telnet to the daemon it will not prompt you for server/port to telnet to. (you cannot telnet back to your self). if you want to change the server/port to leap_frog to, telnet to port (default 5000 + 1 == 5001), the thread listening on the default + 1 (5001) will ask you server/port to telnet to, it will save the server/port and or modify the already cached data. LOGGING: Logging done: logins,logout,time stamps, etc. Things do get logged into the directory ../logs/ if you are against logs you can either 1) put a return in the log function (main.c) or 2) rm -rf the ../logs/ directory (no errors will occur) or 3) you can disable it from the configure utility Programmers note: I am sure there are guru C coders who will laugh at the simplicity, but heck it works.... Code is written and ported for Solaris 2.6,2.7,linux 2.0x, and mabey some BSD os's? (with thread libraries) type : tar xvf leap_frog.tar.Z cd leap_frog ./configure ----> Anwser questions (you can use defaults) whilst running configure<---- (make sure you are in the src directory) cd src make all run program from my_telnet/bin change to the bin directory ex: cd ../bin (assumes that you just compiled the src) run program: ./leap_frog& Send comments and suggestions to awr@cotse.com send flames to 2>&1 >/dev/null& Web Site: http://www.cotse.com leap_frog/src/Makefile.sunos100644 764 764 2741 6771473430 14265 0ustar awrawr.EXPORT_ALL_VARIABLES: #define SOLARIS BIN = ../bin BINARY = leap_frog OBJECT-DIR = ../object CC = gcc CFLAGS = -g -O -Wall -Wnested-externs -I.. -D_REENTRANT LDFLAGS = -ggdb # We may Need -lg this for Linux, also the -Wl,-qmagic causes SEGV on derefence of # NULL pointer. #ifdef SOLARIS LIBPTHREAD= -lnsl -lthread -lm #LIBPTHREAD= -lthread #else #LIBPTHREAD=/usr/lib/libpthread.a #endif # For Solaris # HDRS = DEFS = -DCODING OBJS = $(OBJECT-DIR)/main.o \ $(OBJECT-DIR)/strings.o \ $(OBJECT-DIR)/color.o \ $(OBJECT-DIR)/files.o #ifdef SOLARIS LIBS = -lmalloc -lsocket -lnsl #else #LIBS = -lg -Wl,-qmagic #endif #if you compile with REdhat 5.0 or glibc you need to add -lcrypt all: $(BINARY) mv $(BINARY) $(BIN) @echo 'Made all' $(BINARY): $(OBJS) $(CC) $(LDFLAGS) -o $(BINARY) $(DEFS) $(OBJS) $(LIBS) $(LIBPTHREAD) clean: rm -f ../object/* $(BIN)/$(BINARY) cleanlogs: rm -f ../logs/* $(OBJECT-DIR)/%.o: include/link.h include/linked_list.h include/config.h include/version.h include/proto.h Makefile $(CC) $(CFLAGS) $(DEFS) -c $*.c -o $(OBJECT-DIR)/$*.o # dependancies $(OBJECT-DIR)/main.o: main.c include/link.h include/linked_list.h include/config.h include/version.h include/proto.h $(OBJECT-DIR)/strings.o: strings.c include/link.h include/proto.h $(OBJECT-DIR)/color.o: color.c include/link.h include/proto.h $(OBJECT-DIR)/files.o: files.c include/link.h include/proto.h leap_frog/src/Makefile.linux100644 764 764 2742 6771473446 14265 0ustar awrawr.EXPORT_ALL_VARIABLES: #define SOLARIS BIN = ../bin BINARY = leap_frog OBJECT-DIR = ../object CC = gcc CFLAGS = -g -O -Wall -Wnested-externs -I.. -D_REENTRANT LDFLAGS = -ggdb # We may Need -lg this for Linux, also the -Wl,-qmagic causes SEGV on derefence of # NULL pointer. #ifdef SOLARIS #LIBPTHREAD= -lnsl -lthread -lm #LIBPTHREAD= -lthread #else LIBPTHREAD=/usr/lib/libpthread.a #endif # For Solaris # HDRS = DEFS = -DCODING OBJS = $(OBJECT-DIR)/main.o \ $(OBJECT-DIR)/strings.o \ $(OBJECT-DIR)/color.o \ $(OBJECT-DIR)/files.o #ifdef SOLARIS # LIBS = -lmalloc -lsocket -lnsl #else LIBS = -lg -Wl,-qmagic #endif #if you compile with REdhat 5.0 or glibc you need to add -lcrypt all: $(BINARY) mv $(BINARY) $(BIN) @echo 'Made all' $(BINARY): $(OBJS) $(CC) $(LDFLAGS) -o $(BINARY) $(DEFS) $(OBJS) $(LIBS) $(LIBPTHREAD) clean: rm -f ../object/* $(BIN)/$(BINARY) cleanlogs: rm -f ../logs/* $(OBJECT-DIR)/%.o: include/link.h include/linked_list.h include/config.h include/version.h include/proto.h Makefile $(CC) $(CFLAGS) $(DEFS) -c $*.c -o $(OBJECT-DIR)/$*.o # dependancies $(OBJECT-DIR)/main.o: main.c include/link.h include/linked_list.h include/config.h include/version.h include/proto.h $(OBJECT-DIR)/strings.o: strings.c include/link.h include/proto.h $(OBJECT-DIR)/color.o: color.c include/link.h include/proto.h $(OBJECT-DIR)/files.o: files.c include/link.h include/proto.h leap_frog/src/originalmakefile100644 764 764 2742 6771473416 14711 0ustar awrawr.EXPORT_ALL_VARIABLES: #define SOLARIS BIN = ../bin BINARY = leap_frog OBJECT-DIR = ../object CC = gcc CFLAGS = -g -O -Wall -Wnested-externs -I.. -D_REENTRANT LDFLAGS = -ggdb # We may Need -lg this for Linux, also the -Wl,-qmagic causes SEGV on derefence of # NULL pointer. #ifdef SOLARIS #LIBPTHREAD= -lnsl -lthread -lm #LIBPTHREAD= -lthread #else LIBPTHREAD=/usr/lib/libpthread.a #endif # For Solaris # HDRS = DEFS = -DCODING OBJS = $(OBJECT-DIR)/main.o \ $(OBJECT-DIR)/strings.o \ $(OBJECT-DIR)/color.o \ $(OBJECT-DIR)/files.o #ifdef SOLARIS # LIBS = -lmalloc -lsocket -lnsl #else LIBS = -lg -Wl,-qmagic #endif #if you compile with REdhat 5.0 or glibc you need to add -lcrypt all: $(BINARY) mv $(BINARY) $(BIN) @echo 'Made all' $(BINARY): $(OBJS) $(CC) $(LDFLAGS) -o $(BINARY) $(DEFS) $(OBJS) $(LIBS) $(LIBPTHREAD) clean: rm -f ../object/* $(BIN)/$(BINARY) cleanlogs: rm -f ../logs/* $(OBJECT-DIR)/%.o: include/link.h include/linked_list.h include/config.h include/version.h include/proto.h Makefile $(CC) $(CFLAGS) $(DEFS) -c $*.c -o $(OBJECT-DIR)/$*.o # dependancies $(OBJECT-DIR)/main.o: main.c include/link.h include/linked_list.h include/config.h include/version.h include/proto.h $(OBJECT-DIR)/strings.o: strings.c include/link.h include/proto.h $(OBJECT-DIR)/color.o: color.c include/link.h include/proto.h $(OBJECT-DIR)/files.o: files.c include/link.h include/proto.h leap_frog/src/files.c100664 764 764 4215 6771535651 12731 0ustar awrawr#include #include #include "include/link.h" #include "include/proto.h" int read_modify_write(struct frog *p) { struct saved_player sp; FILE *fp; char dn[100]; // this function should only be called from the port+1 thread // and after the host to connect to has been resolved // return vales // -1 no file open // 0 error on write // 1 updated/new write ok sprintf(dn,"%s/files/%s",ROOT,USERS_ADDRESS_FILE); if (!(fp=fopen(dn,"rb+"))) { if(write_out(p)) return 1; else return 0; } while(!(feof(fp))) { fread(&sp,sizeof(struct saved_player),1,fp); if (!(feof(fp))) { if (!strcmp(p->inetaddr,sp.inetaddr)) { (void *)fseek(fp,0L,SEEK_CUR -1); strcpy(sp.remote,p->name); sp.port=p->remote_port; if (fwrite(&sp,sizeof(struct saved_player),1,fp)!=1) { fclose(fp); return 0; } fclose(fp); return 1; } } } // if we get here it means they connected to port+1 and no config data was there // so lets save it if(write_out(p)) return 1; else return 0; } int read_in(struct frog *p) { struct saved_player sp; FILE *fp; char dn[100]; sprintf(dn,"%s/files/%s",ROOT,USERS_ADDRESS_FILE); if (!(fp=fopen(dn,"rb"))) { return 0; } while(!(feof(fp))) { fread(&sp,sizeof(struct saved_player),1,fp); if (!(feof(fp))) { if (!strcasecmp(p->inetaddr,sp.inetaddr)) { strcpy(p->name,sp.remote); p->remote_port=sp.port; fclose(fp); return 1; } } } fclose(fp); return 0; } int write_out(struct frog *p) { FILE *fp; struct saved_player sp; char dn[100]; sprintf(dn,"%s/files/%s",ROOT,USERS_ADDRESS_FILE); if (!(fp=fopen(dn,"ab"))) { fp=fopen(dn,"wb"); } strcpy(sp.inetaddr,p->inetaddr); strcpy(sp.remote,p->name); sp.port=p->remote_port; if (!fp) { return 0; } if (fwrite(&sp,sizeof(struct saved_player),1,fp)!=1) { fclose(fp); return 0; } fclose(fp); return 1; } leap_frog/bin/ 40775 764 764 0 6772223306 11335 5ustar awrawrleap_frog/logs/ 40755 764 764 0 6772223366 11535 5ustar awrawrleap_frog/object/ 40755 764 764 0 6772223306 12031 5ustar awrawrleap_frog/README100644 764 764 4513 6771505646 11554 0ustar awrawrLeap Frog: 1.0 http://www.cotse.com This is a small program which will create a daemon on port (5000 default) and listen for indbound telnet traffic to it...Upon telneting to the host running the daemon on the port (again default to 5000) you can then enter in a hostname (along with fuly qualified domain name) and desired port number and you will then have an open portal to that desired machine (assuming that port is open and is accepting connections); The machine you have connected to will not see your "real" ip/mac as the leap frogger will handle all intermediate traffic... I have tried to make the code as least bloated as possible (it is bloated though in too many places) (many specifc areas memory needs to be cleaned up a bit) Workings: after you have compiled the program and it is running on port (default 5000) you can telnet to port 5000 (telnet 0 5000). The listening program will ask you where you want to telnet to and which port (if you do not tell it a port it defaults to port 23, telnet). The next time you telnet to the daemon it will not prompt you for server/port to telnet to. (you cannot telnet back to your self). if you want to change the server/port to leap_frog to, telnet to port (default 5000 + 1 == 5001), the thread listening on the default + 1 (5001) will ask you server/port to telnet to, it will save the server/port and or modify the already cached data. LOGGING: Logging done: logins,logout,time stamps, etc. Things do get logged into the directory ../logs/ if you are against logs you can either 1) put a return in the log function (main.c) or 2) rm -rf the ../logs/ directory (no errors will occur) or 3) you can disable it from the configure utility Programmers note: I am sure there are guru C coders who will laugh at the simplicity, but heck it works.... Code is written and ported for Solaris 2.6,2.7,linux 2.0x, and mabey some BSD os's? (with thread libraries) type : tar xvf leap_frog.tar.Z cd leap_frog ./configure ----> Anwser questions (you can use defaults) whilst running configure<---- (make sure you are in the src directory) cd src make all run program from my_telnet/bin change to the bin directory ex: cd ../bin (assumes that you just compiled the src) run program: ./leap_frog& Send comments and suggestions to awr@cotse.com send flames to 2>&1 >/dev/null& Web Site: http://www.cotse.com leap_frog/configure100700 764 764 7144 6772225536 12572 0ustar awrawr#!/bin/sh # simple install script # SunOS/Linux get_system() { echo "Select System type:" echo "1) Linux (BSD)" echo "2) Solaris (SYS IV)" echo "3) BSD (Flavours): " echo $N "System Selection:(1/2/3) ?" read system case "$system" in "Linux" | "LINUX" | "linux" | "1" ) Host="Linux";; "Solaris" | "SOLARIS" | "solaris" | "SUNOS" | "Sunos" | "sunos" | "2" ) Host="SunOS";; "BSD" | "bsd" | "Bsd" | "3" ) Host="Linux";; * ) echo ""; echo "Don't Know That System Type"; exit 0; esac echo "System type selected ---> $Host <---" } # # Determine how to suppress newline with echo command. # case ${N}$C in "") if echo "\c" | grep c >/dev/null 2>&1; then N='-n' else C='\c' fi ;; esac echo "Be sure and visit" echo "http://www.cotse.com for all your security needs" echo "" echo "Configuration utility for Leap Frog" echo "" Host=`uname` echo "Looks like you are running $Host" echo $N "Is this Correct: (y/n): " read yn case "$yn" in "yes" | "Y" | "Yes" | "y" | "YES" ) echo "Trying Config for system $Host";; "no" | "No" | "NO" | "N" | "n" ) get_system;; * ) ;; esac PORT=5000 echo "" echo "Which Port Do you want to Config the server to Listen on." echo "Please Note ports below 1024 are root bound." echo "Default Port is set to listen on $PORT" echo $N "Port # (Default $PORT): " read port case $port in "") port=$PORT;; *) ;; esac if [ "$port" -le 0 ] then echo "Port must be bettween 1..65536" exit 0 fi if [ "$port" -gt 65536 ] then echo "Port must be bettween 1..65536" exit 0 fi echo "" echo "Do you want the logging facility on the leap frog program" echo "*** Note the logging facility, logs any/all traffic if it is kept on ***" echo $N "Logging (y/n): " read yn case "$yn" in "yes" | "Y" | "Yes" | "y" | "YES" ) Logging=1;; "no" | "No" | "NO" | "N" | "n" ) Logging=0;; * ) Logging=1;; esac Directory=`pwd` echo "" echo "Instaling in the directory $Directory/" echo "Doing Config For System Type $Host" echo "Configuring to listen on port $port" if [ "$Logging" -eq 0 ] then echo "With logging shut off" else echo "With logging turned on" fi echo "" echo $N "Is This Config Ok to Use?" read yn case "$yn" in "yes" | "Y" | "Yes" | "y" | "YES" ) echo "Doing Configs";; "no" | "No" | "NO" | "N" | "n" ) exit 0;; * ) exit 0;; esac # Makefile if [ "$Host" = "Linux" ] then cp src/Makefile.linux src/Makefile cp src/include/originalconfig.h src/include/config.h sed 's/\/\/#define LINUX 1/#define LINUX 1/g' src/include/config.h > src/include/config2.h if [ "$Logging" -eq 0 ] then sed 's/#define LOGGING 1/\/\/ #define LOGGING 1/g' src/include/config2.h > src/include/config3.h mv src/include/config3.h src/include/config2.h fi echo "#define DEFAULT_PORT $port" >> src/include/config2.h echo "#define SERVERPORT $port" >> src/include/config2.h echo "#define ROOT \"$Directory/\"" >> src/include/config2.h mv src/include/config2.h src/include/config.h fi if [ "$Host" = "SunOS" ] then cp src/Makefile.sunos src/Makefile cp src/include/originalconfig.h src/include/config.h sed 's/\/\/#define SOLARIS 2/#define SOLARIS 2/g' src/include/config.h > src/include/config2.h if [ "$Logging" -eq 0 ] then sed 's/#define LOGGING 1/\/\/ #define LOGGING 1/g' src/include/config2.h > src/include/config3.h mv src/include/config3.h src/include/config2.h fi echo "#define DEFAULT_PORT $port" >> src/include/config2.h echo "#define SERVERPORT $port" >> src/include/config2.h echo "#define ROOT \"$Directory/\"" >> src/include/config2.h mv src/include/config2.h src/include/config.h fi cd src/ echo "Type cd src/" echo "type make all" echo "Then you can cd ../bin to run the program" leap_frog/INSTALL100664 764 764 250 6771473276 11704 0ustar awrawrTo install type ./configure cd src/ make all cd ../bin ./leap_frog& then you can telnet to port 5000 or 5001 (configure) telnet 0 5000 or telnet 0 5001 enjoy leap_frog/files/ 40775 764 764 0 6772223363 11672 5ustar awrawr