private static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: boxxy.exe \"Port\" \"Sync directory\" \"Destination host\""); return; } bool interactive = args.Length == 4 && args[3] == "i"; if (interactive) { Console.WriteLine("Starting in INTERACTIVE mode, all requests are automatically PAUSED."); } else { Console.WriteLine("Starting in NON-INTERACTIVE mode, all requests are automatically FORWARDED."); } Console.WriteLine("Press ENTER to continue."); Console.ReadLine(); string listeningPort = args[0]; string syncPath = args[1]; string destination = args[2]; if (!Directory.Exists(syncPath)) { Console.WriteLine("Invalid sync directory, exiting."); return; } string[] files = Directory.GetFiles(syncPath, "*.json"); var requests = new List<IncomingHttpRequest>(); foreach (var file in files) { try { using (var reader = new StreamReader(file)) { string str = reader.ReadToEnd(); requests.Add(IncomingHttpRequest.FromString(str)); Debug.WriteLine("Deserialized request from file {0}", str); } } catch (SecurityException e) { ReadFailed(file, e); } catch (UnauthorizedAccessException e) { ReadFailed(file, e); } catch (IOException e) { ReadFailed(file, e); } } var store = new ProxyStore(syncPath, requests); var proxy = new HttpProxy(store, interactive); proxy.Start(string.Format("http://localhost:{0}/", listeningPort), destination); try { new MainScreen(store).Run(); } catch (QuitMenu) { // Intentionally ignored, the exception is only used for control flow. } }
public ListRequestsScreen(ProxyStore store) { _store = store; }
public RequestDetailScreen(ProxyStore store, int index) { _store = store; _index = index; }
public HttpProxy(ProxyStore proxyStore, bool interactive) { _proxyStore = proxyStore; _interactive = interactive; }
public MainScreen(ProxyStore store) { _store = store; }