[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Add C# controller lib port from Oliver Rau.



Update of /home/or/cvsroot/control/cs/test
In directory moria:/tmp/cvs-serv5623/test

Added Files:
	AssemblyInfo.cs Main.cs test.cmbx test.prjx 
Log Message:
Add C# controller lib port from Oliver Rau.

--- NEW FILE: AssemblyInfo.cs ---
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):

[assembly: AssemblyVersion("1.0.*")]

// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
// This is not required, if you don't want signing let these attributes like they're.
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

--- NEW FILE: Main.cs ---
/*
 * File Main.cs
 * 
 * Copyright (C) 2005 Oliver Rau (olra0001@xxxxxxxxxxxxxxxxxxx)
 * 
 * See LICENSE file for copying information 
 * 
 * Created on 08.08.2005 20:37
 * 
 * $Id: Main.cs,v 1.1 2005/11/09 21:47:04 nickm Exp $
 */
 
using System;
using System.Collections;
using System.Net.Sockets;

using Tor.Control;

namespace Tor.Test
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			Console.WriteLine("This version will only show Events occuring by tor!");
			
			// Create and open the tcp socket to tor
			TcpClient tcp = new TcpClient("127.0.0.1", 9051);
			
			// let the factory decide which Connection type we use
			
			ITorControlConnection conn = TorControlConnectionFactory.GetConnection(tcp);
			
			if (((object)conn).GetType() == typeof(TorControlConnection0))
				Console.WriteLine("Using Version 0");
			else
				Console.WriteLine("Using Version 1");
			
			// Attach the Handler for Messages
			conn.Message += new MessageEventHandler(MessageTest);
			// attach the handler for bandwith usage
			conn.BandwidthUsed += new BandwidthUsedEventHandler(BandwidthUsage);
			conn.CircuitStatus += new CircuitStatusEventHandler(CircuitStatus);
			conn.OrConnStatus  += new OrConnStatusEventHandler(OrConnStatus);
			
			// authenticate with tor
			conn.Authenticate(new byte[0]);
			
			// register my events
			conn.SetEvents(new ArrayList(new string[] {"ORCONN", "CIRC", "WARN", "ERR", "BW"}));
			
			// get the version
			string version = conn.GetInfo("version");
			
			Console.WriteLine("You are running tor version {0}", version);
			Console.ReadLine();
		}
		
		public static void MessageTest(object sender, MessageEventArgs args)
		{
			Console.WriteLine(":: {0} :: {1}", args.Severity, args.Msg);
		}
		
		public static void BandwidthUsage(object sender, BandwidthUsedEventArgs args)
		{
			Console.WriteLine("in: {0}, out: {1}", args.Read, args.Written);
		}
		
		public static void CircuitStatus(object sender, CircuitStatusEventArgs args)
		{
			Console.WriteLine("circ: {0} ({1}) [{2}]", args.CircID, args.Path, args.Status);
		}
		
		public static void OrConnStatus(object sender, OrConnStatusEventArgs args)
		{
			Console.WriteLine("orconn: {0} [{1}]", args.OrName, args.Status);
		}
	}
}

--- NEW FILE: test.cmbx ---
<Combine fileversion="1.0" name="test" description="">
  <StartMode startupentry="test" single="True">
    <Execute entry="test" type="None" />
  </StartMode>
  <Entries>
    <Entry filename=".\test.prjx" />
  </Entries>
  <Configurations active="Debug">
    <Configuration name="Release">
      <Entry name="test" configurationname="Debug" build="False" />
    </Configuration>
    <Configuration name="Debug">
      <Entry name="test" configurationname="Debug" build="False" />
    </Configuration>
  </Configurations>
</Combine>
--- NEW FILE: test.prjx ---
<Project name="test" standardNamespace="test" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
  <Contents>
    <File name=".\Main.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
    <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
  </Contents>
  <References>
    <Reference type="Project" refto="control" localcopy="True" />
  </References>
  <DeploymentInformation target="" script="" strategy="File" />
  <Configuration runwithwarnings="True" name="Debug">
    <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Exe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
    <Execution commandlineparameters="" consolepause="True" />
    <Output directory=".\bin\Debug" assembly="test" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
  </Configuration>
  <Configurations active="Debug">
    <Configuration runwithwarnings="True" name="Debug">
      <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="Standard" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Exe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
      <Execution commandlineparameters="" consolepause="True" />
      <Output directory=".\bin\Debug" assembly="test" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
    </Configuration>
    <Configuration runwithwarnings="True" name="Release">
      <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="" target="Exe" definesymbols="" generatexmldocumentation="False" win32Icon="" noconfig="False" nostdlib="False" />
      <Execution commandlineparameters="" consolepause="True" />
      <Output directory=".\bin\Release" assembly="test" executeScript="" executeBeforeBuild="" executeAfterBuild="" executeBeforeBuildArguments="" executeAfterBuildArguments="" />
    </Configuration>
  </Configurations>
</Project>