public async Task StartAsync(Socks5Server server, Mode mode) { if (mode is not ShareMode shareMode) { throw new InvalidOperationException(); } _server = server; _mode = shareMode; var outboundNetworkInterface = NetworkInterfaceUtils.GetBest(); var arguments = new List <object?> { "--interface", $@"\Device\NPF_{outboundNetworkInterface.Id}", "--destination", $"{await _server.AutoResolveHostnameAsync()}:{_server.Port}", _mode.Argument, SpecialArgument.Flag }; if (_server.Auth()) { arguments.AddRange(new[] { "--username", server.Username, "--password", server.Password }); } await StartGuardAsync(Arguments.Format(arguments)); }
public async Task StartAsync(Server server, Mode mode) { _server = server; _mode = mode; var outboundNetworkInterface = NetworkInterfaceUtils.GetBest(); var argument = new StringBuilder($@"-i \Device\NPF_{outboundNetworkInterface.Id}"); if (_server is Socks5 socks5 && !socks5.Auth()) { argument.Append($" --destination {await socks5.AutoResolveHostnameAsync()}:{socks5.Port}"); }