Ejemplo n.º 1
0
static void _torControlCircuitBuild_streamEvent(gpointer moduleData, gint code, gchar* line, gint streamID, gint circID,
		in_addr_t targetIP, in_port_t targetPort, gint status, gint reason,
		gint remoteReason, gchar *source, in_addr_t sourceIP, in_port_t sourcePort,
		gint purpose) {
	TorCtlCircuitBuild *circuitBuild = moduleData;
	ShadowLogFunc log = circuitBuild->log;

	log(G_LOG_LEVEL_DEBUG, __FUNCTION__, "[%d] STREAM: status=\"%s\" streamID=%d  circID=%d",
	        code, torControl_getStreamStatusString(status), streamID, circID);

	if(status == TORCTL_STREAM_STATUS_NEW && circuitBuild->bootstrapped) {
	    /* if we're in the process of building a circuit, add stream ID to list so we can reattach it later */
        if(circuitBuild->state == TORCTL_CIRCBUILD_STATE_ATTACH_STREAMS) {
            torControl_attachStream(circuitBuild->sockd, streamID, circuitBuild->circID);
        } else {
            circuitBuild->streamsToAttach = g_list_append(circuitBuild->streamsToAttach, GINT_TO_POINTER(streamID));
        }
	}
}
Ejemplo n.º 2
0
static void _torControlCircuitBuild_streamEvent(gpointer moduleData, gint code, gchar* line, gint streamID, gint circID,
		in_addr_t targetIP, in_port_t targetPort, gint status, gint reason,
		gint remoteReason, gchar *source, in_addr_t sourceIP, in_port_t sourcePort,
		gint purpose) {
	TorCtlCircuitBuild *circuitBuild = moduleData;
	ShadowLogFunc log = circuitBuild->log;

	log(G_LOG_LEVEL_DEBUG, __FUNCTION__, "[%d] STREAM: status=\"%s\" streamID=%d  circID=%d",
	        code, torControl_getStreamStatusString(status), streamID, circID);

	if(status == TORCTL_STREAM_STATUS_NEW && circuitBuild->bootstrapped) {
		struct timespec now;
		clock_gettime(CLOCK_REALTIME, &now);

		TorCtlCircuitBuild_Circuit *circuit = NULL;
		for(GList *iter = g_list_first(circuitBuild->circuits); iter && !circuit; iter = g_list_next(iter)) {
			TorCtlCircuitBuild_Circuit *tmp = iter->data;
			if(now.tv_sec >= tmp->startTime && (now.tv_sec < tmp->endTime || tmp->endTime == -1)) {
				circuit = tmp;
			}
		}

		if(circuit) {
			torControl_attachStream(circuitBuild->sockd, streamID, circuit->circID);
		} else {
			log(G_LOG_LEVEL_WARNING, __FUNCTION__, "Could not find any circuit time span for stream %d", streamID);
			torControl_attachStream(circuitBuild->sockd, streamID, 0);
		}

//	    /* if we're in the process of building a circuit, add stream ID to list so we can reattach it later */
//        if(circuitBuild->state == TORCTL_CIRCBUILD_STATE_ATTACH_STREAMS) {
//            torControl_attachStream(circuitBuild->sockd, streamID, circuitBuild->circID);
//        } else {
//            circuitBuild->streamsToAttach = g_list_append(circuitBuild->streamsToAttach, GINT_TO_POINTER(streamID));
//        }
	}
}