Skip to content

Commit

Permalink
2.3.100
Browse files Browse the repository at this point in the history
  • Loading branch information
NevermindExpress committed Oct 29, 2023
1 parent 5b133a9 commit ff91bf1
Show file tree
Hide file tree
Showing 21 changed files with 596 additions and 95 deletions.
8 changes: 4 additions & 4 deletions Alyssa.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,2,0,0
PRODUCTVERSION 2,2,0,0
FILEVERSION 2,3,100,0
PRODUCTVERSION 2,3,100,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "PEPSIMANTR"
VALUE "FileDescription", "Alyssa HTTP Server Project"
VALUE "FileVersion", "2.2"
VALUE "FileVersion", "2.3.100"
VALUE "InternalName", "AlyssaHTTP.exe"
VALUE "LegalCopyright", "Copyright (C) 2024 PEPSIMANTR"
VALUE "OriginalFilename", "AlyssaHTTP.exe"
VALUE "ProductName", "Alyssa HTTP Server Project"
VALUE "ProductVersion", "2.2"
VALUE "ProductVersion", "2.3.100"
END
END
BLOCK "VarFileInfo"
Expand Down
4 changes: 2 additions & 2 deletions AlyssaHTTPServerProject.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AlyssaHTTPServerProject", "AlyssaHTTPServerProject.vcxproj", "{700A2600-71DC-470A-9A0B-60514B73F796}"
EndProject
Expand Down
4 changes: 4 additions & 0 deletions AlyssaHTTPServerProject.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
<ClCompile Include="src/DirectoryIndex.cpp" />
<ClCompile Include="src/DynContent.cpp" />
<ClCompile Include="src/Main.cpp" />
<ClCompile Include="src\AlyssaDebug.cpp" />
<ClCompile Include="src\AlyssaTester.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src/Alyssa.h" />
Expand All @@ -179,6 +181,8 @@
<ClInclude Include="src/external/Crc32.h" />
<ClInclude Include="src/resource.h" />
<ClInclude Include="src/external/subprocess.h" />
<ClInclude Include="src\AlyssaLocalization.h" />
<ClInclude Include="src\AlyssaTester.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Alyssa.rc" />
Expand Down
11 changes: 10 additions & 1 deletion AlyssaHTTPServerProject.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
<ClCompile Include="src/external/base64.cpp">
<Filter>Source\External</Filter>
</ClCompile>
<ClCompile Include="src\AlyssaDebug.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="src\AlyssaTester.cpp">
<Filter>Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src/Alyssa.h">
Expand All @@ -74,7 +80,10 @@
<ClInclude Include="src/external/subprocess.h">
<Filter>Header\External</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<ClInclude Include="src\AlyssaLocalization.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="src\AlyssaTester.h">
<Filter>Header</Filter>
</ClInclude>
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Alyssa HTTP Server Changelog

## 2.3.100 - 29.10.2023 C★
- Initial unit testing code Implementation
- It does testing on server code directly.
- Currently it only has a few tests and limited to Windows.
- Initial Localization Implementation
- Currently only limited to 2 languages and only a fraction of code uses the new localization mechanism.
- Added powerful debug features
- Accessible through /Debug/\* node
- Disabled by default, can be enabled from config.
- Has dangerous features such as accessing to any file. Only for use on development on isolated environment.
- Has features of printing server info, manual crashing, accessing to expicit paths, manual responses and more.
- Some improvements for CGI execution code
- Some minor fixes and improvements.
- Bugün en büyük bayramdır, kutlu olsun!

## 2.2 - 18.10.2023
- Rewrote client header parsing
- Now the code is much simpler and slightly faster.
Expand Down
5 changes: 3 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ I'll keep it simple. Here is a place that people interacts with each other with
nor the ones that going to solve wars etc.
We are the ones with no direct affection on anything and we just do software, so don't move any politic thing to here.

2. **Be an entity only:** Just be a human, and treat others as just humans too. Don't move the ethnicity, sexual orientation or any similar thing to there.
2. **Be an entity only, Be Professional:** Just be a human, and treat others as just humans too. Don't move the ethnicity,
sexual orientation or any similar thing or anything with sentimentals and drama involved to there.
Nobody cares about mine, yours or anyone else's ethnicity, sexual orientation or etc..
Neither do any propaganda that's affirming any minority nor do discrimination against anyone.
You won't get any semphaty because of such things here.
Expand All @@ -29,4 +30,4 @@ I have the right of replying to violations in range from just warning up to perm

Tag me (@PEPSIMANTR) in the crime scene or message me from one of available contact options.

Version 1 Amendment B
Version 1 Amendment C
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Alyssa HTTP Server Project
Alyssa is a lightweight, multiplatform HTTP server. It can just work without hours of configuration, on anywhere.
Alyssa is a HTTP server project that aims to be as good as mainstream HTTP server implementation while maintaining a simple source tree.
It can just work without hours of configuration, on anywhere.
## How to use?
You can use it just out of the box! Just get the latest release,
edit ports or other stuff if needed, and run the executable.
Expand All @@ -20,7 +21,7 @@ And more.
- [ ] Configurable build system with makefile
- [ ] Polling client sockets and handling requests in thread pool (HTTP/2 will make this pretty hard)
- [ ] Windows NT service support
- [ ] Content negotiation
- [ ] Content negotiation, Conditional requests handling
- [ ] HTTP/3 QUIC support
- [ ] Hashed authentication files support (sha256 for more security, crc32 for more performance)
- [ ] Automatic CGI execution (i.e. for .php files)
Expand All @@ -33,10 +34,9 @@ And more.
- [x] Server generated and custom error pages
- [ ] Modularization
- [ ] Kernel mode acceleration
- [ ] Conditional requests handling
- [ ] Extend custom actions
- [ ] Implement FastCGI support
- [ ] Add code testing (i.e. unit testing)
- [x] Add code testing (i.e. unit testing)
- [ ] Digest authentication
- [ ] Source code documentation (maybe)
- [ ] Add code for ease of developing APIs on top of server code directly (maybe)
Expand Down
57 changes: 43 additions & 14 deletions src/Alyssa.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// Includes
#include "AlyssaBuildConfig.h"
#include "AlyssaLocalization.h"

#ifdef Compile_CustomActions
#include "external/base64.h"//https://github.com/ReneNyffenegger/cpp-base64
Expand Down Expand Up @@ -91,6 +92,18 @@ struct _Surrogate {//Surrogator struct that holds essentials for connection whic
string host = ""; // Authority header. "host" on surrogator is only used on HTTP/2 connections as it is only sent once by client.
#endif
};
struct HeaderParameters {// Solution to parameter fuckery on serverHeaders(*) functions.
int16_t StatusCode;
size_t ContentLength = 0;
string MimeType;
bool HasRange = 0, hasAuth = 0;
string AddParamStr;// Additional parameter string. Has a use on cases like 302.
std::deque<string> CustomHeaders;// Additional custom headers
uint32_t _Crc = 0;// File CRC that will used for ETag.
#ifdef Compile_H2
bool EndStream = 1; // End stream in case of non-200 headers are sent.
#endif
};
struct clientInfo {//This structure has the information from client request.
string RequestPath = "", version = "",
host = "", // "Host" header
Expand All @@ -111,6 +124,9 @@ struct clientInfo {//This structure has the information from client request.
rstart = 0, rend = 0, VHostNum = 0, flags = 0, ContentLength = 0;
}
std::filesystem::path _RequestPath;
#ifdef AlyssaTesting
HeaderParameters LastHeader;
#endif
};
struct HPackIndex {
int Key = 0;
Expand All @@ -123,18 +139,6 @@ struct IndexEntry {
string FileName; size_t FileSize;
bool isDirectory; string ModifyDate;
};
struct HeaderParameters {// Solution to parameter fuckery on serverHeaders(*) functions.
int16_t StatusCode;
size_t ContentLength = 0;
string MimeType;
bool HasRange = 0, hasAuth = 0;
string AddParamStr;// Additional parameter string. Has a use on cases like 302.
std::deque<string> CustomHeaders;// Additional custom headers
uint32_t _Crc = 0;// File CRC that will used for ETag.
#ifdef Compile_H2
bool EndStream = 1; // End stream in case of non-200 headers are sent.
#endif
};
struct VirtualHost {
string Hostname;
string Location;
Expand All @@ -146,7 +150,9 @@ class Config {
public:
static string getValue(std::string key, std::string value);
static bool initialRead();
#ifndef AlyssaTesting
private:
#endif
static bool Configcache();
};
class AlyssaHTTP {
Expand All @@ -155,7 +161,9 @@ class AlyssaHTTP {
static void ServerHeadersM(clientInfo* c, unsigned short statusCode);
static void parseHeader(clientInfo* cl, char* buf, int sz);
static void clientConnection(_Surrogate sr);
#ifndef AlyssaTesting
private:
#endif
static void Get(clientInfo* cl);
#ifdef Compile_CustomActions
static void Post(clientInfo* cl);
Expand All @@ -165,7 +173,9 @@ class AlyssaHTTP {
class CustomActions {
public:
static int CAMain(char* path, clientInfo* c, H2Stream* h=NULL);
#ifndef AlyssaTesting
private:
#endif
static int DoAuthentication(char* p, char* c);
static int ParseCA(char* c, int s, clientInfo* cl, H2Stream* h);
static int ParseFile(std::filesystem::path p, char* n, clientInfo* c, bool isSameDir, H2Stream* h);
Expand All @@ -175,7 +185,9 @@ class CustomActions {
class DirectoryIndex {
public:
static string DirMain(std::filesystem::path p, std::string& RelPath);
#ifndef AlyssaTesting
private:
#endif
static std::deque<IndexEntry> GetDirectory(std::filesystem::path p);
};
#endif
Expand All @@ -195,7 +207,9 @@ void LogString(const char* s);
void LogString(string s);
void SetPredefinedHeaders();
void ConsoleMsg(int8_t MsgType, const char* UnitName, const char* Msg);
void ConsoleMsg(int8_t MsgType, int UnitStr, int MsgStr);
void ConsoleMsgM(int8_t MsgType, const char* UnitName);
void ConsoleMsgLiteral(int MsgStr);
uint32_t FileCRC(FILE* f, size_t s, char* buf, size_t _Beginning);
std::string ErrorPage(unsigned short ErrorCode);
char ParseCL(int argc, char** argv);
Expand All @@ -204,6 +218,11 @@ unsigned char hexconv(char* _Arr);
bool CGIEnvInit();
void ExecCGI(const char* exec, clientInfo* cl, H2Stream* h);
#endif
#ifdef _DEBUG
void DebugNode(clientInfo* cl);
void DummyCGIGet();
void DummyCGIPost();
#endif

extern std::ofstream Log; extern std::mutex logMutex; extern std::mutex ConsoleMutex;
// Response headers that's never changing in lifetime of server.
Expand Down Expand Up @@ -249,6 +268,11 @@ extern std::deque<std::string> ACAOList; extern bool corsEnabled;
extern string SSLportStr;
extern bool HSTS;
#endif
#ifdef _DEBUG
extern std::string execpath;
extern bool debugFeaturesEnabled;
#endif
extern unsigned short Locale;

// Definition of constant values
static char separator = 1;
Expand Down Expand Up @@ -305,10 +329,15 @@ static const char* MsgTypeStr[] = { "Error: ","Warning: ","Info: " };
#endif
#else
#ifdef _DEBUG
static std::string version = "2.2d";
static std::string version = "2.3.100d";
#else
static std::string version = "2.2";
static std::string version = "2.3.100";
#endif
#endif
#ifdef _WIN32
static char LineDelimiterLength = 2;
#else
static char LineDelimiterLength = 1;
#endif

#ifdef Compile_H2
Expand Down
3 changes: 3 additions & 0 deletions src/AlyssaBuildConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@

// Directory indexes support
#define Compile_DirIndex

// Do testing.
//#define AlyssaTesting
39 changes: 37 additions & 2 deletions src/AlyssaCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ void AlyssaNtSetConsole() {
}
#endif // _WIN32

void ConsoleMsg(int8_t MsgType, const char* UnitName, const char* Msg) {// Function for color output on console
// Ex: "Error: Custom actions: Redirect requires an argument" MsgType: Error, UnitName: "Custom actions", Msg is the latter.
void ConsoleMsg(int8_t MsgType, const char* UnitName, const char* Msg) { // Function for color output on console
// Ex: "Error: Custom actions: Redirect requires an argument"
// MsgType: Error, UnitName: "Custom actions", Msg is the latter.
// Note that this function can be abused in the future for outputting various things.
#ifndef AlyssaTesting
if (MsgType > 2) std::terminate(); std::lock_guard<std::mutex> lock(ConsoleMutex);
if (ColorOut){
#ifndef _WIN32 // Color output on unix platforms is easy since terminals usually support ANSI escape characters.
Expand All @@ -194,9 +196,30 @@ void ConsoleMsg(int8_t MsgType, const char* UnitName, const char* Msg) {// Funct
else {
std::cout << MsgTypeStr[MsgType] << UnitName << Msg << std::endl;
}
#endif // !AlyssaTesting
return;
}
void ConsoleMsg(int8_t MsgType, int UnitStr, int MsgStr) {
#ifndef AlyssaTesting
if (MsgType > 2) std::terminate();
std::lock_guard<std::mutex> lock(ConsoleMutex);
if (ColorOut) {
#ifndef _WIN32
std::wcout << MsgColors[MsgType] << LocaleTable[Locale][MsgType + 1] << MsgColors[3]
<< LocaleTable[Locale][UnitStr] << MsgColors[4] << LocaleTable[Locale][MsgStr] << std::endl;
#else
SetConsoleTextAttribute(hConsole, MsgColors[MsgType]); std::wcout << LocaleTable[Locale][MsgType + 1];
SetConsoleTextAttribute(hConsole, MsgColors[3]); std::wcout << LocaleTable[Locale][UnitStr];
SetConsoleTextAttribute(hConsole, MsgColors[4]); std::wcout << LocaleTable[Locale][MsgStr] << std::endl;
#endif
}
else {
std::wcout << LocaleTable[Locale][MsgType + 1] << LocaleTable[Locale][UnitStr] << LocaleTable[Locale][MsgStr] << std::endl;
}
#endif
}
void ConsoleMsgM(int8_t MsgType, const char* UnitName) {// Just like the one above but this one only prints msgtype and unit name in color, and then resets color for manual output such as printf.
#ifndef AlyssaTesting
if (MsgType > 2) std::terminate();
if (ColorOut) {
#ifndef _WIN32
Expand All @@ -209,8 +232,12 @@ void ConsoleMsgM(int8_t MsgType, const char* UnitName) {// Just like the one abo
else {
std::cout << MsgTypeStr[MsgType] << UnitName;
}
#endif // !AlyssaTesting
return;
}
void ConsoleMsgLiteral(int MsgStr) {
std::wcout << LocaleTable[Locale][MsgStr];
}
uint32_t FileCRC(FILE* f, size_t s, char* buf, size_t _Beginning=0) {
uint32_t ret = 0;
while (s) {
Expand Down Expand Up @@ -279,6 +306,9 @@ char ParseCL(int argc, char** argv) {// This func parses command line arguments.
#endif
cout << "Compiled on " << __DATE__ << " " << __TIME__ << std::endl;
cout << "Features: Core, "
#ifdef _DEBUG
<< "Debug, "
#endif
#ifdef Compile_WolfSSL
<< "SSL, "
#endif
Expand Down Expand Up @@ -343,6 +373,11 @@ char ParseCL(int argc, char** argv) {// This func parses command line arguments.
}
else { cout << "Usage: -sslport [port number]{,port num2,port num3...}" << std::endl; return -4; }
}
#ifdef _DEBUG
else if (!strcmp(argv[i], "debug")) { debugFeaturesEnabled = 1; }
else if (!strcmp(argv[i], "dummycgi")) { DummyCGIGet(); return 0; }
else if (!strcmp(argv[i], "dummycgipost")) { DummyCGIPost(); return 0; }
#endif
#endif
else { cout << "Invalid argument: " << argv[i] << ". See -help for valid arguments." << std::endl; return -4; }
}
Expand Down
Loading

0 comments on commit ff91bf1

Please sign in to comment.