add RPC_ALLOW_REMOTE connections flag

This commit is contained in:
jed
2012-06-06 07:10:30 -07:00
parent 6559655218
commit a79c78111e
7 changed files with 13 additions and 9 deletions

View File

@@ -193,9 +193,7 @@
<ClInclude Include="Peer.h" /> <ClInclude Include="Peer.h" />
<ClInclude Include="RequestParser.h" /> <ClInclude Include="RequestParser.h" />
<ClInclude Include="RPC.h" /> <ClInclude Include="RPC.h" />
<ClInclude Include="RPCServer.h" />
<ClInclude Include="RPCCommands.h" /> <ClInclude Include="RPCCommands.h" />
<ClInclude Include="RPCDoor.h" />
<ClInclude Include="script.h" /> <ClInclude Include="script.h" />
<ClInclude Include="SecureAllocator.h" /> <ClInclude Include="SecureAllocator.h" />
<ClInclude Include="Serializer.h" /> <ClInclude Include="Serializer.h" />
@@ -218,6 +216,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
<None Include="Makefile" /> <None Include="Makefile" />
<None Include="newcoind.cfg" />
<None Include="nodes.xml" /> <None Include="nodes.xml" />
<None Include="notes.txt" /> <None Include="notes.txt" />
<CustomBuild Include="src\newcoin.proto"> <CustomBuild Include="src\newcoin.proto">

View File

@@ -281,9 +281,6 @@
<ClInclude Include="NetworkThread.h"> <ClInclude Include="NetworkThread.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="RPCDoor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PeerDoor.h"> <ClInclude Include="PeerDoor.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@@ -308,9 +305,6 @@
<ClInclude Include="RPCCommands.h"> <ClInclude Include="RPCCommands.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="RPCServer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TransactionBundle.h"> <ClInclude Include="TransactionBundle.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@@ -430,6 +424,7 @@
<Filter>tests\client2</Filter> <Filter>tests\client2</Filter>
</None> </None>
<None Include="SConstruct" /> <None Include="SConstruct" />
<None Include="newcoind.cfg" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="src\newcoin.proto" /> <CustomBuild Include="src\newcoin.proto" />

View File

@@ -21,6 +21,9 @@
# [rpc_port]: # [rpc_port]:
# Port to bind to if allowing insecure RPC connections. # Port to bind to if allowing insecure RPC connections.
# #
# [rpc_allow_remote]:
# 0 or 1. 0 only allows RPC connections from 127.0.0.1. [default 0]
#
# [validation_seed]: # [validation_seed]:
# This is the seed used to generate the validation public/private key pair. # This is the seed used to generate the validation public/private key pair.
# This representation has a checksum and is the recommended form for transmission. # This representation has a checksum and is the recommended form for transmission.

View File

@@ -16,6 +16,7 @@
#define SECTION_PEER_PORT "peer_port" #define SECTION_PEER_PORT "peer_port"
#define SECTION_RPC_IP "rpc_ip" #define SECTION_RPC_IP "rpc_ip"
#define SECTION_RPC_PORT "rpc_port" #define SECTION_RPC_PORT "rpc_port"
#define SECTION_RPC_ALLOW_REMOTE "rpc_allow_remote"
#define SECTION_VALIDATION_PASSWORD "validation_password" #define SECTION_VALIDATION_PASSWORD "validation_password"
#define SECTION_VALIDATION_KEY "validation_key" #define SECTION_VALIDATION_KEY "validation_key"
#define SECTION_PEER_SSL_CIPHER_LIST "peer_ssl_cipher_list" #define SECTION_PEER_SSL_CIPHER_LIST "peer_ssl_cipher_list"
@@ -45,6 +46,7 @@ Config::Config()
RPC_USER = "admin"; RPC_USER = "admin";
RPC_PASSWORD = "pass"; RPC_PASSWORD = "pass";
RPC_ALLOW_REMOTE = false;
DATA_DIR = "db/"; DATA_DIR = "db/";
@@ -99,6 +101,9 @@ void Config::load()
if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp)) if (sectionSingleB(secConfig, SECTION_RPC_PORT, strTemp))
RPC_PORT = boost::lexical_cast<int>(strTemp); RPC_PORT = boost::lexical_cast<int>(strTemp);
if (sectionSingleB(secConfig, SECTION_RPC_ALLOW_REMOTE, strTemp))
RPC_ALLOW_REMOTE = boost::lexical_cast<bool>(strTemp);
(void) sectionSingleB(secConfig, SECTION_VALIDATION_PASSWORD, VALIDATION_PASSWORD); (void) sectionSingleB(secConfig, SECTION_VALIDATION_PASSWORD, VALIDATION_PASSWORD);
(void) sectionSingleB(secConfig, SECTION_VALIDATION_KEY, VALIDATION_KEY); (void) sectionSingleB(secConfig, SECTION_VALIDATION_KEY, VALIDATION_KEY);

View File

@@ -69,6 +69,7 @@ public:
int RPC_PORT; int RPC_PORT;
std::string RPC_USER; std::string RPC_USER;
std::string RPC_PASSWORD; std::string RPC_PASSWORD;
bool RPC_ALLOW_REMOTE;
// Validation // Validation
std::string VALIDATION_PASSWORD; std::string VALIDATION_PASSWORD;

View File

@@ -27,6 +27,7 @@ void RPCDoor::startListening()
bool RPCDoor::isClientAllowed(const std::string& ip) bool RPCDoor::isClientAllowed(const std::string& ip)
{ {
if(theConfig.RPC_ALLOW_REMOTE) return(true);
if(ip=="127.0.0.1") return(true); if(ip=="127.0.0.1") return(true);
return(false); return(false);
} }

View File

@@ -233,7 +233,7 @@ public:
while (phexdigit[*pEnd] >= 0) while (phexdigit[*pEnd] >= 0)
pEnd++; pEnd++;
if (pEnd-pBegin > 2*size()) if ((unsigned int)(pEnd-pBegin) > 2*size())
pBegin = pEnd - 2*size(); pBegin = pEnd - 2*size();
unsigned char* pOut = end()-((pEnd-pBegin+1)/2); unsigned char* pOut = end()-((pEnd-pBegin+1)/2);