public StatusController(ProxySettings proxySettings, MongoSettings mongoSettings, ProxyStore store, Status status) { ProxySettings = proxySettings; MongoSettings = mongoSettings; Store = store; Status = status; }
public async Task ShouldReturnProxyUri() { var proxyStore = new ProxyStore(); var randomProxyAddress = await proxyStore.GetRandomProxyAddress(); randomProxyAddress.Should().NotBeNull(); }
public ProxiesController(ProxySettings settings, ProxyStore store, IFileRepository fileRepository, IMessageRepository messageRepository) { Settings = settings; Store = store; FileRepository = fileRepository; MessageRepository = messageRepository; Random = new Random(Guid.NewGuid().GetHashCode()); ReservedPorts = Enumerable.Range(Settings.FirstPort, Settings.LastPort - Settings.FirstPort).ToArray(); }
public RequestDetailScreen(ProxyStore store, int index) { _store = store; _index = index; }
public MainScreen(ProxyStore store) { _store = store; }
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; }