Skip to content
This repository has been archived by the owner on Aug 19, 2018. It is now read-only.

Linux Modifications #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(LIBS ${LIBS} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY}
${Boost_CHRONO_LIBRARY})


find_package( Curl REQUIRED)
find_package( CURL REQUIRED)
set(INCLUDES ${INCLUDES} ${CURL_INCLUDE_DIRS})
set(LIBS ${LIBS} ${CURL_LIBRARIES})

Expand All @@ -48,7 +48,7 @@ set ( Aperture_srcs
aperture/request_parser.cpp aperture/server.cpp
aperture/ServerResponseMsg.cpp aperture/Settings.cpp
aperture/SHA1.cpp aperture/stdafx.cpp aperture/TokenBucket.cpp
aperture/Validator.cpp aperture/WhipURI.cpp aperture/win_main.cpp
aperture/Validator.cpp aperture/WhipURI.cpp aperture/win_main.cpp aperture/nix_main.cpp
${PROTO_SRCS}
)

Expand All @@ -59,3 +59,4 @@ add_definitions(${DEFS})
include_directories(${INCLUDES})
add_executable( aperture ${Aperture_srcs})
target_link_libraries(aperture ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} ${LIBS} )
target_compile_features(aperture PRIVATE cxx_range_for )
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,28 @@ mesh data to viewer software connected to the InWorldz grid

### Sample cmake build command for windows

This fork of aperture has been modified for compilation on linux. Building on windows has likely been affected.

cmake .. -DCMAKE_BUILD_TYPE=Debug -DCURL_LIBRARY=C:\lib\curl-7.44.0\builds\libcurl-vc-x64-debug-dll-ipv6-sspi-winssl\lib\libcurl_debug.lib -DCURL_INCLUDE_DIR=C:\lib\curl-7.44.0\include -DPROTOBUF_LIBRARY=C:\lib\protobuf-2.6.1\vsprojects\x64\Debug\libprotobuf.lib -DPROTOBUF_INCLUDE_DIR=C:\lib\protobuf-2.6.1\src -DPROTOBUF_PROTOC_EXECUTABLE=C:\lib\protobuf-2.6.1\vsprojects\x64\Debug\protoc.exe
-G "Visual Studio 14 2015 Win64"

### Directions for Ubuntu 16.04 LTS

These are the basic commands in order based off of my terminal history, they may not be precise.

1. Install cmake, protobuf-compiler, libboost1.58-all-dev
1. clone aperture
1. cd aperture
1. mkdir build
1. cd build
1. cmake ..
1. make
1. Create the configuration file

A bare-bones aperture.cfg file is:
<pre>
http_listen_port = <port number>
caps_token = 2960079
whip_url = whip://<password>@<ip>:32700
</pre>

4 changes: 2 additions & 2 deletions aperture/AppLog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"

#include "AppLog.h"
#include <boost/date_time/posix_time/posix_time.hpp>
Expand All @@ -25,4 +25,4 @@ namespace aperture
(*AppLog::_logStream) << "[" << now << "] ";
return *AppLog::_logStream;
}
}
}
10 changes: 5 additions & 5 deletions aperture/Asset.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "StdAfx.h"
#include "stdafx.h"
#include "Asset.h"
#include "Winsock2.h"
//#include "Winsock2.h"

#include <boost/numeric/conversion/cast.hpp>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -63,7 +63,7 @@ boost::tuple<unsigned int, unsigned int> Asset::findDataLocationAndSize() const
aperture::byte nameFieldSz = (*_data)[currLoc];
//skip those bytes
currLoc += nameFieldSz + 1;

//next up is the sz of the description field, skip those bytes
aperture::byte descFieldSz = (*_data)[currLoc];
currLoc += descFieldSz + 1;
Expand All @@ -75,7 +75,7 @@ boost::tuple<unsigned int, unsigned int> Asset::findDataLocationAndSize() const
return boost::tuple<unsigned int, unsigned int>(currLoc + sizeof(unsigned int), dataSz);
}

unsigned int Asset::copyAssetData(std::string& storage) const
unsigned int Asset::copyAssetData(std::string& storage) const
{
unsigned int dataLoc;
unsigned int dataSz;
Expand Down Expand Up @@ -129,4 +129,4 @@ unsigned int Asset::copyAssetData(std::string& storage, unsigned int rngStart, u
return dataSz;
}

}
}
2 changes: 1 addition & 1 deletion aperture/AssetServer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"
#include "AssetServer.h"
#include "AppLog.h"
#include "ClientRequestMsg.h"
Expand Down
10 changes: 5 additions & 5 deletions aperture/AssetServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace whip
typedef boost::function<void (AssetServer::ptr, bool)> ConnectCallback;
typedef boost::function<void (AssetServer::ptr)> SafeKillCallback;

enum ConnectionState
enum ConnectionState
{
CSTATE_DISCONNECTED,
CSTATE_CONNECTING,
Expand Down Expand Up @@ -100,9 +100,9 @@ namespace whip


void onConnect(const boost::system::error_code& error);

void onRecvChallenge(const boost::system::error_code& error, size_t bytesRcvd, AuthChallengeMsg::ptr challenge);

void onChallengeResponseWrite(const boost::system::error_code& error, size_t bytesSent,
AuthResponseMsg::ptr authResponse);

Expand Down Expand Up @@ -169,11 +169,11 @@ namespace whip
/**
* Retrieves the given asset from this server
*/
virtual void AssetServer::getAsset(const std::string& uuid, boost::function<void (aperture::IAsset::ptr)> callBack);
virtual void getAsset(const std::string& uuid, boost::function<void (aperture::IAsset::ptr)> callBack);

/**
* Shuts down the connections and marks this server as shut down
*/
virtual void shutdown();
};
}
}
2 changes: 1 addition & 1 deletion aperture/AuthChallengeMsg.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"
#include "AuthChallengeMsg.h"

namespace whip
Expand Down
15 changes: 8 additions & 7 deletions aperture/AuthResponseMsg.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"

#include <string>
#include <boost/numeric/conversion/cast.hpp>
Expand All @@ -21,7 +21,8 @@ AuthResponseMsg::AuthResponseMsg()

AuthResponseMsg::AuthResponseMsg(const std::string& challenge, const std::string& password)
{
_data.push_back(PACKET_IDENTIFIER);
aperture::byte val = PACKET_IDENTIFIER;
_data.push_back(val);

//calculate our response
string correctHash = this->calculateChallengeResponse(challenge, password);
Expand Down Expand Up @@ -50,15 +51,15 @@ bool AuthResponseMsg::isServerResponse() const
bool AuthResponseMsg::isValid(AuthChallengeMsg::ptr authChallenge)
{
//check the header
if (_data[0] != PACKET_IDENTIFIER &&
_data[0] != SERVER_IDENTIFIER)
if (_data[0] != AuthResponseMsg::PACKET_IDENTIFIER &&
_data[0] != AuthResponseMsg::SERVER_IDENTIFIER)
{
return false;
}

string correctHash = this->calculateChallengeResponse(authChallenge->getPhrase(),
Settings::instance().config()["password"].as<string>());

if (correctHash == this->getChallengeResponse()) {
return true;
}
Expand All @@ -69,7 +70,7 @@ bool AuthResponseMsg::isValid(AuthChallengeMsg::ptr authChallenge)
std::string AuthResponseMsg::calculateChallengeResponse(const std::string& phrase, const std::string& password)
{
CSHA1 sha;

//calculate the correct hash based on password and the challenge that was sent
string correctHash(password + phrase);
sha.Update((unsigned char*) correctHash.data(), boost::numeric_cast<unsigned int>(correctHash.size()));
Expand All @@ -79,4 +80,4 @@ std::string AuthResponseMsg::calculateChallengeResponse(const std::string& phras

return correctHash;
}
}
}
4 changes: 2 additions & 2 deletions aperture/AuthResponseMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthResponseMsg
const static aperture::byte SERVER_IDENTIFIER = 100;

const static short RESPONSE_SIZE = 40;

aperture::byte_array _data;

public:
Expand Down Expand Up @@ -56,4 +56,4 @@ class AuthResponseMsg
*/
bool isServerResponse() const;
};
}
}
7 changes: 4 additions & 3 deletions aperture/AuthStatusMsg.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"
#include "AuthStatusMsg.h"

namespace whip
Expand All @@ -10,7 +10,8 @@ AuthStatusMsg::AuthStatusMsg()

AuthStatusMsg::AuthStatusMsg(AuthStatus authStatus)
{
_messageData.push_back(AuthStatusMsg::PACKET_IDENTIFIER);
aperture::byte val = PACKET_IDENTIFIER;
_messageData.push_back(val);
_messageData.push_back(static_cast<aperture::byte>(authStatus));
}

Expand Down Expand Up @@ -51,4 +52,4 @@ bool AuthStatusMsg::validate() const

return true;
}
}
}
8 changes: 4 additions & 4 deletions aperture/ClientRequestMsg.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "StdAfx.h"
#include "stdafx.h"

#include "ClientRequestMsg.h"
#include "Winsock2.h"
//#include "Winsock2.h"

ClientRequestMsg::ClientRequestMsg()
: _header(HEADER_SIZE)
{

}
ClientRequestMsg::ClientRequestMsg(RequestType type, const std::string& uuid)
{
Expand Down Expand Up @@ -56,4 +56,4 @@ aperture::byte_array_ptr ClientRequestMsg::getData()
unsigned int ClientRequestMsg::getDataSize() const
{
return ntohl(*((unsigned int*)&_header[DATA_SIZE_MARKER_LOC]));
}
}
4 changes: 2 additions & 2 deletions aperture/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
See header file for version history.
*/

// If compiling with MFC, you might want to add #include "StdAfx.h"
#include "StdAfx.h"
// If compiling with MFC, you might want to add #include "stdafx.h"
#include "stdafx.h"

#include <boost/algorithm/string.hpp>

Expand Down
6 changes: 3 additions & 3 deletions aperture/ServerResponseMsg.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "StdAfx.h"
#include "stdafx.h"
#include "ServerResponseMsg.h"
#include "Winsock2.h"
//#include "Winsock2.h"

#include <boost/numeric/conversion/cast.hpp>

Expand Down Expand Up @@ -87,4 +87,4 @@ std::string ServerResponseMsg::getAssetUUID() const
return std::string((const char*)&_header[UUID_LOC], 32);
}

}
}
2 changes: 1 addition & 1 deletion aperture/Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"

#include "Settings.h"

Expand Down
2 changes: 1 addition & 1 deletion aperture/Validator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"
#include "Validator.h"

#include <boost/foreach.hpp>
Expand Down
8 changes: 4 additions & 4 deletions aperture/WhipURI.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdAfx.h"
#include "stdafx.h"

#include "WhipURI.h"
#include <vector>
Expand All @@ -14,7 +14,7 @@ namespace whip
string uri(url);
//parse the uri
//url must start with whip
if (uri.substr(0, 7) != "whip://") throw std::runtime_error("Invaid whip URL. Must start with whip://");
if (uri.substr(0, 7) != "whip://") throw std::runtime_error("Invalid whip URL. Must start with whip://");

//strip the Resource ID portion
uri = uri.substr(7);
Expand All @@ -26,7 +26,7 @@ namespace whip

//get the user and pass
string pass = userAndHost[0];

//get the host and port
vector<string> hostAndPort;
boost::split(hostAndPort, userAndHost[1], boost::is_any_of(":"));
Expand Down Expand Up @@ -55,4 +55,4 @@ namespace whip
{
return _password;
}
}
}
Loading