/// <summary> /// Creates new ReverseSSHTunnel object /// </summary> /// <param name="remoteHost">Remote host - visible in internet by IP</param> /// <param name="localSideHost">Local side host - visible or invisible in internet by IP</param> public ReverseSSHTunnel(TunnelSettings remoteHost, TunnelSettings localSideHost) { _remoteHost = remoteHost; _localSideHost = localSideHost; DefaultSSHCommand = CreateCommandString(SSH_FORMAT_STRING, DEFAULT_BIND_ADDRESS, RemoteHost.Port, LocalSideHost.IP, LocalSideHost.Port, RemoteHost.User, RemoteHost.IP); }
public void SetState(bool state) { if (state == currentState) { return; } if (state) { clientConnected = -1; tunnelSettings = new TunnelSettings(); tunnelSettings.Load("TunnelSettings.txt"); guiData.statistics = new Statistics(); udpServer = new UDPServer(tunnelSettings, guiData.statistics); if (tunnelSettings.tunnelServer == "") { tunnelServer = new TunnelServer(tunnelSettings, udpServer); } else { tunnelClient = new TunnelClient(tunnelSettings, udpServer); } currentState = state; } else { currentState = state; if (tunnelClient != null) { tunnelClient.Stop(); tunnelClient = null; } tunnelServer = null; udpServer.Stop(); udpServer = null; tunnelSettings = null; guiData.labelText = "Disconnected"; guiData.iconName = "gtk-no"; UpdateGUI(); } }
public static void Main2 (string[] args) { string connectToClient = ""; ConsoleKeyInfo cki; TunnelSettings inConfig = new TunnelSettings(); try { inConfig = inConfig.LoadFromXML("settings.xml"); } catch(Exception){ ScreenPrint("Failed to read settings. Using default settings"); } Arguments CommandLine = new Arguments(args); if(CommandLine["connect"] != null){ connectToClient = CommandLine["connect"]; } tunnel = new Tunnel(); tunnel.LogEvent += ScreenPrint; try { if(tunnel.Start(inConfig)){ Console.WriteLine("Press Q to quit"); Console.WriteLine("Press C to connect to client"); Console.WriteLine("Press T to throw off all clients"); if(connectToClient != "") tunnel.ConnectToClient(connectToClient); do { cki = Console.ReadKey(true); if(cki.Key == ConsoleKey.C){ tunnel.LogEvent -= ScreenPrint; Console.Write("Enter client IP-Address: "); tunnel.ConnectToClient(Console.ReadLine()); tunnel.LogEvent += ScreenPrint; } if(cki.Key == ConsoleKey.T){ tunnel.ThrowOffAllClients(); } } while (cki.Key != ConsoleKey.Q); tunnel.Stop(); } } catch(Exception e) { Console.WriteLine(e.Message); } finally { if(tunnel.IsRunning) tunnel.Stop(); } TunnelSettings outConfig = inConfig; try{ outConfig.SaveToXML("settings.xml"); } catch{ } }
public static void Main2(string[] args) { string connectToClient = ""; ConsoleKeyInfo cki; TunnelSettings inConfig = new TunnelSettings(); try { inConfig = inConfig.LoadFromXML("settings.xml"); } catch (Exception) { ScreenPrint("Failed to read settings. Using default settings"); } Arguments CommandLine = new Arguments(args); if (CommandLine["connect"] != null) { connectToClient = CommandLine["connect"]; } tunnel = new Tunnel(); tunnel.LogEvent += ScreenPrint; try { if (tunnel.Start(inConfig)) { Console.WriteLine("Press Q to quit"); Console.WriteLine("Press C to connect to client"); Console.WriteLine("Press T to throw off all clients"); if (connectToClient != "") { tunnel.ConnectToClient(connectToClient); } do { cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.C) { tunnel.LogEvent -= ScreenPrint; Console.Write("Enter client IP-Address: "); tunnel.ConnectToClient(Console.ReadLine()); tunnel.LogEvent += ScreenPrint; } if (cki.Key == ConsoleKey.T) { tunnel.ThrowOffAllClients(); } } while (cki.Key != ConsoleKey.Q); tunnel.Stop(); } } catch (Exception e) { Console.WriteLine(e.Message); } finally { if (tunnel.IsRunning) { tunnel.Stop(); } } TunnelSettings outConfig = inConfig; try{ outConfig.SaveToXML("settings.xml"); } catch { } }