<commit_before>/*
	multiTrack.exe RECV-PORT DEF-FWD-HOST DEF-FWD-PORT /S

		/S ... ~B

	multiTrack.exe RECV-PORT DEF-FWD-HOST DEF-FWD-PORT [/C CONNECT-MAX] [TRACK-NAME FWD-HOST FWD-PORT | /F FWD-FILE]...

		CONNECT-MAX ... őڑ, ȗ 1000
		TRACK-NAME ... gbN
		FWD-HOST ... ]zXg
		FWD-PORT ... ]|[gԍ
		FWD-FILE ... ]惊Xg`t@C

		 DEF-FWD-HOST  NONE w肷ƁAftHg̓]͖ɂȂ܂B

		 DEF-FWD-HOST  RED w肷ƁA_CNgE[higbN]jɂȂ܂B

	- - - -

	]惊Xg`t@C

		eLXgt@CŁAsƔpZ~RŎn܂s͖܂B
		es͈ȉ̂悤ɋLq܂B

			zXg +  + ]zXg +  + ]|[gԍ
*/

#include "libs\Tunnel.h"

#define TRACKNAME_LENMAX 100
#define HOST_LENMAX 255
#define HOST_NONE "NONE"
#define HOST_REDIRECT "RED"

typedef struct TrackInfo_st
{
	char *TrackName;
	char *FwdHost;
	uint FwdPortNo;
}
TrackInfo_t;

static autoList_t *TrackInfoList;

static void AddTrackInfo(char *trackName, char *fwdHost, char *sFwdPortNo)
{
	TrackInfo_t *i = nb(TrackInfo_t);

	errorCase(m_isEmpty(trackName) || TRACKNAME_LENMAX < strlen(trackName));
	errorCase(m_isEmpty(fwdHost) || HOST_LENMAX < strlen(fwdHost));
	errorCase(m_isEmpty(sFwdPortNo));

	i->TrackName = strx(trackName);
	i->FwdHost = strx(fwdHost);
	i->FwdPortNo = toValue(sFwdPortNo);

	errorCase(!i->FwdPortNo || 0xffff < i->FwdPortNo);

	cout("TrackName: %s\n", i->TrackName);
	cout("FwdHost: %s\n", i->FwdHost);
	cout("FwdPortNo: %u\n", i->FwdPortNo);

	addElement(TrackInfoList, (uint)i);
}

static void PreDataFltr(autoBlock_t *buff, uint uPData)
{
	char **pData = (char **)uPData;

	if(*pData)
	{
		autoBlock_t *nb = newBlock();

		ab_addLine(nb, *pData);
		ab_addBytes(nb, buff);

		ab_swap(nb, buff);

		releaseAutoBlock(nb);

		*pData = NULL;
	}
}
static void TransmitTh(int sock, char *fwdHost, uint fwdPortNo, char *data)
{
	uchar ip[4] = { 0 };
	int fwdSock;

	cout("%s %s(%u)\n", c_makeJStamp(NULL, 0), fwdHost, fwdPortNo);

	fwdSock = sockConnect(ip, fwdHost, fwdPortNo);

	if(fwdSock == -1)
		return;

	CrossChannel(sock, fwdSock, PreDataFltr, (uint)&data, NULL, 0);
	sockDisconnect(fwdSock);
}
static void PerformTh(int sock, char *strip)<commit_msg>Magical<commit_after>/*
	multiTrack.exe RECV-PORT DEF-FWD-HOST DEF-FWD-PORT /S

		/S ... ~B

	multiTrack.exe RECV-PORT DEF-FWD-HOST DEF-FWD-PORT [/C CONNECT-MAX] [TRACK-NAME FWD-HOST FWD-PORT | /F FWD-FILE]...

		CONNECT-MAX ... őڑ, ȗ 1000
		TRACK-NAME ... gbN
		FWD-HOST ... ]zXg
		FWD-PORT ... ]|[gԍ
		FWD-FILE ... ]惊Xg`t@C

		 DEF-FWD-HOST  NONE w肷ƁAftHg̓]͖ɂȂ܂B

		 DEF-FWD-HOST  RED w肷ƁA_CNgE[higbN]jɂȂ܂B

	- - - -

	]惊Xg`t@C

		eLXgt@CŁAsƔpZ~RŎn܂s͖܂B
		es͈ȉ̂悤ɋLq܂B

			zXg +  + ]zXg +  + ]|[gԍ
*/

#include "libs\Tunnel.h"

#define TRACKNAME_LENMAX 100
#define HOST_LENMAX 255
#define HOST_NONE "NONE"
#define HOST_REDIRECT "RED"

typedef struct TrackInfo_st
{
	char *TrackName;
	char *FwdHost;
	uint FwdPortNo;
}
TrackInfo_t;

static autoList_t *TrackInfoList;

static void AddTrackInfo(char *trackName, char *fwdHost, char *sFwdPortNo)
{
	TrackInfo_t *i = nb(TrackInfo_t);

	errorCase(m_isEmpty(trackName) || TRACKNAME_LENMAX < strlen(trackName));
	errorCase(m_isEmpty(fwdHost) || HOST_LENMAX < strlen(fwdHost));
	errorCase(m_isEmpty(sFwdPortNo));

	i->TrackName = strx(trackName);
	i->FwdHost = strx(fwdHost);
	i->FwdPortNo = toValue(sFwdPortNo);

	errorCase(!i->FwdPortNo || 0xffff < i->FwdPortNo);

	cout("TrackName: %s\n", i->TrackName);
	cout("FwdHost: %s\n", i->FwdHost);
	cout("FwdPortNo: %u\n", i->FwdPortNo);

	addElement(TrackInfoList, (uint)i);
}

static void PreDataFltr(autoBlock_t *buff, uint uPData)
{
	char **pData = (char **)uPData;

	if(*pData)
	{
		autoBlock_t *b = newBlock();

		ab_addLine(b, *pData);
		ab_addBytes(b, buff);

		ab_swap(b, buff);

		releaseAutoBlock(b);

		*pData = NULL;
	}
}
static void TransmitTh(int sock, char *fwdHost, uint fwdPortNo, char *data)
{
	uchar ip[4] = { 0 };
	int fwdSock;

	cout("%s %s(%u) %d\n", c_makeJStamp(NULL, 0), fwdHost, fwdPortNo, data ? (sint)strlen(data) : -1);

	fwdSock = sockConnect(ip, fwdHost, fwdPortNo);

	if(fwdSock == -1)
		return;

	CrossChannel(sock, fwdSock, PreDataFltr, (uint)&data, NULL, 0);
	sockDisconnect(fwdSock);
}
static void PerformTh(int sock, char *strip)
{'fraction_non_alphanumeric': 0.1677277179236043, 'fraction_numerical': 0.008080313418217433, 'mean_word_length': 4.197201017811705, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2206449', 'n_tokens_mistral': 2055, 'n_tokens_neox': 1906, 'n_words': 347}