Skip to content
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
62 changes: 62 additions & 0 deletions .github/workflows/crabnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Crab-Main

on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
branches: [ master ]


jobs:
Evolve-To-Crab:
strategy:
matrix:
build_type: [Release, RelWithDebInfo, MinSizeRel, Debug]
target_system: [ ubuntu-22.04, windows-2022, macos-11 ]
runs-on: ${{ matrix.target_system }}
env:
BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.lib' || '.a' }}
BUILD_PREFIX: ${{ matrix.target_system != 'windows-2022' && 'lib' || ''}}
BUILD_SUFFIX: ${{ matrix.target_system == 'windows-2022' && matrix.build_type == 'Debug' && 'd' || '' }}
BUILD_DIR: D:/a/CrabNet/CrabNet/lib/${{ matrix.build_type}}/
# LIB_NAME:

steps:
- uses: actions/checkout@v4

- name: Configure
shell: bash
run: cmake .

- name: Build
run: |
cmake --build . --config ${{ matrix.build_type }}

- name: Make Archive
if: github.event_name != 'pull_request'
run: |
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on CrabNet-${{ runner.os }}-${{ matrix.build_type }}.7z LICENSE include/ ${{ runner.os == 'Windows' && env.BUILD_DIR || 'lib/' }}${{ env.BUILD_PREFIX }}RakNetLibStatic${{ env.BUILD_SUFFIX }}${{ env.BUILD_EXT }}
# env:
# LIB_NAME: $BUILD_PREFIXRakNetLibStatic$BUILD_SUFFIX$BUILD_EXT


- name: Upload Release
if: github.event_name != 'pull_request'
uses: softprops/action-gh-release@v1
with:
tag_name: Stable-CI
files: CrabNet-${{ runner.os }}-${{ matrix.build_type }}.7z
body: |
CI Build for Dreamweave CrabNet Fork

- name: Upload Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
path: |
${{ runner.os == 'Windows' && env.BUILD_DIR || 'lib/' }}${{ env.BUILD_PREFIX }}RakNetLibStatic${{ env.BUILD_SUFFIX }}${{ env.BUILD_EXT }}
include/
LICENSE
name: CrabNet-${{ runner.os }}-${{ matrix.build_type }}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ENDIF (WIN32 AND NOT UNIX)

# Options
option(CRABNET_ENABLE_SAMPLES "Generate RakNet sample projects." FALSE)
option(CRABNET_ENABLE_DLL "Generate the DLL project." TRUE)
option(CRABNET_ENABLE_DLL "Generate the DLL project." FALSE)
option(CRABNET_ENABLE_STATIC "Generate the static library project." TRUE)

option(CRABNET_ENABLE_PVS "Enable PVS Studio Analyzer" FALSE)
Expand Down
7 changes: 2 additions & 5 deletions Source/Plugins/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void FileList::AddFilesFromDirectory(const char *applicationDirectory, const cha
strcat(fullPath, "*");


intptr_t dir = _findfirst(fullPath, &fileInfo);
long dir = _findfirst(fullPath, &fileInfo);
if (dir == -1)
{
_findclose(dir);
Expand All @@ -282,11 +282,8 @@ void FileList::AddFilesFromDirectory(const char *applicationDirectory, const cha
do
{
// no guarantee these entries are first...
if (strcmp(".", fileInfo.name) == 0 ||
strcmp("..", fileInfo.name) == 0)
{
if (strcmp(".", fileInfo.name) == 0 || strcmp("..", fileInfo.name) == 0)
continue;
}

if ((fileInfo.attrib & (_A_HIDDEN | _A_SUBDIR | _A_SYSTEM)) == 0)
{
Expand Down
90 changes: 31 additions & 59 deletions Source/Plugins/HTTPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,75 +222,47 @@ void HTTPConnection::ProcessTCPPacket(Packet *packet)
{
RakAssert(packet);

// read all the packets possible
if(packet->systemAddress == server)
if (packet->systemAddress != server)
return;

if (incomingData.GetLength() == 0)
{
if(incomingData.GetLength() == 0)
{
int response_code = atoi((char *)packet->data + strlen("HTTP/1.0 "));
int response_code = atoi((char *)packet->data + strlen("HTTP/1.0 "));

if(response_code > 299)
{
badResponses.Push(BadResponse(packet->data, response_code));
//printf("Closed connection (Bad response 2)\n");
CloseConnection();
return;
}
if (response_code > 299)
{
badResponses.Push(BadResponse(packet->data, response_code));
CloseConnection();
return;
}
}

RakNet::RakString incomingTemp = RakNet::RakString::NonVariadic((const char*) packet->data);
incomingTemp.URLDecode();
incomingData += incomingTemp;
RakNet::RakString incomingTemp = RakNet::RakString::NonVariadic((const char *)packet->data);
incomingTemp.URLDecode();
incomingData += incomingTemp;

// printf((const char*) packet->data);
// printf("\n");
RakAssert(strlen((char *)packet->data) == packet->length);
const char *start_of_body = strstr(incomingData, "\r\n\r\n");

RakAssert(strlen((char *)packet->data) == packet->length); // otherwise it contains Null bytes
if (connectionState != CS_PROCESSING)
return;

const char *start_of_body = strstr(incomingData, "\r\n\r\n");
long length_of_headers;
if (!start_of_body)
return;

length_of_headers = (long)(start_of_body + 4 - incomingData.C_String());
const char *length_header = strstr(incomingData, "\r\nLength: ");

// besides having the server close the connection, they may
// provide a length header and supply that many bytes
if(
// Why was start_of_body here? Makes the GET command fail
// start_of_body &&
connectionState == CS_PROCESSING)
{
/*
// The stupid programmer that wrote this originally didn't think that just because the header contains this value doesn't mean you got the whole message
if (strstr((const char*) packet->data, "\r\nConnection: close\r\n"))
{
CloseConnection();
}
else
{
*/
long length_of_headers;
if (start_of_body)
{
length_of_headers = (long)(start_of_body + 4 - incomingData.C_String());
const char *length_header = strstr(incomingData, "\r\nLength: ");

if(length_header)
{
long length = atol(length_header + 10) + length_of_headers;

if((long) incomingData.GetLength() >= length)
{
//printf("Closed connection (Got all data due to length header)\n");
CloseConnection();
}
}
}
else
{
// No processing needed
}
if (!length_header)
return;

long length = atol(length_header + 10) + length_of_headers;

//}
}
}
if ((long)incomingData.GetLength() < length)
return;

CloseConnection();
}

bool HTTPConnection::IsBusy(void) const
Expand Down
2 changes: 1 addition & 1 deletion Source/Utils/FileOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool DirectoryExists(const char *directory)
strcpy(baseDirWithStars, directory);
AddSlash(baseDirWithStars);
strcat(baseDirWithStars, "*.*");
intptr_t dir = _findfirst(baseDirWithStars, &fileInfo);
long dir = _findfirst(baseDirWithStars, &fileInfo);
if (dir == -1)
return false;
_findclose(dir);
Expand Down
8 changes: 5 additions & 3 deletions Source/Utils/_FindFirst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "_FindFirst.h"
#include "DS_List.h"

#include "FileList.h"

#include <sys/stat.h>

#include <fnmatch.h>
Expand Down Expand Up @@ -57,11 +59,11 @@ long _findfirst(const char *name, _finddata_t *f)
// being '.'
if (_findnext(ret, f) == -1)
return -1;
else
return ret;

return ret;
}

int _findnext(intptr_t h, _finddata_t *f)
int _findnext(long h, _finddata_t *f)
{
RakAssert(h >= 0 && h < (long) fileInfo.Size());
if (h < 0 || h >= (long) fileInfo.Size()) return -1;
Expand Down
2 changes: 1 addition & 1 deletion Source/Utils/_FindFirst.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef struct _findinfo_t
} _findinfo;

long _findfirst(const char *name, _finddata_t *f);
int _findnext(intptr_t h, _finddata_t *f);
int _findnext(long h, _finddata_t *f);
int _findclose(intptr_t h);

#endif
Expand Down