public void SetUp() { _settings = new AppSettings(); _settings.Port = 1234; _settings.ServerAddress = IPAddress.Parse("127.0.0.1"); _settings.ClientConnectionTimeout = 1000; }
public Instance(AppSettings settings, string instanceName, ConnectionType type) { //is this necessary to store? _connectionType = type; _settings = settings; if (!_settings.WorkingPath.Exists) { _settings.WorkingPath.Create(); } if (!_settings.TransferPath.Exists) { _settings.TransferPath.Create(); } Connection = new Connection(type, settings, instanceName); Connection.Service.Instance = this; Connection.LostConnection += new EventHandler<ExceptionEventArgs>(Connection_LostConnection); Connection.MessageReceived += new EventHandler<MessageEventArgs>(Connection_MessageReceived); Connection.MessageSending += new EventHandler<MessageEventArgs>(Connection_MessageSending); Connection.ConnectionMade += new EventHandler(Connection_ConnectionMade); Connection.ConnectionTermainated += new EventHandler(Connection_ConnectionTermainated); }
public BitTunnelClientService(AppSettings settings, string clientName) : base(settings) { _availableFiles = new Dictionary<string, FileDescriptor>(); _clientName = clientName; }
public ServerInstance(AppSettings settings) : base(settings, ConnectionType.Server) { ServerService.FileRequested += new EventHandler<FileRequestEventArgs>(ServerService_FileRequested); ServerService.ClientConnected += new EventHandler<IdentificationEventArgs>(ServerService_ClientConnected); ServerService.ClientIdentified += new EventHandler<IdentificationEventArgs>(ServerService_ClientIdentified); ServerService.ClientDisconnected += new EventHandler(ServerService_ClientDisconnected); ServerService.AvailableFilesUpdated += new EventHandler<FileListModificationEventArgs>(ServerService_AvailableFilesUpdated); }
public BitTunnelClientProtocolFactory(AppSettings settings, string clientName) : base(settings) { _clientName = clientName; _requestedFiles = new Dictionary<string, FileDescriptor>(); LoadMessageHandlers(); }
public BitTunnelServerService(AppSettings settings, string serverName) : base(settings) { _handles = new List<ConnectorHandle>(); _serverName = serverName; _settings = settings; _activeNegotiators = new List<FileServerNegotiator>(); }
public ClientInstance(AppSettings settings, string instanceName) : base(settings, instanceName, ConnectionType.Client) { _networkFiles = new FileDescriptorLookup(true); _localFiles = new FileDescriptorLookup(false); ClientService.FullFileListReceived += new EventHandler<FileListEventArgs>(Service_FullFileListReceived); ClientService.FileListModificationsReceived += new EventHandler<FileListModificationEventArgs>(Service_FileListModificationsReceived); ClientService.FileRequestReceived += new EventHandler<FileRequestEventArgs>(Service_FileRequestReceived); ClientService.FileRequestResponseReceived += new EventHandler<FileRequestResponseEventArgs>(Service_FileRequestResponseReceived); ClientService.FileTransferInitiated += new EventHandler<FileTransferEventArgs>(ClientService_FileTransferInitiated); ClientService.FileTransferCompleted += new EventHandler<FileTransferCompletedEventArgs>(ClientService_FileTransferCompleted); ClientService.FileTransferProgressed += new EventHandler<FileTransferEventArgs>(ClientService_FileTransferProgressed); }
public ServerForm() { InitializeComponent(); _settings = new AppSettings(); //Default values _settings.Port = 1234; _settings.ServerAddress = IPAddress.Parse("127.0.0.1"); _settings.ServerIsRemote = false; _instance = new ServerInstance(_settings); _instance.ConnectionMade += new EventHandler(_instance_ConnectionMade); _instance.ConnectionTerminated += new EventHandler(_instance_ConnectionTerminated); LoadControls(); LoadMenu(); SetupForConnection(); }
public BitTunnelForm() { InitializeComponent(); _settings = new AppSettings(); //Default values _settings.Port = 1234; _settings.ServerAddress = IPAddress.Parse("127.0.0.1"); _settings.ServerIsRemote = false; _client = new ClientInstance(_settings); _client.ConnectionMade += new EventHandler(_client_ConnectionMade); _client.ConnectionTerminated += new EventHandler(_client_ConnectionTerminated); _client.LostConnection += new EventHandler<ExceptionEventArgs>(_client_LostConnection); AddInfoTabControls(); AddMainTabControls(); LoadInfoTabs(); LoadMainTabs(); SetupForConnection(); }
public Instance(AppSettings settings, ConnectionType type) : this(settings, "", type) { }
public LoggingControl(ServerInstance server, AppSettings settings) : this() { Settings = settings; Server = server; }
public static void Main(string[] args) { AppSettings settings = new AppSettings(); settings.ClientConnectionTimeout = 10000; if (!LoadSettings(settings, args)) { Console.WriteLine("Bad or no parameters given"); Console.WriteLine("Usage: Knock -a[ipaddress] -p[port]"); return; } _localClient = new ClientInstance(settings); _localClient.LostConnection += new EventHandler<ObviousCode.Interlace.BitTunnelLibrary.Events.ExceptionEventArgs>(_localClient_LostConnection); _localClient.ConnectionMade += new EventHandler(_localClient_ConnectionMade); _localClient.ConnectionTerminated += new EventHandler(_localClient_ConnectionTerminated); Console.Write ("Starting Server ... "); _server = new ServerInstance(settings); _server.ConnectionMade += new EventHandler(_server_ConnectionMade); _server.ConnectionTerminated += new EventHandler(_server_ConnectionTerminated); _server.LostConnection += new EventHandler<ObviousCode.Interlace.BitTunnelLibrary.Events.ExceptionEventArgs>(_server_LostConnection); _server.Connect(); Console.WriteLine(); Console.WriteLine ("Server started"); Console.WriteLine(); LoadCommands(); MountedFileCache.Cache.Client = _localClient; MountedFileCache.Cache.Server = _server; MountedFileCache.Cache.PromptRequested += new EventHandler(Cache_PromptRequested); try { Console.Write ("Preparing local client ... "); if (!_localClient.Connect()) { Console.WriteLine("Unable to connect ..."); Console.WriteLine("Stopping ..."); Console.WriteLine("Bye"); Console.ReadLine(); return; } } catch (Exception e) { Console.WriteLine ("Unable to prepare locale client: {0}", e.Message); Console.ReadLine(); Console.WriteLine("Bye"); return; } _currentPath = "/"; Console.WriteLine(); Console.WriteLine("Welcome. Type \"quit\" to exit"); Console.WriteLine(); string line = ""; Console.Write(Cursor); while(true) { if (_forceQuit) break; line = Console.ReadLine(); if (line == string.Empty) { Console.Write(Cursor); continue; } if (line == "quit") { ConsoleKeyInfo response; do { Console.WriteLine(); Console.Write("Quit? (Y/N)"); response = Console.ReadKey(); } while (response.Key != ConsoleKey.Y && response.Key != ConsoleKey.N); if (response.Key == ConsoleKey.Y) { break; } else { Console.WriteLine(); Console.Write(Cursor); continue; } } try { ParseCommand(line); } catch (Exception e) { Console.WriteLine ("System Error: {0}", e.Message); } Console.Write(Cursor); } _server.Dispose(); _localClient.Dispose(); Console.WriteLine("Bye"); }
private static bool LoadSettings(AppSettings settings, string[] args) { Arguments a = new Arguments(args); string ip; string portString; try { ip = a.Get("-a"); portString = a.Get("-p"); } catch (System.Exception ex) { return false; } IPAddress address; int port; if (ip == null || !IPAddress.TryParse(ip, out address)) { return false; } if (portString == null || !Int32.TryParse(portString, out port)) { return false; } settings.Port = port; settings.ServerAddress = address; settings.ServerIsRemote = false; return true; }
public ClientInstance(AppSettings settings) : this(settings, "") { }
public SettingsControl(ServerInstance server, AppSettings settings) : this() { Settings = settings; _settings.SelectedObject = Settings; }