@@ -2644,64 +2644,41 @@ int is_connection_local(SBUF2 *sb) {
2644
2644
int do_appsock (netinfo_type * netinfo_ptr , struct sockaddr_in * cliaddr ,
2645
2645
SBUF2 * sb , uint8_t firstbyte )
2646
2646
{
2647
- watchlist_node_type * watchlist_node ;
2648
- int new_fd = sbuf2fileno (sb );
2649
- char paddr [64 ];
2650
-
2651
- int admin = 0 ;
2652
- APPSOCKFP * rtn = NULL ;
2653
-
2654
- if (firstbyte == '@' ) {
2655
- findpeer (new_fd , paddr , sizeof (paddr ));
2656
- if (!gbl_forbid_remote_admin ||
2657
- (cliaddr -> sin_addr .s_addr == htonl (INADDR_LOOPBACK ))) {
2658
- admin = 1 ;
2659
- } else {
2660
- logmsg (LOGMSG_INFO , "Rejecting non-local admin user from %s\n" , paddr );
2661
- sbuf2close (sb );
2662
- return -1 ;
2663
- }
2647
+ if (firstbyte == '@' || gbl_server_admin_mode ) {
2648
+ /* admin connections are handled by exclusively by newsql - should never get here */
2649
+ goto err ;
2664
2650
} else if (firstbyte != sbuf2ungetc (firstbyte , sb )) {
2665
- logmsg (LOGMSG_ERROR , "sbuf2ungetc failed %s:%d\n" , __FILE__ , __LINE__ );
2666
- sbuf2close (sb );
2667
- return -1 ;
2651
+ logmsg (LOGMSG_ERROR , "sbuf2ungetc failed %s\n" , __func__ );
2652
+ goto err ;
2668
2653
}
2669
2654
2670
-
2671
- if (gbl_server_admin_mode && !admin ) {
2672
- sbuf2close (sb );
2673
- return -1 ;
2655
+ if (!netinfo_ptr -> appsock_rtn ) {
2656
+ goto err ;
2674
2657
}
2675
2658
2659
+ /* set up the watchlist system for this node */
2660
+ watchlist_node_type * watchlist_node ;
2661
+ watchlist_node = calloc (1 , sizeof (watchlist_node_type ));
2662
+ if (!watchlist_node ) {
2663
+ logmsg (LOGMSG_ERROR , "%s: malloc watchlist_node failed\n" , __func__ );
2664
+ goto err ;
2665
+ }
2666
+ memcpy (watchlist_node -> magic , "WLST" , 4 );
2667
+ watchlist_node -> in_watchlist = 0 ;
2668
+ watchlist_node -> netinfo_ptr = netinfo_ptr ;
2669
+ watchlist_node -> sb = sb ;
2670
+ watchlist_node -> readfn = sbuf2getr (sb );
2671
+ watchlist_node -> writefn = sbuf2getw (sb );
2672
+ watchlist_node -> addr = * cliaddr ;
2673
+ sbuf2setrw (sb , net_reads , net_writes );
2674
+ sbuf2setuserptr (sb , watchlist_node );
2675
+
2676
2676
/* call user specified app routine */
2677
- if (admin && netinfo_ptr -> admin_appsock_rtn ) {
2678
- rtn = netinfo_ptr -> admin_appsock_rtn ;
2679
- } else if (netinfo_ptr -> appsock_rtn ) {
2680
- rtn = netinfo_ptr -> appsock_rtn ;
2681
- }
2682
-
2683
- if (rtn ) {
2684
- /* set up the watchlist system for this node */
2685
- watchlist_node = calloc (1 , sizeof (watchlist_node_type ));
2686
- if (!watchlist_node ) {
2687
- logmsg (LOGMSG_ERROR , "%s: malloc watchlist_node failed\n" , __func__ );
2688
- sbuf2close (sb );
2689
- return -1 ;
2690
- }
2691
- memcpy (watchlist_node -> magic , "WLST" , 4 );
2692
- watchlist_node -> in_watchlist = 0 ;
2693
- watchlist_node -> netinfo_ptr = netinfo_ptr ;
2694
- watchlist_node -> sb = sb ;
2695
- watchlist_node -> readfn = sbuf2getr (sb );
2696
- watchlist_node -> writefn = sbuf2getw (sb );
2697
- watchlist_node -> addr = * cliaddr ;
2698
- sbuf2setrw (sb , net_reads , net_writes );
2699
- sbuf2setuserptr (sb , watchlist_node );
2700
-
2701
- /* this doesn't read- it just farms this off to a thread */
2702
- rtn (netinfo_ptr , sb );
2703
- return 0 ;
2704
- }
2677
+ /* this doesn't read- it just farms this off to a thread */
2678
+ netinfo_ptr -> appsock_rtn (netinfo_ptr , sb );
2679
+ return 0 ;
2680
+
2681
+ err :
2705
2682
sbuf2close (sb );
2706
2683
return -1 ;
2707
2684
}
0 commit comments