mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-07 03:07:45 +00:00
Added hacky PS4 support back
This commit is contained in:
parent
d4a86366dd
commit
c1d287b15b
4 changed files with 109 additions and 0 deletions
|
@ -70,6 +70,20 @@ bool Core::Network::SapphireAPI::login( const std::string& username, const std::
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Core::Network::SapphireAPI::insertSession( const uint32_t& accountId, std::string& sId )
|
||||||
|
{
|
||||||
|
// create session for the new sessionid and store to sessionlist
|
||||||
|
auto pSession = boost::make_shared< Session >();
|
||||||
|
pSession->setAccountId( accountId );
|
||||||
|
pSession->setSessionId( (uint8_t *)sId.c_str() );
|
||||||
|
|
||||||
|
m_sessionMap[sId] = pSession;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Core::Network::SapphireAPI::createAccount( const std::string& username, const std::string& pass, std::string& sId )
|
bool Core::Network::SapphireAPI::createAccount( const std::string& username, const std::string& pass, std::string& sId )
|
||||||
{
|
{
|
||||||
// get account from login name
|
// get account from login name
|
||||||
|
|
|
@ -31,6 +31,8 @@ namespace Core
|
||||||
|
|
||||||
void deleteCharacter( std::string name, uint32_t accountId );
|
void deleteCharacter( std::string name, uint32_t accountId );
|
||||||
|
|
||||||
|
bool insertSession( const uint32_t& accountId, std::string& sId );
|
||||||
|
|
||||||
std::vector<Core::PlayerMinimal> getCharList( uint32_t accountId );
|
std::vector<Core::PlayerMinimal> getCharList( uint32_t accountId );
|
||||||
|
|
||||||
bool checkNameTaken( std::string name );
|
bool checkNameTaken( std::string name );
|
||||||
|
|
|
@ -289,6 +289,46 @@ int main()
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
server.resource["^/sapphire-api/lobby/insertSession"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||||
|
print_request_info( request );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using namespace boost::property_tree;
|
||||||
|
ptree pt;
|
||||||
|
read_json( request->content, pt );
|
||||||
|
|
||||||
|
std::string sId = pt.get<string>( "sId" );
|
||||||
|
uint32_t accountId = pt.get<uint32_t>( "accountId" );
|
||||||
|
std::string secret = pt.get<string>( "secret" );
|
||||||
|
|
||||||
|
auto m_pConfig = new Core::XMLConfig();
|
||||||
|
|
||||||
|
if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) )
|
||||||
|
{
|
||||||
|
g_log.fatal( "Error loading config settings_rest.xml" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) {
|
||||||
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
|
*response << "HTTP/1.1 403\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_sapphireAPI.insertSession( accountId, sId );
|
||||||
|
std::string json_string = "{\"result\":\"success\"}";
|
||||||
|
*response << "HTTP/1.1 200\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( exception& e )
|
||||||
|
{
|
||||||
|
*response << "HTTP/1.1 500\r\n\r\n";
|
||||||
|
g_log.error( e.what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
server.resource["^/sapphire-api/lobby/checkNameTaken"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
server.resource["^/sapphire-api/lobby/checkNameTaken"]["POST"] = [&server]( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request ) {
|
||||||
print_request_info( request );
|
print_request_info( request );
|
||||||
|
|
||||||
|
|
53
src/tools/Script/ps4dns.py
Normal file
53
src/tools/Script/ps4dns.py
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
import socket
|
||||||
|
from urllib2 import urlopen
|
||||||
|
|
||||||
|
class DNSQuery:
|
||||||
|
def __init__(self, data):
|
||||||
|
self.data=data
|
||||||
|
self.domain=''
|
||||||
|
|
||||||
|
qtype = (ord(data[2]) >> 3) & 15 # Opcode bits
|
||||||
|
if qtype == 0: # Standard query
|
||||||
|
index=12
|
||||||
|
lon=ord(data[index])
|
||||||
|
while lon != 0:
|
||||||
|
self.domain+=data[index+1:index+lon+1]+'.'
|
||||||
|
index+=lon+1
|
||||||
|
lon=ord(data[index])
|
||||||
|
|
||||||
|
def request(self, ip):
|
||||||
|
packet=''
|
||||||
|
if self.domain:
|
||||||
|
packet+=self.data[:2] + "\x81\x80"
|
||||||
|
packet+=self.data[4:6] + self.data[4:6] + '\x00\x00\x00\x00' # Questions and Answers Counts
|
||||||
|
packet+=self.data[12:] # Original Domain Name Question
|
||||||
|
packet+='\xc0\x0c' # Pointer to domain name
|
||||||
|
packet+='\x00\x01\x00\x01\x00\x00\x00\x3c\x00\x04' # Response type, ttl and resource data length -> 4 bytes
|
||||||
|
packet+=str.join('',map(lambda x: chr(int(x)), ip.split('.'))) # 4bytes of IP
|
||||||
|
return packet
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
#ip=socket.gethostbyname(socket.gethostname())
|
||||||
|
#ip = urlopen('http://ip.42.pl/raw').read()
|
||||||
|
ip = "212.43.86.40"
|
||||||
|
print 'DNS server started on %s intercepting to %s' % (socket.gethostbyname(socket.gethostname()), ip)
|
||||||
|
|
||||||
|
udps = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
udps.bind(('',53))
|
||||||
|
|
||||||
|
try:
|
||||||
|
while 1:
|
||||||
|
data, addr = udps.recvfrom(1024)
|
||||||
|
p=DNSQuery(data)
|
||||||
|
if "neolobby" in p.domain:
|
||||||
|
udps.sendto(p.request(ip), addr) #send answer
|
||||||
|
print 'Intercepted request: %s -> %s' % (p.domain, ip)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
r_ip = socket.gethostbyname(p.domain)
|
||||||
|
except:
|
||||||
|
r_ip = ip
|
||||||
|
udps.sendto(p.request(r_ip), addr) #send answer
|
||||||
|
print 'Normal request: %s -> %s' % (p.domain, r_ip)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
udps.close()
|
Loading…
Add table
Reference in a new issue