@@ -225,15 +225,15 @@ static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
225225 pfd [0 ].events = POLLOUT ;
226226 fcntl (sock , F_SETFL , O_NONBLOCK );
227227 ret = true_connect (sock , addr , len );
228- PDEBUG ("\nconnect ret=%d\n" , ret );
228+ PDEBUG ("timed_connect: core.c: ret=%d\n" , ret );
229229
230230 if (ret == -1 && errno == EINPROGRESS ) {
231231 ret = poll_retry (pfd , 1 , tcp_connect_time_out );
232- PDEBUG ("\npoll ret=%d\n" , ret );
232+ PDEBUG ("timed_connect: core.c: poll ret=%d\n" , ret );
233233 if (ret == 1 ) {
234234 value_len = sizeof (socklen_t );
235235 getsockopt (sock , SOL_SOCKET , SO_ERROR , & value , & value_len );
236- PDEBUG ("\nvalue =%d\n" , value );
236+ PDEBUG ("timed_connect: core.c: value =%d\n" , value );
237237 if (!value )
238238 ret = 0 ;
239239 else
@@ -259,7 +259,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
259259 char * dns_name = NULL ;
260260 size_t dns_len = 0 ;
261261
262- PDEBUG ("tunnel_to()\n" );
262+ PDEBUG ("tunnel_to: core.c: init tunnel_to ()\n" );
263263
264264 // we use ip addresses with 224.* to lookup their dns name in our table, to allow remote DNS resolution
265265 // the range 224-255.* is reserved, and it won't go outside (unless the app does some other stuff with
@@ -274,13 +274,13 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
274274 goto err ;
275275 }
276276
277- PDEBUG ("host dns %s\n" , dns_name ? dns_name : "<NULL>" );
277+ PDEBUG ("tunnel_to: core.c: host dns %s\n" , dns_name ? dns_name : "<NULL>" );
278278
279279 size_t ulen = strlen (user );
280280 size_t passlen = strlen (pass );
281281
282282 if (ulen > 0xFF || passlen > 0xFF || dns_len > 0xFF ) {
283- proxybound_write_log (LOG_PREFIX "error: maximum size of 255 for user/pass or domain name! \n" );
283+ proxybound_write_log (LOG_PREFIX "ERROR: USER+PASS/DOMAIN SIZE EXCEEDS MAX VALUE OF 255!\n\n \n" );
284284 goto err ;
285285 }
286286
@@ -493,7 +493,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
493493 return SOCKET_ERROR ;
494494}
495495
496- #define TP " ... "
496+ #define TP "... "
497497#define DT "Dynamic chain"
498498#define ST "Strict chain"
499499#define RT "Random chain"
@@ -507,8 +507,7 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
507507 goto error ;
508508
509509 pc_stringfromipv4 (& pd -> ip .octet [0 ], ip_buf );
510- proxybound_write_log (LOG_PREFIX "%s " TP " %s:%d " ,
511- begin_mark , ip_buf , htons (pd -> port ));
510+ proxybound_write_log (LOG_PREFIX "%s " TP "%s:%d\n" , begin_mark , ip_buf , htons (pd -> port ));
512511 pd -> ps = PLAY_STATE ;
513512 memset (& addr , 0 , sizeof (addr ));
514513 addr .sin_family = AF_INET ;
@@ -521,7 +520,7 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
521520 pd -> ps = BUSY_STATE ;
522521 return SUCCESS ;
523522 error1 :
524- proxybound_write_log (TP " timeout\n" );
523+ proxybound_write_log (LOG_PREFIX TP "timeout\n" );
525524 error :
526525 if (* fd != -1 )
527526 close (* fd );
@@ -599,7 +598,7 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
599598 char * hostname ;
600599 char ip_buf [16 ];
601600
602- PDEBUG ("chain_step()\n" );
601+ PDEBUG ("chain_step: core.c: init chain_step ()\n" );
603602
604603 if (pto -> ip .octet [0 ] == remote_dns_subnet ) {
605604 hostname = string_from_internal_ip (pto -> ip );
@@ -611,20 +610,20 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
611610 hostname = ip_buf ;
612611 }
613612
614- proxybound_write_log (TP " %s:%d " , hostname , htons (pto -> port ));
613+ proxybound_write_log (LOG_PREFIX TP "%s:%d\n " , hostname , htons (pto -> port ));
615614 retcode = tunnel_to (ns , pto -> ip , pto -> port , pfrom -> pt , pfrom -> user , pfrom -> pass );
616615 switch (retcode ) {
617616 case SUCCESS :
618617 pto -> ps = BUSY_STATE ;
619618 break ;
620619 case BLOCKED :
621620 pto -> ps = BLOCKED_STATE ;
622- proxybound_write_log ("<-- denied\n" );
621+ proxybound_write_log (LOG_PREFIX " denied\n" );
623622 close (ns );
624623 break ;
625624 case SOCKET_ERROR :
626625 pto -> ps = DOWN_STATE ;
627- proxybound_write_log ("<-- socket error or timeout!\n" );
626+ proxybound_write_log (LOG_PREFIX " socket error or timeout!\n" );
628627 close (ns );
629628 break ;
630629 }
@@ -643,7 +642,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
643642
644643 p3 = & p4 ;
645644
646- PDEBUG ("connect_proxy_chain\n" );
645+ PDEBUG ("connect: core.c: connect_proxy_chain\n" );
647646
648647 again :
649648
@@ -660,7 +659,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
660659 if (!p2 )
661660 break ;
662661 if (SUCCESS != chain_step (ns , p1 , p2 )) {
663- PDEBUG ("GOTO AGAIN 1 \n" );
662+ PDEBUG ("connect: core.c: goto again x1 \n" );
664663 goto again ;
665664 }
666665 p1 = p2 ;
@@ -676,18 +675,18 @@ int connect_proxy_chain(int sock, ip_type target_ip,
676675 alive_count = calc_alive (pd , proxy_count );
677676 offset = 0 ;
678677 if (!(p1 = select_proxy (FIFOLY , pd , proxy_count , & offset ))) {
679- PDEBUG ("select_proxy failed\n" );
678+ PDEBUG ("connect: core.c: select_proxy failed\n" );
680679 goto error_strict ;
681680 }
682681 if (SUCCESS != start_chain (& ns , p1 , ST )) {
683- PDEBUG ("start_chain failed\n" );
682+ PDEBUG ("connect: core.c: start_chain failed\n" );
684683 goto error_strict ;
685684 }
686685 while (offset < proxy_count ) {
687686 if (!(p2 = select_proxy (FIFOLY , pd , proxy_count , & offset )))
688687 break ;
689688 if (SUCCESS != chain_step (ns , p1 , p2 )) {
690- PDEBUG ("chain_step failed\n" );
689+ PDEBUG ("connect: core.c: chain_step failed\n" );
691690 goto error_strict ;
692691 }
693692 p1 = p2 ;
@@ -712,7 +711,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
712711 if (!(p2 = select_proxy (RANDOMLY , pd , proxy_count , & offset )))
713712 goto error_more ;
714713 if (SUCCESS != chain_step (ns , p1 , p2 )) {
715- PDEBUG ("GOTO AGAIN 2 \n" );
714+ PDEBUG ("connect: core.c: goto again x2 \n" );
716715 goto again ;
717716 }
718717 p1 = p2 ;
@@ -725,7 +724,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
725724
726725 }
727726
728- proxybound_write_log (TP " OK \n" );
727+ proxybound_write_log (LOG_PREFIX TP "ok \n" );
729728 dup2 (ns , sock );
730729 close (ns );
731730 return 0 ;
@@ -736,9 +735,9 @@ int connect_proxy_chain(int sock, ip_type target_ip,
736735 return -1 ;
737736
738737 error_more :
739- proxybound_write_log ("\n!!!need more proxies!!! \n" );
738+ proxybound_write_log (LOG_PREFIX "ERROR: NEED MORE PROXIES!\n\n \n" );
740739 error_strict :
741- PDEBUG ("error\n" );
740+ PDEBUG ("connect: core.c: error\n" );
742741
743742 release_all (pd , proxy_count );
744743 if (ns != -1 )
@@ -800,23 +799,23 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
800799 for (i = 0 ; i < internal_ips .counter ; i ++ ) {
801800 if (internal_ips .list [i ]-> hash == hash && !strcmp (name , internal_ips .list [i ]-> string )) {
802801 data -> resolved_addr = make_internal_ip (i );
803- PDEBUG ("got cached ip for %s\n" , name );
802+ PDEBUG ("proxy_gethostbyname: core.c: got cached ip for %s\n" , name );
804803 goto have_ip ;
805804 }
806805 }
807806 }
808807
809808 // grow list if needed.
810809 if (internal_ips .capa < internal_ips .counter + 1 ) {
811- PDEBUG ("realloc\n" );
810+ PDEBUG ("proxy_gethostbyname: core.c: realloc\n" );
812811 new_mem = realloc (internal_ips .list , (internal_ips .capa + 16 ) * sizeof (void * ));
813812 if (new_mem ) {
814813 internal_ips .capa += 16 ;
815814 internal_ips .list = new_mem ;
816815 } else {
817816 // goto ------------
818817 oom :
819- proxybound_write_log ("out of mem \n" );
818+ proxybound_write_log (LOG_PREFIX "ERROR: OUT OF MEMORY!\n\n \n" );
820819 goto err_plus_unlock ;
821820 }
822821 }
@@ -830,7 +829,7 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
830829 if (!new_mem )
831830 goto oom ;
832831
833- PDEBUG ("creating new entry %d for ip of %s\n" , (int ) internal_ips .counter , name );
832+ PDEBUG ("proxy_gethostbyname: core.c: creating new entry %d for ip of %s\n" , (int ) internal_ips .counter , name );
834833
835834 internal_ips .list [internal_ips .counter ] = new_mem ;
836835 internal_ips .list [internal_ips .counter ]-> hash = hash ;
0 commit comments