dns.mitm: edit default behavior/hosts filenames

This commit is contained in:
Michael Scire 2021-01-31 08:04:25 -08:00
parent a804e62293
commit a231d7164b
3 changed files with 14 additions and 14 deletions

View file

@ -48,7 +48,7 @@
; Controls whether dns.mitm uses the default redirections in addition to ; Controls whether dns.mitm uses the default redirections in addition to
; whatever is specified in the user's hosts file. ; whatever is specified in the user's hosts file.
; 0 = Disabled (use hosts file contents), 1 = Enabled (use defaults and hosts file contents) ; 0 = Disabled (use hosts file contents), 1 = Enabled (use defaults and hosts file contents)
; add_defaults_to_dns_hosts = u8!0x0 ; add_defaults_to_dns_hosts = u8!0x1
[hbloader] [hbloader]
; Controls the size of the homebrew heap when running as applet. ; Controls the size of the homebrew heap when running as applet.
; If set to zero, all available applet memory is used as heap. ; If set to zero, all available applet memory is used as heap.

View file

@ -199,7 +199,7 @@ namespace ams::mitm::socket::resolver {
Log(log_file, "Selecting hosts file...\n"); Log(log_file, "Selecting hosts file...\n");
const bool is_emummc = emummc::IsActive(); const bool is_emummc = emummc::IsActive();
const u32 emummc_id = emummc::GetActiveId(); const u32 emummc_id = emummc::GetActiveId();
util::SNPrintf(g_specific_emummc_hosts_path, sizeof(g_specific_emummc_hosts_path), "/hosts/emummc_%04x", emummc_id); util::SNPrintf(g_specific_emummc_hosts_path, sizeof(g_specific_emummc_hosts_path), "/hosts/emummc_%04x.txt", emummc_id);
if (is_emummc) { if (is_emummc) {
if (mitm::fs::HasAtmosphereSdFile(g_specific_emummc_hosts_path)) { if (mitm::fs::HasAtmosphereSdFile(g_specific_emummc_hosts_path)) {
@ -207,18 +207,18 @@ namespace ams::mitm::socket::resolver {
} }
Log(log_file, "Skipping %s because it does not exist...\n", g_specific_emummc_hosts_path); Log(log_file, "Skipping %s because it does not exist...\n", g_specific_emummc_hosts_path);
if (mitm::fs::HasAtmosphereSdFile("/hosts/emummc")) { if (mitm::fs::HasAtmosphereSdFile("/hosts/emummc.txt")) {
return "/hosts/emummc"; return "/hosts/emummc.txt";
} }
Log(log_file, "Skipping %s because it does not exist...\n", "/hosts/emummc"); Log(log_file, "Skipping %s because it does not exist...\n", "/hosts/emummc.txt");
} else { } else {
if (mitm::fs::HasAtmosphereSdFile("/hosts/sysmmc")) { if (mitm::fs::HasAtmosphereSdFile("/hosts/sysmmc.txt")) {
return "/hosts/sysmmc"; return "/hosts/sysmmc.txt";
} }
Log(log_file, "Skipping %s because it does not exist...\n", "/hosts/sysmmc"); Log(log_file, "Skipping %s because it does not exist...\n", "/hosts/sysmmc.txt");
} }
return "/hosts/default"; return "/hosts/default.txt";
} }
} }
@ -240,14 +240,14 @@ namespace ams::mitm::socket::resolver {
Log(log_file, "DNS Mitm:\n"); Log(log_file, "DNS Mitm:\n");
/* If a default hosts file doesn't exist on the sd card, create one. */ /* If a default hosts file doesn't exist on the sd card, create one. */
if (!mitm::fs::HasAtmosphereSdFile("/hosts/default")) { if (!mitm::fs::HasAtmosphereSdFile("/hosts/default.txt")) {
Log(log_file, "Creating /hosts/default because it does not exist.\n"); Log(log_file, "Creating /hosts/default.txt because it does not exist.\n");
mitm::fs::CreateAtmosphereSdDirectory("/hosts"); mitm::fs::CreateAtmosphereSdDirectory("/hosts");
R_ABORT_UNLESS(mitm::fs::CreateAtmosphereSdFile("/hosts/default", sizeof(DefaultHostsFile) - 1, ams::fs::CreateOption_None)); R_ABORT_UNLESS(mitm::fs::CreateAtmosphereSdFile("/hosts/default.txt", sizeof(DefaultHostsFile) - 1, ams::fs::CreateOption_None));
::FsFile default_file; ::FsFile default_file;
R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(std::addressof(default_file), "/hosts/default", ams::fs::OpenMode_ReadWrite)); R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdFile(std::addressof(default_file), "/hosts/default.txt", ams::fs::OpenMode_ReadWrite));
R_ABORT_UNLESS(::fsFileWrite(std::addressof(default_file), 0, DefaultHostsFile, sizeof(DefaultHostsFile) - 1, ::FsWriteOption_Flush)); R_ABORT_UNLESS(::fsFileWrite(std::addressof(default_file), 0, DefaultHostsFile, sizeof(DefaultHostsFile) - 1, ::FsWriteOption_Flush));
::fsFileClose(std::addressof(default_file)); ::fsFileClose(std::addressof(default_file));
} }

View file

@ -356,7 +356,7 @@ namespace ams::settings::fwdbg {
/* Controls whether dns.mitm uses the default redirections in addition to */ /* Controls whether dns.mitm uses the default redirections in addition to */
/* whatever is specified in the user's hosts file. */ /* whatever is specified in the user's hosts file. */
/* 0 = Disabled (use hosts file contents), 1 = Enabled (use defaults and hosts file contents) */ /* 0 = Disabled (use hosts file contents), 1 = Enabled (use defaults and hosts file contents) */
R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "add_defaults_to_dns_hosts", "u8!0x0")); R_ABORT_UNLESS(ParseSettingsItemValue("atmosphere", "add_defaults_to_dns_hosts", "u8!0x1"));
/* Hbloader custom settings. */ /* Hbloader custom settings. */