Code Monkey home page Code Monkey logo

tntnet's Introduction

Tntnet

Tntnet is a web application server for web applications written in C++.

You can write a Web-page with HTML and with special tags you embed C++-code into the page for active contents. These pages, called components are compiled into C++-classes with the ecpp-compilier "ecppc", then compiled into objectcode and linked into a process or shared library.

This shared library is loaded by the webserver "tntnet" on request and executed.

The ecpp-compiler can create also C++-classes from static files of any type, e.g. you can compile a jpeg-image into the library. So the whole webapplication is a single library.

The application runs native, so they are very fast and compact.

Features supported include: cookies, HTTP-upload, automatic request-parameter parsing and conversion, automatic sessionmanagement, scoped variables (application, request and session), internationalisation, keep-alive.

Logging is done through cxxtools.

Tntnet is fully multithreaded, so it scales well on multiprocessor machines. It uses a dynamic pool of workerthreads, which answers requests from http-clients.

Installation

To install tntnet, you need cxxtools (http://www.tntnet.org/).

You can find generic installation instructions in the file INSTALL.

Quick start

To create a simple application run "tntnet-project hello". This creates a directory "hello" with a simple project and prints a short message, how to run the application.

There are some demo-applications you can try in demos. To run the demos without installing tntnet, change to the directory of the demo and run tntnet from the directory framework/runtime: cd hello ../../framework/runtime/tntnet

Tntnet listens on port 8000. Start your browser and navigate to: http://localhost:8000/

Documentation is provided in man pages and some documents found in the doc directory.

Ssl

Tntnet supports ssl. It must be configured in tntnet.xml or using the api. For ssl a certificate is needed. To create a self signed certificate run:

openssl req -x509 -nodes -days 1095 -utf8 -subj "/C=DE/L=Your Town/CN=$(hostname -f)/O=Your Organization/OU=Your unit" -newkey rsa:2048 -keyout tntnet.pem -out tntnet.pem

Client side certificates can be used to restrict access to tntnet.

tntnet's People

Contributors

geraldguillaume avatar jouven avatar maekitalo avatar stargater avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tntnet's Issues

tntnet 3.0 template folder

Hi,

I have a question about the folder tntnet/template. is it needed at runtime or can it be removed?
What is this directory needed for?

SSL server certificate chain

My server uses a server certificate that is signed with an intermediate certificate. When I use a file that is a concatenation of server and intermediate certificate, tntnet only delivers the first certificate. I checked this with openssl s_client -showcerts -connect mydomain.de:49443
Perhaps this is more a feature request than an issue :-)

configure.ac is a bit messy

Reading through configure.ac, I found several things done in multiple different ways throughout the file:

  • Option testing with test "$enable_option" = "yes" and test x$enable_option = xyes (e.g. line 135 and line 149)
  • Conditional code paths with AS_IF and the shell's if ... then ... endif (e.g. line 152 and line 196)

Also, the options -Wall and -pedantic are enabled (only) for the IBM C++ compiler. Why?

Server Name Indication on listeners

As written in http://www.tntnet.org/man/tntnet.xml.7.html,

the section specifies the ip addresses and ports. .... A listener must have a subnode ip and port.

And what about the so called "Server Name"? It's a must have in order to setup multiple ssl certificates for each domain name with only one IP.
The Server Name Indication (SNI) has been added to TLS some years ago. Can Tntnet listen on multiple server names (domain names), not only ips and ports? Can Tntnet listen on multiple domain names, all from a single IP address? And use a different certificate for each domain names?

For example:

<listeners>
  <listener>
    <servername>example1.com<servername>
    <ip>1.1.1.1</ip>
    <port>443</port>
    <!-- a certificate enables ssl -->
    <certificate>cert1.pem</certificate>
  </listener>

  <listener>
    <servername>example2.com<servername>
    <ip>1.1.1.1</ip>
    <port>443</port>
    <!-- a certificate enables ssl -->
    <certificate>cert2.pem</certificate>
  </listener>
</listeners>

Tommi, thank you very much.
Maurizio

config.h isn't installed

The (generated) file config.h currently isn't installed as part of the tntnet library, but is included in several headers: ssl.h, listener.h, pollerimpl.h, and on my fork's v3.0 branch tntconfig.has well (that's how I found out). I would suggest moving it from framework/common to framework/common/tnt.

If you think it shouldn't be installed, IMHO the headers including it shouldn't be installed either, and moved from framework/common/tnt to framework/common (and from _HEADERS to _SOURCES).

I will fix this on my fork and include it in the v3.0 branch. Here is what I use config.h for in tntconfig.h.

By the way, I would be happy discussion this and the other changes on there with you on IRC, or maybe gitter.im? It's pretty similar to IRC (in fact it allows connecting to it via IRC) but has a log / history so users don't have to be online simultaneously or use a bouncer.

Pointers in %session scope="global" don't work with latest git

Hi,

In my code:

<%session scope="global"> bool logged_in(false); FFmpegThread *f_worker = NULL; </%session>

With the latest git, this results in the following compiler error:
/usr/include/tnt/object.h:54:11: Fehler: ungültige Umwandlung von »long int« in »vdrlive::FFmpegThread*« [-fpermissive] 54 | : _obj(args...) | ^~~~~~~~~~~~~ | | | long int

Thanks, Markus

Hosting static files

Ok, I've got a (hopefully) dumb question.

I checked the docs, and it says:
http://www.tntnet.org/howto/static-howto.html

In tntnet.xml, I put the lines:

<mapping>
  <url>^/(.*)</url>
  <target>static@tntnet</target>
  <pathinfo>/var/www/htdocs/$1</pathinfo>
</mapping>

I'm using the basic sample:

int main(int argc, char* argv[])
{
	std::cerr << "Starting up CLabs webserver" << std::endl;
	try
	{
		tnt::Tntnet app;
		app.listen(8000);
		app.mapUrl("^/(.*)", "$1");
		app.mapUrl("^/([^.]+)(\\..+)?", "$1"); 

		app.run();
	}
	catch (const std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}
	std::cerr << "Shutting down webserver" << std::endl;
}

Yet, I get 404 errors for any of the files I have loaded in /var/www/htdocs/

I've tried slightly different versions of the files to make sure I didn't have a typo or something.

Do we have to do something in the code to enable static files? Do I need a different app.mapURL statement? Does that bypass tntnet.xml? Do you need a statement to read tntnet.xml?

Thank you,

== John ==

Deprecate Mapping::setPathInfo?

If I'm understanding Mapping::setPathInfo correctly, it doesn't provide any functionality beyond what Mapping::setArg does – so you could replace setPathInfo(value) with setArg("pathInfo", value) (if you'd also replace every request.getPathInfo() with request.getArg("pathInfo")).

That's why I'd like to propose to deprecate Mapping::setPathInfo, MapTarget::setPathInfo and so on and replace their current implementation with a simpler one just using the request arguments, until they can be removed completely (API break).

I'd happily implement this and create a PR if you think it's a good idea.

Problems with latest version of tntnet

Hello,

After installing the latest github version of the tools (cxxtools,
tntnet and tntdb), I have problems with my REST application. After a
while, tntnet no longer responds to requests. The program does not
stop but I have to restart the application. I didn't have that kind of
problem before. Do other people have this kind of problem ?

I just installed branches 3.0 for cxxtools and tntnet and 1.4 for
tntbd. I'll see if the problems are still there.

Jean-Marc

error 1 in function setgroups

I am starting tntnet with a systemd service unit, see attached configuration file: [email protected]
I am starting multiple instances, for example systemctl start [email protected] and systemctl start [email protected].

This systemd service sets the user and group to www-data. If user and group are also configured in the configuration file tntnet.xml (<user>www-data</user><group>www-data</group>), tntnet throws an exception: error 1 in function setgroups: Operation not permitted

Maybe tntnet should check user and group before calling the setgroups function?

It would be nice, if tntnet provides a special daemon mode for systemd services. systemd could be used for controlling the tntnet process.

My system is a Debian 9.6 (Stretch) and tntnet is compiled from master branch. The April 2018 version did not show this behavior.

Standalone tntnet-project templates require libtool

libtool is only needed when building libraries and including it (through LT_INIT) adds an additional build dependency as well as resulting in a bigger configure script that checks for things that aren't used.

I'll create a PR for this soon, just don't release tntnet 2.3 yet, please :)

build fails on armv6h architecture

Building for raspberry pi zero:
CXX tntnet-main.o main.cpp: In constructor 'tnt::TntnetProcess::TntnetProcess(int&, char**)': main.cpp:191:18: error: 'getuid' was not declared in this scope else if (getuid() != 0) ^~~~~~ main.cpp:191:18: note: suggested alternative: 'getline' else if (getuid() != 0) ^~~~~~ getline
there is no #include <unistd.h>

CORS

Is there a way to enable CORS for tntnet server?

tntnet no longer reads startup args from /etc/default/tntnet

Debian Linux Bullseye 11.3
Tntnet version 2.2.1-4

This is a completely new Debian Bulleye installation with freshly installed tntnet, the same setup works perfectly on Debian Buster (edit correction: my last known working tntnet version was on Debian 9 "Stretch").

I use the default startup file to specify an alternative configuration .xml file, but noticed it behaved as if using the default configs from /etc/tntnet.xml.

Contents of /etc/default/tntnet :

DAEMON_OPTS="--logall -c /usr/local/etc/tntnet.xml"

Nothing seems to be read on startup because there are no errors even when jibberish is typed into the startup config file.

Generated code for application-wide variables has unused typedef

This bit of ECPP

<%application scope="shared">
    GlobalConf a_conf;
</%application>

results is this generated C++

  typedef GlobalConf a_conf_type;
  TNT_APPLICATION_SHARED_VAR(GlobalConf, a_conf, ());   // <%application> GlobalConf a_conf

where the typedef isn't actually used. I suppose it's meant to be used as the first argument for TNT_APPLICATION_SHARED_VAR?

demo hello missing cxxtools lib

inside makefile of hello the cxxtools lib is not define and so the compilation has an error of link
in the history of demo/hello/Makefile.am it seems that it was perhaps correct in the past

unnamed QueryParams

With tntnet version 2.1 from the Debian repositories you can create tnt::QueryParams objects with unnamed parameters.
tnt::QueryParams tnt_qp; tnt_qp.add("value");

With the latest version from GitHub this only works with the class cxxtools::QueryParams from the cxxtools library. For now I am using a workaround:
cxxtools::QueryParams cxx_qp; cxx_qp.add("value"); tnt_qp.add(cxx_qp)

warning message: tntnet.service: Supervising process which is not our child ...

Debian Bullseye 11.3
tntnet 2.2.1-4

Note: this is a completely fresh Debian 11 installation with tntnet, the exact same configuration works fine on Deb 10.

When running command:
systemctl status tntnet

I see this warning (hostname is dev0).

● tntnet.service - Tntnet web server
Loaded: loaded (/lib/systemd/system/tntnet.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-04-10 18:35:37 PDT; 19h ago
Process: 2711879 ExecStart=/usr/bin/tntnet (code=exited, status=0/SUCCESS)
Main PID: 2711881 (tntnet)
Tasks: 9 (limit: 154413)
Memory: 1.3M
CPU: 211ms
CGroup: /system.slice/tntnet.service
├─2711880 /usr/bin/tntnet
└─2711881 /usr/bin/tntnet

Apr 10 18:35:37 dev0 systemd[1]: Starting Tntnet web server...
Apr 10 18:35:37 dev0 tntnet[2711879]: tntnet 2.2.1
Apr 10 18:35:37 dev0 systemd[1]: tntnet.service: Supervising process 2711881 which is not our child. We'll most likely not notice when it exits.

Something is wrong with the way systemd is being used. I posted another issue about the default startup file /etc/default/tntnet is not being read on startup, the issue with systemd may be a related.

Getiing error

when doing command make inside newly created project. Using tntnet version 3.0rc3

make: *** No targets specified and no makefile found. Stop.

compilation failure

httpreply.cpp: In member function ‘bool tnt::HttpReply::sendReply(unsigned int, const char*)’:
httpreply.cpp:476:20: error: cannot convert ‘std::ostream {aka std::basic_ostream}’ to ‘bool’ in return
return *_impl->socket;
^~~~~~

tntnet.worker requesttime exceeded

Hello,

We regularly encounter a problem with unsuccessful Ajax requests in an application using tntnet. For example on our component Login.ecpp. This component does not do any complex actions.

tntnet.worker returns this message to us:

FATAL tntnet.worker - requesttime 600s seconds in thread 139743169820416 exceeded - exit process

tntnet is completely blocked for a while. If we wait, everything works again.

We used the latest tntnet.

How do we debug this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.