library/src/network/tor/BP-Tor.cc
// Configure hidden service information for the hidden service.
Configure hidden service information for the hidden service.
Configure hidden service information for the hidden service .
BP_ERROR_T BP_TorConfigHiddenService
(
	P_BP_TOR       tor,
	char         * service_dir,
	unsigned short service_port,
	char         * bind_local_addr,
	unsigned short bind_local_port
)
{
	if(!tor)
		return ERR_FAILURE;
	if(!service_dir)
		return ERR_FAILURE;
	if(!bind_local_addr)
		return ERR_FAILURE;
	if(!bind_local_port)
		return ERR_FAILURE;
	if(!BP_StringIsReasonableForUnixEXT4Directory(service_dir, bpstrlen(service_dir), BP_TRUE))
		return ERR_FAILURE;
	if(!BP_StringIsIPv4Address(bind_local_addr))
		return ERR_FAILURE;
	if(tor->service_dir)
		ht_free(tor->system_hreg, tor->service_dir);
	tor->service_dir = ht_strdup(tor->system_hreg, service_dir);
	tor->service_port = service_port;
	if(tor->bind_local_addr)
		ht_free(tor->system_hreg, tor->bind_local_addr);
	tor->bind_local_addr = ht_strdup(tor->system_hreg, bind_local_addr);
	tor->bind_local_port = bind_local_port;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_TorConfigHiddenService ( P_BP_TOR tor , char * service_dir , unsigned short service_port , char * bind_local_addr , unsigned short bind_local_port ) { if ( ! tor ) return ERR_FAILURE ; if ( ! service_dir ) return ERR_FAILURE ; if ( ! bind_local_addr ) return ERR_FAILURE ; if ( ! bind_local_port ) return ERR_FAILURE ; if ( ! BP_StringIsReasonableForUnixEXT4Directory ( service_dir , bpstrlen ( service_dir ) , BP_TRUE ) ) return ERR_FAILURE ; if ( ! BP_StringIsIPv4Address ( bind_local_addr ) ) return ERR_FAILURE ; if ( tor -> service_dir ) ht_free ( tor -> system_hreg , tor -> service_dir ) ; tor -> service_dir = ht_strdup ( tor -> system_hreg , service_dir ) ; tor -> service_port = service_port ; if ( tor -> bind_local_addr ) ht_free ( tor -> system_hreg , tor -> bind_local_addr ) ; tor -> bind_local_addr = ht_strdup ( tor -> system_hreg , bind_local_addr ) ; tor -> bind_local_port = bind_local_port ; return ERR_SUCCESS ; }
Configure hidden service information for the hidden service.
Configure hidden service information for the hidden service .
// Run basic null checks // attempt to check composition of, and stat, the service directory // ensure the bind addr string is an ip version 4 addr // set service directory // set the service port // destroy local addr if it's already set // set the local address // set the local port // return indicating success