<commit_before>﻿using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using Tempest.Providers.Network;

namespace Tempest.Social.Server
{
	class Program
	{
		private static readonly PublicKeyIdentityProvider IdentityProvider = new PublicKeyIdentityProvider();

		static void Main (string[] args)
		{
			Console.WriteLine ("Getting server key...");

			RSAAsymmetricKey key = GetKey ("server.key");

			Console.WriteLine ("Got it.");

			//var provider = new NetworkConnectionProvider (
			//	new[] { SocialProtocol.Instance },
			//	new IPEndPoint (IPAddress.Any, 42912),
			//	10000,
			//	() => new RSACrypto(),
			//	key);

			var provider = new UdpConnectionProvider (
				SocialProtocol.DefaultPort,
				SocialProtocol.Instance,
				key);

			SocialServer server = new SocialServer (new MemoryWatchListProvider(), IdentityProvider);
			server.ConnectionMade += OnConnectionMade;
			server.AddConnectionProvider (provider);
			server.Start();

			Console.WriteLine ("Server ready.");

			while (true)
				Thread.Sleep (1000);
		}

		private static void OnConnectionMade (object sender, ConnectionMadeEventArgs e)
		{
			Console.WriteLine ("Connection made");
		}

		private static RSAAsymmetricKey GetKey (string path)
		{
			RSAAsymmetricKey key = null;
			if (!File.Exists (path))
			{
				RSACrypto crypto = new RSACrypto();
				key = crypto.ExportKey (true);
				using (FileStream stream = File.Create (path))
					key.Serialize (null, new StreamValueWriter (stream));
			}

			if (key == null)
			{<commit_msg>Switch server back to TCP<commit_after>﻿using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using Tempest.Providers.Network;

namespace Tempest.Social.Server
{
	class Program
	{
		private static readonly PublicKeyIdentityProvider IdentityProvider = new PublicKeyIdentityProvider();

		static void Main (string[] args)
		{
			Console.WriteLine ("Getting server key...");

			RSAAsymmetricKey key = GetKey ("server.key");

			Console.WriteLine ("Got it.");

			var provider = new NetworkConnectionProvider (
				new[] { SocialProtocol.Instance },
				new Target (Target.AnyIP, 42912),
				10000,
				key);

			SocialServer server = new SocialServer (new MemoryWatchListProvider(), IdentityProvider);
			server.ConnectionMade += OnConnectionMade;
			server.AddConnectionProvider (provider);
			server.Start();

			Console.WriteLine ("Server ready.");

			while (true)
				Thread.Sleep (1000);
		}

		private static void OnConnectionMade (object sender, ConnectionMadeEventArgs e)
		{
			Console.WriteLine ("Connection made");
		}

		private static RSAAsymmetricKey GetKey (string path)
		{
			RSAAsymmetricKey key = null;
			if (!File.Exists (path))
			{
				RSACrypto crypto = new RSACrypto();
				key = crypto.ExportKey (true);
				using (FileStream stream = File.Create (path))
					key.Serialize (null, new StreamValueWriter (stream));
			}

			if (key == null)
			{
{'fraction_non_alphanumeric': 0.11167341430499325, 'fraction_numerical': 0.009446693657219974, 'mean_word_length': 3.813311688311688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2220419', 'n_tokens_mistral': 1049, 'n_tokens_neox': 828, 'n_words': 239}