@@ -225,15 +225,15 @@ static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
225
225
pfd [0 ].events = POLLOUT ;
226
226
fcntl (sock , F_SETFL , O_NONBLOCK );
227
227
ret = true_connect (sock , addr , len );
228
- PDEBUG ("\nconnect ret=%d\n" , ret );
228
+ PDEBUG ("timed_connect: core.c: ret=%d\n" , ret );
229
229
230
230
if (ret == -1 && errno == EINPROGRESS ) {
231
231
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 );
233
233
if (ret == 1 ) {
234
234
value_len = sizeof (socklen_t );
235
235
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 );
237
237
if (!value )
238
238
ret = 0 ;
239
239
else
@@ -259,7 +259,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
259
259
char * dns_name = NULL ;
260
260
size_t dns_len = 0 ;
261
261
262
- PDEBUG ("tunnel_to()\n" );
262
+ PDEBUG ("tunnel_to: core.c: init tunnel_to ()\n" );
263
263
264
264
// we use ip addresses with 224.* to lookup their dns name in our table, to allow remote DNS resolution
265
265
// 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
274
274
goto err ;
275
275
}
276
276
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>" );
278
278
279
279
size_t ulen = strlen (user );
280
280
size_t passlen = strlen (pass );
281
281
282
282
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" );
284
284
goto err ;
285
285
}
286
286
@@ -493,7 +493,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
493
493
return SOCKET_ERROR ;
494
494
}
495
495
496
- #define TP " ... "
496
+ #define TP "... "
497
497
#define DT "Dynamic chain"
498
498
#define ST "Strict chain"
499
499
#define RT "Random chain"
@@ -507,8 +507,7 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
507
507
goto error ;
508
508
509
509
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 ));
512
511
pd -> ps = PLAY_STATE ;
513
512
memset (& addr , 0 , sizeof (addr ));
514
513
addr .sin_family = AF_INET ;
@@ -521,7 +520,7 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
521
520
pd -> ps = BUSY_STATE ;
522
521
return SUCCESS ;
523
522
error1 :
524
- proxybound_write_log (TP " timeout\n" );
523
+ proxybound_write_log (LOG_PREFIX TP "timeout\n" );
525
524
error :
526
525
if (* fd != -1 )
527
526
close (* fd );
@@ -599,7 +598,7 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
599
598
char * hostname ;
600
599
char ip_buf [16 ];
601
600
602
- PDEBUG ("chain_step()\n" );
601
+ PDEBUG ("chain_step: core.c: init chain_step ()\n" );
603
602
604
603
if (pto -> ip .octet [0 ] == remote_dns_subnet ) {
605
604
hostname = string_from_internal_ip (pto -> ip );
@@ -611,20 +610,20 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
611
610
hostname = ip_buf ;
612
611
}
613
612
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 ));
615
614
retcode = tunnel_to (ns , pto -> ip , pto -> port , pfrom -> pt , pfrom -> user , pfrom -> pass );
616
615
switch (retcode ) {
617
616
case SUCCESS :
618
617
pto -> ps = BUSY_STATE ;
619
618
break ;
620
619
case BLOCKED :
621
620
pto -> ps = BLOCKED_STATE ;
622
- proxybound_write_log ("<-- denied\n" );
621
+ proxybound_write_log (LOG_PREFIX " denied\n" );
623
622
close (ns );
624
623
break ;
625
624
case SOCKET_ERROR :
626
625
pto -> ps = DOWN_STATE ;
627
- proxybound_write_log ("<-- socket error or timeout!\n" );
626
+ proxybound_write_log (LOG_PREFIX " socket error or timeout!\n" );
628
627
close (ns );
629
628
break ;
630
629
}
@@ -643,7 +642,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
643
642
644
643
p3 = & p4 ;
645
644
646
- PDEBUG ("connect_proxy_chain\n" );
645
+ PDEBUG ("connect: core.c: connect_proxy_chain\n" );
647
646
648
647
again :
649
648
@@ -660,7 +659,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
660
659
if (!p2 )
661
660
break ;
662
661
if (SUCCESS != chain_step (ns , p1 , p2 )) {
663
- PDEBUG ("GOTO AGAIN 1 \n" );
662
+ PDEBUG ("connect: core.c: goto again x1 \n" );
664
663
goto again ;
665
664
}
666
665
p1 = p2 ;
@@ -676,18 +675,18 @@ int connect_proxy_chain(int sock, ip_type target_ip,
676
675
alive_count = calc_alive (pd , proxy_count );
677
676
offset = 0 ;
678
677
if (!(p1 = select_proxy (FIFOLY , pd , proxy_count , & offset ))) {
679
- PDEBUG ("select_proxy failed\n" );
678
+ PDEBUG ("connect: core.c: select_proxy failed\n" );
680
679
goto error_strict ;
681
680
}
682
681
if (SUCCESS != start_chain (& ns , p1 , ST )) {
683
- PDEBUG ("start_chain failed\n" );
682
+ PDEBUG ("connect: core.c: start_chain failed\n" );
684
683
goto error_strict ;
685
684
}
686
685
while (offset < proxy_count ) {
687
686
if (!(p2 = select_proxy (FIFOLY , pd , proxy_count , & offset )))
688
687
break ;
689
688
if (SUCCESS != chain_step (ns , p1 , p2 )) {
690
- PDEBUG ("chain_step failed\n" );
689
+ PDEBUG ("connect: core.c: chain_step failed\n" );
691
690
goto error_strict ;
692
691
}
693
692
p1 = p2 ;
@@ -712,7 +711,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
712
711
if (!(p2 = select_proxy (RANDOMLY , pd , proxy_count , & offset )))
713
712
goto error_more ;
714
713
if (SUCCESS != chain_step (ns , p1 , p2 )) {
715
- PDEBUG ("GOTO AGAIN 2 \n" );
714
+ PDEBUG ("connect: core.c: goto again x2 \n" );
716
715
goto again ;
717
716
}
718
717
p1 = p2 ;
@@ -725,7 +724,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
725
724
726
725
}
727
726
728
- proxybound_write_log (TP " OK \n" );
727
+ proxybound_write_log (LOG_PREFIX TP "ok \n" );
729
728
dup2 (ns , sock );
730
729
close (ns );
731
730
return 0 ;
@@ -736,9 +735,9 @@ int connect_proxy_chain(int sock, ip_type target_ip,
736
735
return -1 ;
737
736
738
737
error_more :
739
- proxybound_write_log ("\n!!!need more proxies!!! \n" );
738
+ proxybound_write_log (LOG_PREFIX "ERROR: NEED MORE PROXIES!\n\n \n" );
740
739
error_strict :
741
- PDEBUG ("error\n" );
740
+ PDEBUG ("connect: core.c: error\n" );
742
741
743
742
release_all (pd , proxy_count );
744
743
if (ns != -1 )
@@ -800,23 +799,23 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
800
799
for (i = 0 ; i < internal_ips .counter ; i ++ ) {
801
800
if (internal_ips .list [i ]-> hash == hash && !strcmp (name , internal_ips .list [i ]-> string )) {
802
801
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 );
804
803
goto have_ip ;
805
804
}
806
805
}
807
806
}
808
807
809
808
// grow list if needed.
810
809
if (internal_ips .capa < internal_ips .counter + 1 ) {
811
- PDEBUG ("realloc\n" );
810
+ PDEBUG ("proxy_gethostbyname: core.c: realloc\n" );
812
811
new_mem = realloc (internal_ips .list , (internal_ips .capa + 16 ) * sizeof (void * ));
813
812
if (new_mem ) {
814
813
internal_ips .capa += 16 ;
815
814
internal_ips .list = new_mem ;
816
815
} else {
817
816
// goto ------------
818
817
oom :
819
- proxybound_write_log ("out of mem \n" );
818
+ proxybound_write_log (LOG_PREFIX "ERROR: OUT OF MEMORY!\n\n \n" );
820
819
goto err_plus_unlock ;
821
820
}
822
821
}
@@ -830,7 +829,7 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
830
829
if (!new_mem )
831
830
goto oom ;
832
831
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 );
834
833
835
834
internal_ips .list [internal_ips .counter ] = new_mem ;
836
835
internal_ips .list [internal_ips .counter ]-> hash = hash ;
0 commit comments