Add switch support (BROKEN) and TessesFrameworkFeatures.h and CertificateChain.hpp will be installed properly

This commit is contained in:
2025-04-14 06:30:45 -05:00
parent e8ff8d5bc1
commit 6bc9d0e76c
14 changed files with 385 additions and 44 deletions

View File

@ -3,6 +3,7 @@
#include "TessesFramework/Filesystem/SubdirFilesystem.hpp"
#include <iostream>
#include <unistd.h>
#include "TessesFramework/Common.hpp"
using LocalFilesystem = Tesses::Framework::Filesystem::LocalFilesystem;
using SubdirFilesystem = Tesses::Framework::Filesystem::SubdirFilesystem;
using VFSPath = Tesses::Framework::Filesystem::VFSPath;
@ -38,7 +39,7 @@ namespace Tesses::Framework::Http
}
bool FileServer::SendFile(ServerContext& ctx,VFSPath path)
{
TF_LOG("File: " + path.ToString());
auto strm = this->vfs->OpenFile(path,"rb");
bool retVal = false;
if(strm != nullptr)
@ -55,14 +56,18 @@ namespace Tesses::Framework::Http
bool FileServer::Handle(ServerContext& ctx)
{
auto path = HttpUtils::UrlPathDecode(ctx.path);
if(this->vfs->DirectoryExists(path))
{
TF_LOG("Directory exists");
for(auto f : defaultNames)
{
VFSPath p(path,f);
VFSPath p=path;
p = p / f;
TF_LOG("Trying " + p.ToString());
TF_LOG("Before file exists");
TF_LOG(this->vfs->FileExists(p)?"File Exists" : "File Does Not Exist");
TF_LOG("After file exists");
if(this->vfs->FileExists(p))
return SendFile(ctx,p);
}

View File

@ -8,6 +8,7 @@
#include "TessesFramework/Http/HttpStream.hpp"
#include "TessesFramework/Crypto/MbedHelpers.hpp"
#include "TessesFramework/Threading/Mutex.hpp"
#include "TessesFramework/Common.hpp"
#include <iostream>
using FileStream = Tesses::Framework::Streams::FileStream;
@ -536,20 +537,36 @@ namespace Tesses::Framework::Http
if(http == nullptr) return;
auto svr=this->server;
auto http = this->http;
TF_LOG("Before Creating Thread");
thrd = new Threading::Thread([svr,http]()->void {
while(TF_IsRunning())
{
TF_LOG("after TF_IsRunning");
std::string ip;
uint16_t port;
auto sock =svr->GetStream(ip,port);
if(sock == nullptr) return;
TF_LOG("New Host IP: " + ip + ":" + std::to_string(port));
if(sock == nullptr)
{
std::cout << "STREAM ERROR" << std::endl;
return;
}
TF_LOG("Before entering socket thread");
Threading::Thread thrd2([sock,http,ip,port]()->void {
TF_LOG("In thread to process");
HttpServer::Process(*sock,*http,ip,port,false);
TF_LOG("In thread after process");
delete sock;
});
TF_LOG("Before attach");
thrd2.Detach();
TF_LOG("After attach");
}
});
TF_LOG("Before printing interfaces");
std::cout << "\e[34mInterfaces:\n";
for(auto _ip : NetworkStream::GetIPs())
{
@ -558,7 +575,9 @@ namespace Tesses::Framework::Http
std::cout << "\e[35mhttp://";
std::cout << _ip.second << ":" << std::to_string(this->port) << "/\n";
}
if(!svr->IsValid()) std::cout << "\e[31mError, we failed to bind or something\e[39m\n" << std::endl;
std::cout << "\e[31mAlmost Ready to Listen\e[39m\n";
TF_LOG("After printing interfaces");
}
HttpServer::~HttpServer()
{
@ -834,7 +853,7 @@ namespace Tesses::Framework::Http
}
void HttpServer::Process(Stream& strm, IHttpServer& server, std::string ip, uint16_t port, bool encrypted)
{
TF_LOG("In process");
while(true)
{
BufferedStream bStrm(strm);
@ -863,6 +882,8 @@ namespace Tesses::Framework::Http
ctx.originalPath = pp[0];
ctx.path = ctx.originalPath;
TF_LOG(ctx.method + " with path " + ctx.path);
auto queryPart = pp[1];
if(!queryPart.empty())
{