add setting for whether to bind the wifi socket to any address or to loopback only

This commit is contained in:
StapleButter 2017-07-16 00:57:26 +02:00
parent bb963c35a4
commit 08bdef481f
7 changed files with 35 additions and 6 deletions

View File

@ -35,6 +35,8 @@ int DirectBoot;
int Threaded3D;
int SocketBindAnyAddr;
typedef struct
{
char Name[16];
@ -81,6 +83,8 @@ ConfigEntry ConfigFile[] =
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0},
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0},
{"", -1, NULL, 0, NULL, 0}
};

View File

@ -37,6 +37,8 @@ extern int DirectBoot;
extern int Threaded3D;
extern int SocketBindAnyAddr;
}
#endif // CONFIG_H

View File

@ -140,6 +140,9 @@ enum
};
extern bool MPInited;
bool Init();
void DeInit();
void Reset();

View File

@ -40,6 +40,10 @@ EmuConfigDialog::EmuConfigDialog(wxWindow* parent)
vboxmain->Add(cbThreaded3D, 0, wxALL&(~wxBOTTOM), 15);
cbThreaded3D->SetValue(Config::Threaded3D != 0);
cbBindAnyAddr = new wxCheckBox(this, wxID_ANY, "Wifi: bind socket to any address");
vboxmain->Add(cbBindAnyAddr, 0, wxALL&(~wxBOTTOM), 15);
cbBindAnyAddr->SetValue(Config::SocketBindAnyAddr != 0);
{
wxPanel* p = new wxPanel(this);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
@ -67,6 +71,7 @@ void EmuConfigDialog::OnOk(wxCommandEvent& event)
{
Config::DirectBoot = cbDirectBoot->GetValue() ? 1:0;
Config::Threaded3D = cbThreaded3D->GetValue() ? 1:0;
Config::SocketBindAnyAddr = cbBindAnyAddr->GetValue() ? 1:0;
Config::Save();
Close();

View File

@ -38,6 +38,7 @@ private:
wxCheckBox* cbDirectBoot;
wxCheckBox* cbThreaded3D;
wxCheckBox* cbBindAnyAddr;
};
#endif // WX_EMUCONFIG_H

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include "../Platform.h"
#include "../Config.h"
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
@ -154,7 +155,7 @@ bool MP_Init()
sockaddr_t saddr;
saddr.sa_family = AF_INET;
*(u32*)&saddr.sa_data[2] = htonl(INADDR_LOOPBACK);//htonl(INADDR_ANY);
*(u32*)&saddr.sa_data[2] = htonl(Config::SocketBindAnyAddr ? INADDR_ANY : INADDR_LOOPBACK);
*(u16*)&saddr.sa_data[0] = htons(7064);
res = bind(MPSocket, &saddr, sizeof(sockaddr_t));
if (res < 0)

View File

@ -24,6 +24,8 @@
#include "../GPU.h"
#include "../GPU3D.h"
#include "../SPU.h"
#include "../Wifi.h"
#include "../Platform.h"
#include "InputConfig.h"
#include "EmuConfig.h"
@ -113,7 +115,7 @@ bool wxApp_melonDS::OnInit()
"bios7.bin -- ARM7 BIOS\n"
"bios9.bin -- ARM9 BIOS\n"
"firmware.bin -- firmware image\n\n"
"Place the following files in the directory you run melonDS from.\n"
"Dump the files from your DS and place them in the directory you run melonDS from.\n"
"Make sure that the files can be accessed.",
"melonDS",
wxICON_ERROR);
@ -315,15 +317,26 @@ void MainFrame::OnReset(wxCommandEvent& event)
void MainFrame::OnEmuConfig(wxCommandEvent& event)
{
bool oldpause = emuthread->EmuIsPaused();
if (!oldpause) emuthread->EmuPause();
if (!oldpause && emuthread->EmuIsRunning())
emuthread->EmuPause();
EmuConfigDialog dlg(this);
dlg.ShowModal();
// apply threaded 3D setting
GPU3D::SoftRenderer::SetupRenderThread();
if (emuthread->EmuIsRunning())
{
// apply threaded 3D setting
GPU3D::SoftRenderer::SetupRenderThread();
if (!oldpause) emuthread->EmuRun();
if (Wifi::MPInited)
{
Platform::MP_DeInit();
Platform::MP_Init();
}
}
if (!oldpause && emuthread->EmuIsRunning())
emuthread->EmuRun();
}
void MainFrame::OnInputConfig(wxCommandEvent& event)