├── IRCd ├── ircd │ ├── test.cpp │ ├── servers.hpp │ ├── ircsplit.hpp │ ├── transform.cpp │ ├── common.hpp │ ├── yield_assist.hpp │ ├── modes.cpp │ ├── readq.hpp │ ├── CMakeLists.txt │ ├── ciless.hpp │ ├── selftest.cpp │ ├── server_commands.cpp │ ├── modes.hpp │ ├── client_timeout.cpp │ ├── readq.cpp │ ├── ircsplit.cpp │ ├── server.hpp │ ├── client_new.cpp │ ├── perf_array.hpp │ ├── channel.hpp │ └── tokens.hpp ├── begin_test.sh ├── vm.json ├── update.sh ├── README.md ├── conanfile.txt ├── forward.sh ├── config.json ├── CMakeLists.txt ├── linux │ └── CMakeLists.txt ├── autoconf.cpp ├── test.py └── fill.py ├── LiveUpdate ├── ircd.version ├── motd_array.h ├── update.sh ├── conanfile.txt ├── config.json ├── README.md ├── ircd.motd ├── server.hpp ├── CMakeLists.txt ├── liu.hpp └── tls │ └── drive │ ├── test.pem │ └── test.key ├── http_client ├── .gitignore ├── vm.json ├── config.json ├── conanfile.txt ├── README.md ├── CMakeLists.txt └── service.cpp ├── microLB ├── .gitignore ├── update.sh ├── vm.json ├── conanfile.txt ├── README.md ├── config.json ├── server.js └── CMakeLists.txt ├── TCP_perf ├── .gitignore ├── send.sh ├── linux │ ├── test.sh │ ├── README.md │ ├── config.json │ └── CMakeLists.txt ├── vm.json ├── vmw.sh ├── receive.sh ├── docker_run.sh ├── config.json ├── conanfile.txt ├── README.md └── CMakeLists.txt ├── TLS_server ├── vm.json ├── drive │ ├── test.der │ ├── build.sh │ ├── test.pem │ ├── test.key │ └── server.key ├── config.json ├── art.yaml ├── conanfile.txt ├── README.md ├── fuzz.py ├── CMakeLists.txt ├── http.cpp └── service.cpp ├── protobuf ├── vm.json ├── person.proto ├── conanfile.txt ├── CMakeLists.txt ├── README.md └── service.cpp ├── transfer ├── vm.json ├── send_file.sh ├── config.json ├── README.md ├── conanfile.txt ├── linux │ └── CMakeLists.txt ├── CMakeLists.txt ├── server.py └── service.cpp ├── snake ├── vm.json ├── conanfile.txt ├── README.md ├── CMakeLists.txt └── service.cpp ├── starlight ├── vm.json ├── README.md ├── conanfile.txt ├── CMakeLists.txt └── service.cpp ├── 256_color_vga ├── vm.json ├── conanfile.txt ├── README.md └── CMakeLists.txt ├── STREAM ├── vm.json ├── conanfile.txt ├── README.md ├── CMakeLists.txt └── service.cpp ├── acorn ├── vm.json ├── disk1 │ └── public │ │ ├── favicon.ico │ │ ├── img │ │ ├── books.jpg │ │ ├── engine.png │ │ ├── squirrel.jpg │ │ └── includeos_logo.png │ │ ├── app │ │ ├── js │ │ │ ├── services │ │ │ │ ├── squirrel.js │ │ │ │ ├── dashboard.js │ │ │ │ └── cpusage.js │ │ │ ├── controllers │ │ │ │ ├── home.js │ │ │ │ └── squirrel.js │ │ │ ├── statman_treeview.js │ │ │ ├── stats.js │ │ │ └── app.js │ │ ├── views │ │ │ ├── 404.html │ │ │ ├── squirrels.html │ │ │ ├── home_no.html │ │ │ └── home.html │ │ └── index.html │ │ └── css │ │ └── main.css ├── config.json ├── dependencies.cmake ├── conanfile.txt ├── README.md ├── app │ ├── routes │ │ ├── routes │ │ ├── users.hpp │ │ ├── languages.hpp │ │ └── squirrels.hpp │ ├── acorn │ └── models │ │ └── user.hpp ├── fs │ ├── acorn_fs.hpp │ └── acorn_fs.cpp └── CMakeLists.txt ├── UDP_perf ├── vm.json ├── vmw.sh ├── receive.sh ├── docker_run.sh ├── config.json ├── send.sh ├── conanfile.txt ├── CMakeLists.txt └── README.md ├── vlan ├── vm.json ├── config.json ├── README.md ├── conanfile.txt ├── service.cpp └── CMakeLists.txt ├── demo_service ├── vm.json ├── config.json ├── conanfile.txt ├── conanfile_solo5.txt ├── README.md └── CMakeLists.txt ├── syslog ├── Makefile_linux ├── conanfile.txt ├── CMakeLists.txt ├── syslog_example.c ├── README.md └── service.cpp ├── websocket ├── disk │ ├── README.md │ └── index.html ├── config.json ├── conanfile.txt ├── README.md ├── CMakeLists.txt └── service.cpp ├── router ├── vm.json ├── README.md ├── conanfile.txt ├── config.json ├── CMakeLists.txt └── service.cpp ├── tcp ├── config.json ├── README.md ├── conanfile.txt ├── server.py ├── CMakeLists.txt └── service.cpp ├── scoped_profiler ├── config.json ├── run.sh ├── conanfile.txt ├── README.md ├── CMakeLists.txt └── service.cpp ├── Jenkinsfile ├── CMakeLists.txt └── README.md /IRCd/ircd/test.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LiveUpdate/ircd.version: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /http_client/.gitignore: -------------------------------------------------------------------------------- 1 | disk/ 2 | -------------------------------------------------------------------------------- /microLB/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /TCP_perf/.gitignore: -------------------------------------------------------------------------------- 1 | bla.txt 2 | build/ 3 | -------------------------------------------------------------------------------- /TLS_server/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem": 10 3 | } 4 | -------------------------------------------------------------------------------- /protobuf/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 32 3 | } 4 | -------------------------------------------------------------------------------- /transfer/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 128 3 | } 4 | -------------------------------------------------------------------------------- /snake/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 32, 3 | "vga" : "std" 4 | } 5 | -------------------------------------------------------------------------------- /starlight/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 12, 3 | "vga" : "qxl" 4 | } 5 | -------------------------------------------------------------------------------- /256_color_vga/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 6, 3 | "vga" : "qxl" 4 | } 5 | -------------------------------------------------------------------------------- /STREAM/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 256, 3 | "cpu" : {"model": "host"} 4 | } 5 | -------------------------------------------------------------------------------- /TCP_perf/send.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat bla.txt | ncat 10.0.0.42 1338 --send-only 3 | -------------------------------------------------------------------------------- /acorn/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "vmxnet3"}], 3 | "mem" : 64 4 | } 5 | -------------------------------------------------------------------------------- /TCP_perf/linux/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | AS_ROOT=ON lxp-run # TAP device needs sudo 3 | -------------------------------------------------------------------------------- /TCP_perf/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "vmxnet3"}], 3 | "mem" : 2048 4 | } 5 | -------------------------------------------------------------------------------- /UDP_perf/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio"}], 3 | "mem" : 1280 4 | } 5 | -------------------------------------------------------------------------------- /IRCd/begin_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for run in {1..1} 4 | do 5 | ./fill.py & 6 | done 7 | -------------------------------------------------------------------------------- /LiveUpdate/motd_array.h: -------------------------------------------------------------------------------- 1 | static const char motd_array[] = { 2 | #include "motd.h" 3 | , 0x0}; 4 | -------------------------------------------------------------------------------- /transfer/send_file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | dd if=/dev/zero bs=1280 count=1048576 > /dev/tcp/10.0.0.42/81 3 | -------------------------------------------------------------------------------- /IRCd/ircd/servers.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.hpp" 3 | 4 | struct Servers 5 | { 6 | 7 | }; 8 | -------------------------------------------------------------------------------- /http_client/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "backend": "user"} 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /vlan/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"} 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /TLS_server/drive/test.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/demo-examples/HEAD/TLS_server/drive/test.der -------------------------------------------------------------------------------- /demo_service/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"} 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /syslog/Makefile_linux: -------------------------------------------------------------------------------- 1 | all: 2 | $(CC) syslog_example.c -o syslog_linux 3 | 4 | clean: 5 | rm -f syslog_linux 6 | -------------------------------------------------------------------------------- /TCP_perf/vmw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | boot . -b -g 3 | pushd build 4 | ~/github/IncludeOS/etc/vmware tcp_perf.grub 5 | popd 6 | -------------------------------------------------------------------------------- /UDP_perf/vmw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | boot . -b -g 3 | pushd build 4 | ~/github/IncludeOS/etc/vmware udp_perf.grub 5 | popd 6 | -------------------------------------------------------------------------------- /acorn/disk1/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/demo-examples/HEAD/acorn/disk1/public/favicon.ico -------------------------------------------------------------------------------- /acorn/disk1/public/img/books.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/demo-examples/HEAD/acorn/disk1/public/img/books.jpg -------------------------------------------------------------------------------- /TCP_perf/receive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for i in `seq 1 4`; 3 | do 4 | ncat 10.0.0.42 1337 --recv-only > bla.txt 5 | done 6 | -------------------------------------------------------------------------------- /acorn/disk1/public/img/engine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/demo-examples/HEAD/acorn/disk1/public/img/engine.png -------------------------------------------------------------------------------- /acorn/disk1/public/img/squirrel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/demo-examples/HEAD/acorn/disk1/public/img/squirrel.jpg -------------------------------------------------------------------------------- /acorn/disk1/public/img/includeos_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/demo-examples/HEAD/acorn/disk1/public/img/includeos_logo.png -------------------------------------------------------------------------------- /http_client/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "dhcp" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /TCP_perf/linux/README.md: -------------------------------------------------------------------------------- 1 | ## How to run 2 | 3 | 1. Install the OS 4 | 5 | 2. Create TAP: `sudo mknod /dev/net/tap c 10 200` 6 | 7 | 3. `lxp-run` 8 | -------------------------------------------------------------------------------- /UDP_perf/receive.sh: -------------------------------------------------------------------------------- 1 | echo "Listening on port 1338 and dumping received data to recv.txt" 2 | ncat -p 1338 -u 10.0.0.42 1337 --recv-only > recv.txt 3 | -------------------------------------------------------------------------------- /IRCd/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "IRCd", 3 | "net" : [{"device" : "vmxnet3"}], 4 | "mem" : 1024, 5 | "uuid": "5cae2301-7467-424b-9def-e9bcbc85cf91" 6 | } 7 | -------------------------------------------------------------------------------- /websocket/disk/README.md: -------------------------------------------------------------------------------- 1 | The `index.html` is based on the template code found at [https://www.websocket.org/echo.html](https://www.websocket.org/echo.html). 2 | -------------------------------------------------------------------------------- /microLB/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BFOLD=build 3 | mkdir -p $BFOLD 4 | pushd $BFOLD 5 | cmake .. 6 | make -j8 7 | popd 8 | dd if=$BFOLD/microlb > /dev/tcp/10.0.0.42/666 9 | -------------------------------------------------------------------------------- /router/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:3a"} 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /LiveUpdate/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BFOLD=build 3 | mkdir -p $BFOLD 4 | pushd $BFOLD 5 | cmake .. 6 | make -j8 7 | popd 8 | dd if=$BFOLD/liveupdate > /dev/tcp/10.0.0.42/666 9 | -------------------------------------------------------------------------------- /TCP_perf/docker_run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e 3 | 4 | script_dir="$( cd "$( dirname "${bash_source[0]}" )" && pwd )" 5 | docker run --privileged -v $script_dir:/service -it includeos "$@" 6 | -------------------------------------------------------------------------------- /UDP_perf/docker_run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e 3 | 4 | script_dir="$( cd "$( dirname "${bash_source[0]}" )" && pwd )" 5 | docker run --privileged -v $script_dir:/service -it includeos "$@" 6 | -------------------------------------------------------------------------------- /IRCd/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #for i in `seq 1 100`: 4 | #do 5 | # dd if=./build/IRCd bs=9000 > /dev/tcp/10.0.0.42/666 6 | # sleep 1 7 | #done 8 | dd if=build/IRCd bs=9000 > /dev/tcp/10.0.0.42/666 9 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/services/squirrel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('acornWebApp') 4 | .factory('Squirrel', ['$resource', function($resource) { 5 | return $resource('/api/squirrels'); 6 | }]); 7 | -------------------------------------------------------------------------------- /microLB/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description" : "VM with 3 interfaces for load balancing", 3 | "net" : [ 4 | {"device" : "virtio"}, 5 | {"device" : "virtio"}, 6 | {"device" : "virtio"} 7 | ], 8 | "mem" : 512 9 | } 10 | -------------------------------------------------------------------------------- /acorn/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /TCP_perf/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /TLS_server/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /UDP_perf/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /transfer/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /TCP_perf/linux/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /tcp/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "dhcp-with-fallback", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /websocket/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net": [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /demo_service/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "dhcp-with-fallback", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /scoped_profiler/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "dhcp-with-fallback", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /IRCd/ircd/ircsplit.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | extern std::vector 6 | ircsplit(const std::string& text); 7 | 8 | extern std::vector 9 | ircsplit(const std::string& text, std::string& source); 10 | -------------------------------------------------------------------------------- /TLS_server/drive/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | openssl req -newkey rsa:4096 -nodes -sha512 -x509 -days 3650 -nodes -out test.pem -keyout test.key 3 | openssl x509 -outform der -in test.pem -out test.der 4 | openssl req -newkey rsa:4096 -nodes -sha512 -x509 -days 3650 -nodes -keyout server.key 5 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/services/dashboard.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('acornWebApp') 4 | .factory('Dashboard', ['$resource', function($resource) { 5 | return $resource('/api/dashboard', null, { 6 | query: {method: 'get', isArray: false } 7 | }); 8 | }]); 9 | -------------------------------------------------------------------------------- /scoped_profiler/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set - 3 | INCLUDEOS_PREFIX=${INCLUDEOS_PREFIX-/usr/local} 4 | 5 | FILE=$1 6 | shift 7 | export CMDLINE="-append ${1}" 8 | if [ $# -eq 0 ] 9 | then 10 | export CMDLINE="" 11 | fi 12 | source $INCLUDEOS_PREFIX/includeos/scripts/run.sh $FILE ${*} 13 | -------------------------------------------------------------------------------- /acorn/dependencies.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(ExternalProject) 3 | ExternalProject_Add(bucket 4 | GIT_REPOSITORY "https://github.com/includeos/bucket.git" 5 | PREFIX bucket 6 | CONFIGURE_COMMAND "" 7 | BUILD_COMMAND "" 8 | UPDATE_COMMAND "" 9 | INSTALL_COMMAND "" 10 | ) 11 | 12 | set(BUCKET_DIR ${CMAKE_CURRENT_BINARY_DIR}/bucket/src/) 13 | -------------------------------------------------------------------------------- /starlight/README.md: -------------------------------------------------------------------------------- 1 | ### Starlight 2 | 3 | This example shows VGA gfx demo showing animated starlight travel. 4 | 5 | ### Build and run service 6 | 7 | ``` 8 | mkdir build 9 | cd build 10 | conan install .. -pr 11 | source activate.sh 12 | cmake .. 13 | cmake --build . 14 | boot starlight 15 | source deactivate.sh 16 | ``` 17 | -------------------------------------------------------------------------------- /UDP_perf/send.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Starting test.." 3 | 4 | if [ -e send.txt ] 5 | then 6 | echo "File exists" 7 | else 8 | echo "Creating test file.." 9 | head -c 1G send.txt 10 | fi 11 | 12 | echo "Sending data in a loop..." 13 | 14 | while [ 1 ] 15 | do 16 | cat send.txt | ncat -u 10.0.0.42 1338 --send-only 17 | done 18 | -------------------------------------------------------------------------------- /IRCd/ircd/transform.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static char ASCII_LUT[256]; 4 | 5 | void transform_init() { 6 | 7 | for (size_t i = 0; i < 256; i++) { 8 | ASCII_LUT[i] = std::toupper(i); 9 | } 10 | 11 | } 12 | 13 | void transform_to_upper(std::string& str) 14 | { 15 | for (char& c : str) { 16 | c = ASCII_LUT[(unsigned) c]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vlan/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.38.0.1", 7 | "netmask": "255.255.255.0", 8 | 9 | "vlan" : [ 10 | { 11 | "id": 2, 12 | "address": "10.50.0.42", 13 | "netmask": "255.255.255.0" 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /IRCd/README.md: -------------------------------------------------------------------------------- 1 | # IRCd 2 | 3 | This example sets up an IRC server using [IncludeOS](https://github.com/includeos/includeos). 4 | 5 | ### Build and run service 6 | 7 | ``` 8 | mkdir build 9 | cd build 10 | conan install .. -pr 11 | source activate.sh 12 | cmake .. 13 | cmake --build . 14 | boot ircd_example 15 | source deactivate.sh 16 | ``` 17 | -------------------------------------------------------------------------------- /transfer/README.md: -------------------------------------------------------------------------------- 1 | # Transfer Service 2 | 3 | This is a TCP example service that demonstrates sending a file over a tcp connection. 4 | 5 | ### Build and run service 6 | 7 | ``` 8 | mkdir build 9 | cd build 10 | conan install .. -pr 11 | source activate.sh 12 | cmake .. 13 | cmake --build . 14 | boot transfer_service 15 | source deactivate.sh 16 | ``` 17 | -------------------------------------------------------------------------------- /protobuf/person.proto: -------------------------------------------------------------------------------- 1 | syntax="proto3"; 2 | 3 | message Person { 4 | int32 id = 1; 5 | string name = 2; 6 | string email = 3; 7 | 8 | enum PhoneType { 9 | MOBILE = 0; 10 | HOME = 1; 11 | WORK = 2; 12 | } 13 | 14 | message PhoneNumber { 15 | PhoneType type = 1; 16 | string number = 2; 17 | } 18 | 19 | repeated PhoneNumber phone = 4; 20 | } 21 | -------------------------------------------------------------------------------- /tcp/README.md: -------------------------------------------------------------------------------- 1 | ### TCP 2 | 3 | This TCP service creates a TCP/IP socket, binds the socket to a port and listens 4 | for incoming connections. 5 | 6 | ### Build and run service 7 | 8 | ``` 9 | mkdir build 10 | cd build 11 | conan install .. -pr 12 | source activate.sh 13 | cmake .. 14 | cmake --build . 15 | boot tcp_example 16 | source deactivate.sh 17 | ``` 18 | -------------------------------------------------------------------------------- /router/README.md: -------------------------------------------------------------------------------- 1 | ## IncludeOS Routing Service 2 | 3 | This example starts a [IncludeOS](https://github.com/includeos/includeos)routing service. 4 | 5 | ### Build and run service 6 | 7 | ``` 8 | mkdir build 9 | cd build 10 | conan install .. -pr 11 | source activate.sh 12 | cmake .. 13 | cmake --build . 14 | boot router_service 15 | source deactivate.sh 16 | ``` 17 | -------------------------------------------------------------------------------- /IRCd/ircd/common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define READQ_MAX 512 5 | 6 | typedef uint32_t clindex_t; 7 | typedef uint16_t chindex_t; 8 | typedef int sindex_t; 9 | 10 | #define NO_SUCH_CLIENT ((clindex_t) -1) 11 | #define NO_SUCH_CHANNEL ((chindex_t) -1) 12 | #define NO_SUCH_CHANNEL_INDEX UINT32_MAX 13 | #define NO_SUCH_SERVER ((int) -1) 14 | -------------------------------------------------------------------------------- /vlan/README.md: -------------------------------------------------------------------------------- 1 | ### IncludeOS VLAN example 2 | 3 | This service demonstrates how VLAN works in [IncludeOS](https://github.com/includeos/includeos) 4 | 5 | 6 | ### Build and run service 7 | 8 | ``` 9 | mkdir build 10 | cd build 11 | conan install .. -pr 12 | source activate.sh 13 | cmake .. 14 | cmake --build . 15 | boot vlan_service 16 | source deactivate.sh 17 | ``` 18 | -------------------------------------------------------------------------------- /IRCd/ircd/yield_assist.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | struct YieldCounter 5 | { 6 | YieldCounter(const int max) 7 | : MAX(max), counter(0) 8 | {} 9 | 10 | int MAX; 11 | int counter; 12 | 13 | 14 | YieldCounter& operator++ () 15 | { 16 | counter++; 17 | if (counter >= MAX) { 18 | counter = 0; 19 | os::block(); 20 | } 21 | return *this; 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /TLS_server/art.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | target: "http://10.0.0.42" 3 | phases: 4 | - duration: 60 5 | arrivalRate: 10 6 | plugins: 7 | fuzzer: {} 8 | scenarios: 9 | - name: "Fuzz some stuff" 10 | flow: 11 | - get: 12 | url: "/?hello-{{naughtyString}}" 13 | - log: "***** naughtyString = {{ naughtyString }}" 14 | - get: 15 | url: "/something/else?{{naughtyString}}" 16 | -------------------------------------------------------------------------------- /acorn/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | mana/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/views/404.html: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 | 14 | 15 |
16 |

404 - Not found

17 |
18 |
19 | -------------------------------------------------------------------------------- /IRCd/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | liveupdate/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /STREAM/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /router/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /snake/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /syslog/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /tcp/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /vlan/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /STREAM/README.md: -------------------------------------------------------------------------------- 1 | # STREAM 2 | 3 | STREAM is Sustainable Memory Bandwidth in High Performance Computers. The output from this service should show estimated memory bandwidth inside a virtual machine. 4 | 5 | ### Build and run service 6 | 7 | ``` 8 | mkdir build 9 | cd build 10 | conan install .. -pr 11 | source activate.sh 12 | cmake .. 13 | cmake --build . 14 | boot stream 15 | source deactivate.sh 16 | ``` 17 | -------------------------------------------------------------------------------- /TCP_perf/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /TLS_server/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /UDP_perf/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /demo_service/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /http_client/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /starlight/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /transfer/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /websocket/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /256_color_vga/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /IRCd/ircd/modes.cpp: -------------------------------------------------------------------------------- 1 | #include "modes.hpp" 2 | #include "common.hpp" 3 | 4 | // visible user modes 5 | mode_table_t usermodes("airoOws"); 6 | // visible channel modes (+eIb) 7 | mode_table_t chanmodes("klimnpstu"); 8 | 9 | mode_table_t::mode_table_t(const char* lut) 10 | : LUT(lut) {} 11 | 12 | uint16_t default_user_modes() 13 | { 14 | return 2; // +i 15 | } 16 | uint16_t default_channel_modes() 17 | { 18 | return 16 | 128; // +nt 19 | } 20 | -------------------------------------------------------------------------------- /scoped_profiler/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /256_color_vga/README.md: -------------------------------------------------------------------------------- 1 | # 256 color VGA demo 2 | 3 | An example of enabling and using 256-color pixel graphics to draw a [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set). 4 | 5 | > To run this example you need to have a GUI. 6 | 7 | ### Build and run service 8 | 9 | ``` 10 | mkdir build 11 | cd build 12 | conan install .. -pr 13 | source activate.sh 14 | cmake .. 15 | cmake --build . 16 | boot 256_color_vga 17 | source deactivate.sh 18 | ``` 19 | -------------------------------------------------------------------------------- /demo_service/conanfile_solo5.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [options] 11 | includeos:solo5=ON 12 | 13 | [generators] 14 | virtualenv 15 | cmake 16 | -------------------------------------------------------------------------------- /LiveUpdate/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | liveupdate/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | uplink/[>=0.14.0,include_prerelease=True]@includeos/latest 4 | [build_requires] 5 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 6 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | 10 | [generators] 11 | virtualenv 12 | cmake 13 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/controllers/home.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('acornWebApp') 4 | .controller('HomeCtrl', ['$cookies', function($cookies) { 5 | 6 | var chosen_language = $cookies.get('lang'); 7 | 8 | if(chosen_language == "en-US") { 9 | console.log("English language chosen!"); 10 | } else if(chosen_language == "nb-NO") { 11 | console.log("Norwegian language chosen!"); 12 | } else { 13 | console.log("No language chosen!"); 14 | } 15 | }]); 16 | -------------------------------------------------------------------------------- /microLB/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | microlb/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | liveupdate/[>=0.14.0,include_prerelease=True]@includeos/latest 4 | 5 | [build_requires] 6 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 10 | 11 | [generators] 12 | virtualenv 13 | cmake 14 | -------------------------------------------------------------------------------- /websocket/README.md: -------------------------------------------------------------------------------- 1 | # IncludeOS WebSocket Example 2 | 3 | This service demonstrates websocket, and utilizes memdisk, autoconf and http server. 4 | 5 | Start with service and visit [http://10.0.0.42](http://10.0.0.42) from a browser that supports WebSocket. 6 | 7 | ### Build and run service 8 | 9 | ``` 10 | mkdir build 11 | cd build 12 | conan install .. -pr 13 | source activate.sh 14 | cmake .. 15 | cmake --build . 16 | boot websocket_service 17 | source deactivate.sh 18 | ``` 19 | -------------------------------------------------------------------------------- /demo_service/README.md: -------------------------------------------------------------------------------- 1 | # IncludeOS Demo Service 2 | 3 | This demo-service should start an instance of [IncludeOS](https://github.com/includeos/includeos) that brings up a minimal web service on port 80 with static content. 4 | 5 | The default static IP is `10.0.0.42`, unless running on a network with DHCP. 6 | 7 | ### Build and run service 8 | 9 | ``` 10 | mkdir build 11 | cd build 12 | conan install .. -pr 13 | source activate.sh 14 | cmake .. 15 | cmake --build . 16 | boot demo 17 | source deactivate.sh 18 | ``` 19 | -------------------------------------------------------------------------------- /transfer/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | # Human-readable name of your service 8 | set(SERVICE_NAME "TCP Transfer From Linux") 9 | 10 | # Name of your service binary 11 | set(BINARY "tcp_linux") 12 | 13 | # Source files to be linked with OS library parts to form bootable image 14 | set(SOURCES 15 | ../service.cpp 16 | ) 17 | 18 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 19 | -------------------------------------------------------------------------------- /TLS_server/README.md: -------------------------------------------------------------------------------- 1 | ### IncludeOS TLS Server 2 | 3 | This TLS Server example should start an instance of [IncludeOS](https://github.com/includeos/includeos) that brings up a minimal web service on HTTPS port 443 with static content. 4 | 5 | The default static IP is 10.0.0.42, unless running on a network with DHCP. 6 | 7 | ### Build and run service 8 | 9 | ``` 10 | mkdir build 11 | cd build 12 | conan install .. -pr 13 | source activate.sh 14 | cmake .. 15 | cmake --build . 16 | boot tls_service 17 | source deactivate.sh 18 | ``` 19 | -------------------------------------------------------------------------------- /snake/README.md: -------------------------------------------------------------------------------- 1 | ### Snake game 2 | 3 | Using VGA text-mode in qemu (or possibly VirtualBox) we can play snake! 4 | 5 | > NOTE: This example requires the use of a video device. Otherwise it is unable 6 | to initialize SDL, thus the service will fail. 7 | 8 | ### Build and run service 9 | 10 | ``` 11 | mkdir build 12 | cd build 13 | conan install .. -pr 14 | source activate.sh 15 | cmake .. 16 | cmake --build . 17 | boot snake_example 18 | source deactivate.sh 19 | ``` 20 | 21 | Use arrow keys to change the snakes direction. Press spacebar to restart the game. 22 | -------------------------------------------------------------------------------- /microLB/README.md: -------------------------------------------------------------------------------- 1 | ### microLB demo 2 | 3 | Start the nodeJS demo services first: 4 | 5 | ``` 6 | $ node server.js 7 | ``` 8 | 9 | ### Build and run service 10 | 11 | Build and run the load balancer. 12 | 13 | ``` 14 | mkdir build 15 | cd build 16 | conan install .. -pr 17 | source activate.sh 18 | cmake .. 19 | cmake --build . 20 | boot microlb_example 21 | source deactivate.sh 22 | ``` 23 | 24 | ### Connect to the load balancer 25 | ``` 26 | curl 10.0.0.42 27 | ``` 28 | 29 | The load balancer should be configured to round-robin on `10.0.0.1` ports 6001-6004. 30 | -------------------------------------------------------------------------------- /IRCd/forward.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script for forwarding packets from IncludeOS running on a nested qemu interface 4 | # This works on ubuntu 16.04 5 | # Make sure ip forwarding is enabled by running: sysctl -w net.ipv4.ip_forward=1 6 | 7 | OUTWARD_FACING_INTERFACE=enp2s0 8 | BRIDGE_INTERFACE=bridge43 9 | 10 | # Clear iptables 11 | sudo iptables -t nat -F 12 | 13 | # Masks the source address 14 | sudo iptables -t nat -A POSTROUTING -o $OUTWARD_FACING_INTERFACE -j MASQUERADE 15 | 16 | # Sets the packets coming from bridge43 to be natted 17 | sudo iptables -t nat -A PREROUTING -i $BRIDGE_INTERFACE -p udp -m udp 18 | -------------------------------------------------------------------------------- /http_client/README.md: -------------------------------------------------------------------------------- 1 | # IncludeOS HTTP Client example 2 | 3 | This example will send a GET request to http://www.google.com with our Basic_client, and to https://www.google.com with our HTTPS supported Client. 4 | For the example to succeed, make sure your virtual machine can reach the internet (ip forward & nat). 5 | 6 | For example purpose only. Don't reuse the `server.pem` certificate. 7 | 8 | ### Build and run service 9 | 10 | ``` 11 | mkdir build 12 | cd build 13 | conan install .. -pr 14 | source activate.sh 15 | cmake .. 16 | cmake --build . 17 | boot http_demo 18 | source deactivate.sh 19 | ``` 20 | -------------------------------------------------------------------------------- /IRCd/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "dhcp-with-fallback", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ], 11 | 12 | "uplink": { 13 | "iface": 0, 14 | "url": "10.20.17.12:9090", 15 | "token": "kappa123", 16 | "reboot": true 17 | }, 18 | 19 | "ircd": { 20 | "client_iface": 0, 21 | "client_port": 6667, 22 | "server_iface": 0, 23 | "server_port": 7000, 24 | "server_id": 0, 25 | "server_name": "irc.includeos.org", 26 | "server_netw": "IncludeNet" 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /TCP_perf/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | option(PORTABLE "" OFF) 8 | 9 | # Human-readable name of your service 10 | set(SERVICE_NAME "Linux TCP perf service") 11 | 12 | # Name of your service binary 13 | set(BINARY "tcp_perf") 14 | 15 | # Source files to be linked with OS library parts to form bootable image 16 | set(SOURCES 17 | ../service.cpp 18 | ) 19 | 20 | set(PLUGINS 21 | autoconf 22 | ) 23 | 24 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 25 | -------------------------------------------------------------------------------- /protobuf/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | includeos/[>=0.14.0,include_prerelease=True]@includeos/latest 3 | protobuf/3.6.1@bincrafters/stable 4 | 5 | [build_requires] 6 | vmrunner/[>=0.14.0,include_prerelease=True]@includeos/latest 7 | vmbuild/[>=0.14.0,include_prerelease=True]@includeos/latest 8 | chainloader/[>=0.14.0,include_prerelease=True]@includeos/latest 9 | diskbuilder/[>=0.14.0,include_prerelease=True]@includeos/latest 10 | protoc_installer/3.6.1@bincrafters/stable 11 | 12 | [options] 13 | protobuf:shared=False 14 | protobuf:lite=False 15 | protobuf:fPIC=True 16 | protobuf:with_zlib=False 17 | 18 | [generators] 19 | virtualenv 20 | cmake 21 | -------------------------------------------------------------------------------- /TLS_server/fuzz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | import socket #for sockets 3 | import sys #for exit 4 | 5 | remote_ip = '10.0.0.42' 6 | port = 80 7 | 8 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 9 | s.connect((remote_ip , port)) 10 | 11 | payload="t/" * 16000000 12 | 13 | #Send some data to remote server 14 | message = str.encode("GET / HTTP/1.1\r\nContent-Length: 16000000\r\n\r\n%s" % payload) 15 | 16 | #print("SENDING >>> " + str(message)) 17 | try : 18 | #Set the whole string 19 | s.sendall(message) 20 | except socket.error: 21 | #Send failed 22 | print('Send failed') 23 | sys.exit() 24 | 25 | data = s.recv(512) 26 | print(data) 27 | -------------------------------------------------------------------------------- /IRCd/ircd/readq.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct ReadQ 6 | { 7 | typedef delegate on_read_func; 8 | // returns false if max readq exceeded 9 | bool read(uint8_t* buf, size_t len, on_read_func); 10 | 11 | size_t size() const noexcept { 12 | return buffer.size(); 13 | } 14 | const std::string& get() const noexcept { 15 | return buffer; 16 | } 17 | void set(std::string val) { 18 | buffer = std::move(val); 19 | } 20 | void clear() { 21 | buffer.clear(); 22 | buffer.shrink_to_fit(); 23 | } 24 | 25 | private: 26 | std::string buffer; 27 | }; 28 | -------------------------------------------------------------------------------- /TCP_perf/README.md: -------------------------------------------------------------------------------- 1 | # IncludeOS TCP Performance 2 | 3 | This service demonstrates TCP performance by sending and receiving data. 4 | 5 | ### Build and run service 6 | 7 | ``` 8 | mkdir build 9 | cd build 10 | conan install .. -pr 11 | source activate.sh 12 | cmake .. 13 | cmake --build . 14 | boot tcp_perf_service 15 | source deactivate.sh 16 | ``` 17 | 18 | ### Howto: 19 | 20 | Receive data from the instance: 21 | ``` 22 | ncat 10.0.0.42 1337 --recv-only > bla.txt 23 | ``` 24 | 25 | Send data to the instance: 26 | ``` 27 | cat bla.txt | ncat 10.0.0.42 1338 --send-only 28 | ``` 29 | 30 | Configure by changing the variables at the top. 31 | -------------------------------------------------------------------------------- /256_color_vga/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | #service 7 | project (service) 8 | if (NOT DEFINED CONAN_DEPENDENCIES) 9 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 10 | if (NOT HAS_CONAN) 11 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 12 | endif() 13 | endif() 14 | conan_basic_setup() 15 | 16 | 17 | include(os) 18 | 19 | set(SOURCES 20 | service.cpp # ...add more here 21 | ) 22 | 23 | os_add_executable(256_color_vga "Mode 13h Example Service" ${SOURCES}) 24 | -------------------------------------------------------------------------------- /LiveUpdate/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | } 10 | ], 11 | 12 | "terminal": { 13 | "iface": 0, 14 | "port": 23 15 | }, 16 | 17 | "uplink": { 18 | "iface": 0, 19 | "url": "10.20.17.12:9090", 20 | "token": "kappa123", 21 | "reboot": true 22 | }, 23 | 24 | "ircd": { 25 | "client_iface": 0, 26 | "client_port": 6667, 27 | "server_iface": 0, 28 | "server_port": 7000, 29 | "server_id": 0, 30 | "server_name": "irc.includeos.org", 31 | "server_netw": "IncludeNet" 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /IRCd/ircd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # IRC Server CMake 3 | # 4 | # Custom version string of the IRC server 5 | set(VERSION "v0.3 IRCd") 6 | 7 | set(SOURCES 8 | channel.cpp 9 | client.cpp 10 | client_commands.cpp 11 | client_new.cpp 12 | client_send.cpp 13 | client_timeout.cpp 14 | ircd.cpp 15 | ircsplit.cpp 16 | modes.cpp 17 | readq.cpp 18 | selftest.cpp 19 | server.cpp 20 | server_commands.cpp 21 | test.cpp 22 | transform.cpp 23 | ) 24 | 25 | if (LIVEUPDATE) 26 | list(APPEND SOURCES 27 | restore.cpp 28 | ) 29 | set(LIBRARIES libliveupdate.a) 30 | endif() 31 | 32 | add_library(ircd ${SOURCES}) 33 | target_compile_definitions(ircd PUBLIC IRC_SERVER_VERSION="${VERSION}") 34 | -------------------------------------------------------------------------------- /http_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8.0) 2 | 3 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 4 | 5 | project (http_client C CXX) 6 | 7 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 8 | if (NOT HAS_CONAN) 9 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 10 | endif() 11 | conan_basic_setup() 12 | 13 | include(os) 14 | 15 | os_add_executable(http_client "http_client" service.cpp) 16 | os_add_drivers(http_client virtionet vmxnet3 e1000 boot_logger timestamps) 17 | os_add_plugins(http_client autoconf) 18 | os_add_stdout(http_client default_stdout) 19 | os_add_ssl_certificates(http_client) 20 | -------------------------------------------------------------------------------- /IRCd/ircd/ciless.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct ci_less : std::binary_function 4 | { 5 | // case-independent (ci) compare_less binary function 6 | struct nocase_compare : public std::binary_function 7 | { 8 | bool operator() (const unsigned char& c1, const unsigned char& c2) const { 9 | return tolower (c1) < tolower (c2); 10 | } 11 | }; 12 | bool operator() (const std::string& s1, const std::string& s2) const { 13 | return std::lexicographical_compare 14 | (s1.begin(), s1.end(), // source range 15 | s2.begin(), s2.end(), // dest range 16 | nocase_compare()); // comparison 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /router/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.38.0.1", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.38.0.254" 9 | }, 10 | { 11 | "iface": 1, 12 | "config": "static", 13 | "address": "10.39.0.1", 14 | "netmask": "255.255.255.0", 15 | "gateway": "10.39.0.254" 16 | } 17 | 18 | ], 19 | "router" : [ 20 | [ 21 | { 22 | "address": "10.38.0.0", 23 | "netmask": "255.255.255.0", 24 | "iface" : 0 25 | }, 26 | { 27 | "address": "10.39.0.0", 28 | "netmask": "255.255.255.0", 29 | "iface" : 1 30 | } 31 | ] 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /snake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project (snake) 9 | #check if conan is already run outside of project 10 | if (NOT DEFINED CONAN_DEPENDENCIES) 11 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 12 | if (NOT HAS_CONAN) 13 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 14 | endif() 15 | endif() 16 | conan_basic_setup() 17 | 18 | include(os) 19 | 20 | set(SOURCES 21 | service.cpp # ...add more here 22 | ) 23 | 24 | os_add_executable(snake_example "Snake Example Service" ${SOURCES}) 25 | -------------------------------------------------------------------------------- /scoped_profiler/README.md: -------------------------------------------------------------------------------- 1 | ### IncludeOS Scoped Profiler Demo 2 | 3 | Add `ScopedProfiler sp;` in the scopes that you want to profile. Don't forget to `#include `. 4 | 5 | Rebuild / install IncludeOS: 6 | 7 | ``` 8 | cd IncludeOS 9 | mkdir build 10 | cd build 11 | cmake .. 12 | make 13 | make install 14 | ``` 15 | 16 | 17 | ### Build and run service 18 | 19 | ``` 20 | mkdir build 21 | cd build 22 | conan install .. -pr 23 | source activate.sh 24 | cmake .. 25 | cmake --build . 26 | boot scoped_profiler_example 27 | source deactivate.sh 28 | ``` 29 | 30 | Make something happen in the OS and then use wget or curl to `GET /profile` to see statistics: 31 | 32 | ``` 33 | curl 10.0.0.42/profile 34 | ``` 35 | -------------------------------------------------------------------------------- /IRCd/ircd/selftest.cpp: -------------------------------------------------------------------------------- 1 | #include "ircsplit.hpp" 2 | #include 3 | 4 | void selftest() 5 | { 6 | auto vec = ircsplit(":"); 7 | assert(vec.size() == 1 && vec[0] == ":"); 8 | 9 | vec = ircsplit("A"); 10 | assert(vec.size() == 1 && vec[0] == "A"); 11 | 12 | vec = ircsplit("ABC"); 13 | assert(vec.size() == 1 && vec[0] == "ABC"); 14 | 15 | vec = ircsplit("A B C"); 16 | assert(vec.size() == 3 && vec[0] == "A" && vec[1] == "B" && vec[2] == "C"); 17 | 18 | // second parameter can be long 19 | vec = ircsplit("A :B C D"); 20 | assert(vec.size() == 2 && vec[0] == "A" && vec[1] == "B C D"); 21 | 22 | // first parameter can't be long 23 | vec = ircsplit(":A B C D"); 24 | assert(vec.size() == 4 && vec[0] == ":A"); 25 | } 26 | -------------------------------------------------------------------------------- /starlight/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project (service) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | 20 | include(os) 21 | 22 | set(SOURCES 23 | service.cpp # ...add more here 24 | ) 25 | 26 | os_add_executable(starlight "Starlight Mode 13h" ${SOURCES}) 27 | -------------------------------------------------------------------------------- /LiveUpdate/README.md: -------------------------------------------------------------------------------- 1 | ### LiveUpdate Demo Service 2 | 3 | This service should start an instance of [IncludeOS](https://github.com/includeos/includeos) that brings up a minimal web service on port 80 with static content. When running update.sh the service should be updated with itself. 4 | 5 | 6 | ### Build and run service 7 | 8 | * To Build: 9 | 10 | ``` 11 | $ mkdir build 12 | $ cd build 13 | $ conan install .. -pr 14 | $ source activate.sh 15 | $ cmake .. 16 | $ cmake --build . 17 | ``` 18 | 19 | * To run the serive: 20 | 21 | ``` 22 | $ boot ircd_example 23 | ``` 24 | 25 | * To update: 26 | 27 | ``` 28 | $ ./update.sh 29 | ``` 30 | 31 | When finished, reset configurations: 32 | 33 | ``` 34 | $ source deactivate.sh 35 | ``` 36 | -------------------------------------------------------------------------------- /STREAM/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project (service) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | 20 | include(os) 21 | 22 | set(SOURCES 23 | service.cpp stream.cpp 24 | ) 25 | 26 | os_add_executable(stream "STREAM benchmark" ${SOURCES}) 27 | os_add_stdout(stream default_stdout) 28 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/controllers/squirrel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('acornWebApp') 4 | .controller('SquirrelCtrl', ['$scope', 'Squirrel', 'toastr', function($scope, Squirrel, toastr) { 5 | 6 | $scope.squirrel = new Squirrel(); 7 | $scope.squirrels = []; 8 | 9 | $scope.squirrels = Squirrel.query(function() {}); 10 | 11 | $scope.create = function() { 12 | $scope.squirrel.$save({}, 13 | function(squirrel, headers) { 14 | $scope.squirrels.push(squirrel); 15 | $scope.squirrel = new Squirrel(); 16 | toastr.success('Squirrel captured!', 'Success'); 17 | }, 18 | function(error) { 19 | //console.log(error); 20 | toastr.error(error.data.message, error.data.type); 21 | } 22 | ); 23 | }; 24 | }]); 25 | -------------------------------------------------------------------------------- /scoped_profiler/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project(router_service C CXX) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | include(os) 20 | # Source file 21 | 22 | os_add_executable(scoped_profiler_example "Scoped Profiler Example" service.cpp) 23 | # Human-readable name of your service 24 | os_add_drivers(scoped_profiler_example 25 | virtionet 26 | ) 27 | -------------------------------------------------------------------------------- /microLB/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "iface": 0, 5 | "config": "static", 6 | "address": "10.0.0.42", 7 | "netmask": "255.255.255.0", 8 | "gateway": "10.0.0.1" 9 | }, 10 | { 11 | "iface": 1, 12 | "config": "static", 13 | "address": "10.0.0.44", 14 | "netmask": "255.255.255.0", 15 | "gateway": "10.0.0.1" 16 | } 17 | ], 18 | 19 | "load_balancer" : { 20 | "clients" : { 21 | "iface" : 0, 22 | "port" : 80, 23 | "waitq_limit" : 1000, 24 | "session_limit" : 1000 25 | }, 26 | "nodes" : { 27 | "iface" : 1, 28 | "algo" : "round_robin", 29 | "list" : [ 30 | ["10.0.0.1", 6001], 31 | ["10.0.0.1", 6002], 32 | ["10.0.0.1", 6003], 33 | ["10.0.0.1", 6004] 34 | ] 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LiveUpdate/ircd.motd: -------------------------------------------------------------------------------- 1 | .-') _ _ .-') _ ('-. .-') 2 | ( OO ) ) ( ( OO) ) _( OO) ( OO ). 3 | ,-.-') ,--./ ,--,' .-----. ,--. ,--. ,--. \ .'_ (,------. .-'),-----. (_)---\_) 4 | | |OO)| \ | |\ ' .--./ | |.-') | | | | ,`'--..._) | .---' ( OO' .-. '/ _ | 5 | | | \| \| | )| |('-. | | OO )| | | .-') | | \ ' | | / | | | |\ :` `. 6 | | |(_/| . |//_) |OO )| |`-' || |_|( OO )| | ' |(| '--. \_) | |\| | '..`''.) 7 | ,| |_.'| |\ | || |`-'|(| '---.'| | | `-' /| | / : | .--' \ | | | |.-._) \ 8 | (_| | | | \ |(_' '--'\ | |(' '-'(_.-' | '--' / | `---. `' '-' '\ / 9 | `--' `--' `--' `-----' `------' `-----' `-------' `------' `-----' `-----' 10 | -------------------------------------------------------------------------------- /acorn/README.md: -------------------------------------------------------------------------------- 1 | # acorn 2 | Acorn Web Server Appliance running on IncludeOS. 3 | 4 | ### Features 5 | 6 | * Serve static content from a disk with just a few lines of code. 7 | * RESTful API service reading and posting JSON. 8 | * Real-time information about the server with an interactive Dashboard 9 | 10 | Acorn is a simple web server using a collection of libraries and extensions: 11 | 12 | * [Mana](https://github.com/includeos/mana) - IncludeOS Web Appliance Framework 13 | * [Bucket](https://github.com/includeos/bucket) - Simplified in-memory database 14 | 15 | Content to be served can be found (and edited) in the directory [disk1](disk1/). 16 | 17 | ### Build and run service 18 | 19 | ``` 20 | mkdir build 21 | cd build 22 | conan install .. -pr 23 | source activate.sh 24 | cmake .. 25 | cmake --build . 26 | boot acorn 27 | source deactivate.sh 28 | ``` 29 | -------------------------------------------------------------------------------- /syslog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | # Service 8 | project (syslogd) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | 20 | include(os) 21 | 22 | set(SOURCES 23 | service.cpp # ...add more here 24 | ) 25 | 26 | os_add_executable(syslog_service "Syslog plugin example" ${SOURCES}) 27 | 28 | os_add_drivers(syslog_service 29 | virtionet 30 | ) 31 | 32 | os_add_stdout(syslog_service default_stdout) 33 | os_add_plugins(syslog_service syslogd) 34 | -------------------------------------------------------------------------------- /IRCd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | option(REAL_HW "Run on real hardware" OFF) 7 | option(LIVEUPDATE "Enable liveupdate" ON) 8 | 9 | #service 10 | project (ircd_example) 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | include(os) 20 | 21 | add_subdirectory(ircd) 22 | 23 | os_add_executable(ircd_example "IRC service" service.cpp autoconf.cpp) 24 | os_add_drivers(ircd_example vmxnet3) 25 | os_add_plugins(ircd_example autoconf) 26 | os_add_stdout(ircd_example default_stdout) 27 | os_link_libraries(ircd_example ircd) 28 | -------------------------------------------------------------------------------- /transfer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project (transfer) 9 | #check if conan is already run outside of project 10 | if (NOT DEFINED CONAN_DEPENDENCIES) 11 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 12 | if (NOT HAS_CONAN) 13 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 14 | endif() 15 | endif() 16 | conan_basic_setup() 17 | 18 | 19 | include(os) 20 | 21 | 22 | # Source files to be linked with OS library parts to form bootable image 23 | set(SOURCES 24 | service.cpp # ...add more here 25 | ) 26 | 27 | os_add_executable(transfer_service "TCP Example Service" ${SOURCES}) 28 | os_add_drivers(transfer_service virtionet) 29 | os_add_stdout(transfer_service default_stdout) 30 | -------------------------------------------------------------------------------- /protobuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | project(protobuf_test_service C CXX) 8 | #check if conan is already run outside of project 9 | if (NOT DEFINED CONAN_DEPENDENCIES) 10 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 11 | if (NOT HAS_CONAN) 12 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 13 | endif() 14 | endif() 15 | conan_basic_setup() 16 | 17 | find_package(Protobuf REQUIRED) 18 | protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS person.proto) 19 | 20 | include(os) 21 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 22 | os_add_executable(protobuf_test_service "Google's protobuf runtime library test" service.cpp ${PROTO_SRCS} ${PROTO_HDRS}) 23 | os_add_stdout(protobuf_test_service default_stdout) 24 | -------------------------------------------------------------------------------- /acorn/app/routes/routes: -------------------------------------------------------------------------------- 1 | // -*-C++-*- 2 | // This file is a part of the IncludeOS unikernel - www.includeos.org 3 | // 4 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 5 | // and Alfred Bratterud 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | #ifndef ROUTES_ROUTES 20 | #define ROUTES_ROUTES 21 | 22 | #include "squirrels.hpp" 23 | #include "users.hpp" 24 | #include "languages.hpp" 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/statman_treeview.js: -------------------------------------------------------------------------------- 1 | function fillTree(tree, name, val) { 2 | var parts = name.split('.'); 3 | 4 | var current = null, 5 | existing = null, 6 | i = 0; 7 | 8 | if (!tree.nodes || typeof tree.nodes == 'undefined') 9 | tree = { text: parts[y], nodes: [] }; 10 | 11 | current = tree.nodes; 12 | 13 | for (var y = 0; y < parts.length; y++) { 14 | if (y != parts.length - 1) { 15 | existing = null; 16 | 17 | for (i = 0; i < current.length; i++) { 18 | if (current[i].text === parts[y]) { 19 | existing = current[i]; 20 | break; 21 | } 22 | } 23 | 24 | if (existing) { 25 | current = existing.nodes; 26 | } else { 27 | current.push({ id: i, text: parts[y], nodes: [] }); 28 | current = current[current.length - 1].nodes; 29 | } 30 | } else { 31 | // leaf node 32 | current.push({ id: i, text: parts[y], value: val, path: name }); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tcp/server.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | 4 | # Create a TCP/IP socket 5 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | 7 | # Bind the socket to the port 8 | server_address = ('127.0.0.1', 1337) 9 | print >>sys.stderr, 'starting up on %s port %s' % server_address 10 | sock.bind(server_address) 11 | 12 | # Listen for incoming connections 13 | sock.listen(5) 14 | 15 | while True: 16 | # Wait for a connection 17 | print >>sys.stderr, 'waiting for a connection' 18 | connection, client_address = sock.accept() 19 | 20 | try: 21 | print >>sys.stderr, 'connection from', client_address 22 | 23 | while True: 24 | data = connection.recv(1024) 25 | if data: 26 | print >>sys.stderr, 'received: %s' % data 27 | connection.sendall(data) 28 | else: 29 | print >>sys.stderr, 'closing', client_address 30 | break 31 | 32 | finally: 33 | # Clean up the connection 34 | connection.close() -------------------------------------------------------------------------------- /vlan/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2017 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | void Service::start() 23 | { 24 | net::setup_vlans(); 25 | auto& eth0 = net::Interfaces::get(0); 26 | 27 | auto& vlan0_2 = net::Interfaces::get(0,2); 28 | } 29 | -------------------------------------------------------------------------------- /IRCd/ircd/server_commands.cpp: -------------------------------------------------------------------------------- 1 | #include "server.hpp" 2 | #include 3 | #define BUFFER_SIZE 1024 4 | 5 | typedef delegate&)> command_func_t; 6 | static std::unordered_map funcs; 7 | 8 | static void handle_ping(Server& server, const std::vector& msg) 9 | { 10 | if (msg.size() > 1) { 11 | char buffer[64]; 12 | int len = snprintf(buffer, sizeof(buffer), 13 | "PONG :%s\r\n", msg[1].c_str()); 14 | if (len > 0) server.send(buffer, len); 15 | } 16 | } 17 | static void handle_pong(Server&, const std::vector&) 18 | { 19 | // do nothing 20 | } 21 | 22 | void Server::handle_commands(const std::vector& msg) 23 | { 24 | auto it = funcs.find(msg[0]); 25 | if (it != funcs.end()) { 26 | it->second(*this, msg); 27 | } 28 | else { 29 | this->squit("Unknown command: " + msg[0]); 30 | } 31 | } 32 | 33 | void Server::init() 34 | { 35 | funcs["PING"] = handle_ping; 36 | funcs["PONG"] = handle_pong; 37 | } 38 | -------------------------------------------------------------------------------- /acorn/fs/acorn_fs.hpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #pragma once 19 | #ifndef ACORN_FS_HPP 20 | #define ACORN_FS_HPP 21 | 22 | #include 23 | #include 24 | 25 | namespace acorn 26 | { 27 | void list_static_content(const fs::File_system&); 28 | } 29 | 30 | #endif //< ACORN_FS_HPP 31 | -------------------------------------------------------------------------------- /tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | # Service 8 | project (tcp) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | 20 | include(os) 21 | 22 | set(SOURCES 23 | service.cpp # ...add more here 24 | ) 25 | 26 | os_add_executable(tcp_service "TCP example" ${SOURCES}) 27 | 28 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 29 | os_add_drivers(tcp_service 30 | solo5net 31 | ) 32 | else() 33 | os_add_drivers(tcp_service 34 | virtionet 35 | vmxnet3 36 | e1000 37 | boot_logger 38 | ) 39 | endif() 40 | 41 | os_add_stdout(tcp_service default_stdout) 42 | os_add_plugins(tcp_service autoconf) 43 | -------------------------------------------------------------------------------- /vlan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | # Service 7 | project (vlan) 8 | 9 | #check if conan is already run outside of project 10 | if (NOT DEFINED CONAN_DEPENDENCIES) 11 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 12 | if (NOT HAS_CONAN) 13 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 14 | endif() 15 | endif() 16 | conan_basic_setup() 17 | 18 | include(os) 19 | 20 | set(SOURCES 21 | service.cpp # ...add more here 22 | ) 23 | 24 | os_add_executable(vlan_service "VLAN example" ${SOURCES}) 25 | 26 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 27 | os_add_drivers(vlan_service 28 | solo5net 29 | ) 30 | else() 31 | os_add_drivers(vlan_service 32 | virtionet 33 | vmxnet3 34 | e1000 35 | boot_logger 36 | ) 37 | endif() 38 | 39 | os_add_stdout(vlan_service default_stdout) 40 | os_add_plugins(vlan_service autoconf) 41 | -------------------------------------------------------------------------------- /transfer/server.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | 4 | # Create a TCP/IP socket 5 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | 7 | # Bind the socket to the port 8 | server_address = ('10.0.0.1', 1337) 9 | print 'starting up on %s port %s' % server_address 10 | sock.bind(server_address) 11 | 12 | # Listen for incoming connections 13 | sock.listen(5) 14 | 15 | while True: 16 | # Wait for a connection 17 | print 'waiting for a connection' 18 | connection, client_address = sock.accept() 19 | 20 | try: 21 | print 'connection from', client_address 22 | bytes = 0 23 | 24 | while True: 25 | data = connection.recv(8192) 26 | if data: 27 | bytes += len(data) 28 | #print 'received: %d' % len(data) 29 | connection.sendall(data) 30 | else: 31 | print 'received %d bytes' % bytes 32 | print 'closing', client_address 33 | break 34 | 35 | finally: 36 | # Clean up the connection 37 | connection.close() 38 | -------------------------------------------------------------------------------- /protobuf/README.md: -------------------------------------------------------------------------------- 1 | ### Test service for Google's protobuf runtime library 2 | 3 | This service is to test our build of the protobuf runtime library, therefore it can only be built if [IncludeOS](https://github.com/includeos/includeos) was installed with the `libprotobuf` option set to `ON`. 4 | 5 | 6 | __Add the bincrafters remote__ 7 | 8 | For protobuf specifically, we use bincrafters conan package, thus you need to add the bincrafters remote to your remote list. 9 | 10 | ``` 11 | $ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan 12 | ``` 13 | 14 | __Verify remotes:__ 15 | 16 | ``` 17 | $ conan remote list 18 | includeos: https://api.bintray.com/conan/includeos/includeos [Verify SSL: True] 19 | bincrafters: https://api.bintray.com/conan/bincrafters/public-conan [Verify SSL: True] 20 | ``` 21 | 22 | 23 | ### Build and run service 24 | 25 | ``` 26 | mkdir build 27 | cd build 28 | conan install .. -pr 29 | source activate.sh 30 | cmake .. 31 | cmake --build . 32 | boot protobuf_test_service 33 | source deactivate.sh 34 | ``` 35 | -------------------------------------------------------------------------------- /TCP_perf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | #service 7 | project (tcpperf) 8 | 9 | #check if conan is already run outside of project 10 | if (NOT DEFINED CONAN_DEPENDENCIES) 11 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 12 | if (NOT HAS_CONAN) 13 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 14 | endif() 15 | endif() 16 | conan_basic_setup() 17 | 18 | include(os) 19 | 20 | set(SOURCES 21 | service.cpp # ...add more here 22 | ) 23 | 24 | os_add_executable(tcp_perf_service "TCP benchmarking" ${SOURCES}) 25 | 26 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 27 | os_add_drivers(tcp_perf_service 28 | solo5net 29 | #solo5blk 30 | ) 31 | else() 32 | os_add_drivers(tcp_perf_service 33 | virtionet 34 | vmxnet3 35 | e1000 36 | boot_logger 37 | ) 38 | endif() 39 | 40 | os_add_stdout(tcp_perf_service default_stdout) 41 | os_add_plugins(tcp_perf_service autoconf) 42 | -------------------------------------------------------------------------------- /UDP_perf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | #service 7 | project (udpperf) 8 | 9 | #check if conan is already run outside of project 10 | if (NOT DEFINED CONAN_DEPENDENCIES) 11 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 12 | if (NOT HAS_CONAN) 13 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 14 | endif() 15 | endif() 16 | conan_basic_setup() 17 | 18 | include(os) 19 | 20 | set(SOURCES 21 | service.cpp # ...add more here 22 | ) 23 | 24 | os_add_executable(udp_service "UDP benchmark" ${SOURCES}) 25 | 26 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 27 | os_add_drivers(udp_service 28 | ip4_reassembly 29 | solo5net 30 | ) 31 | else() 32 | os_add_drivers(udp_service 33 | ip4_reassembly 34 | virtionet 35 | vmxnet3 36 | e1000 37 | boot_logger 38 | ) 39 | endif() 40 | 41 | os_add_stdout(udp_service default_stdout) 42 | os_add_plugins(udp_service autoconf) 43 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/stats.js: -------------------------------------------------------------------------------- 1 | function humanFileSize(bytes, si) { 2 | var thresh = si ? 1000 : 1024; 3 | if(Math.abs(bytes) < thresh) { 4 | return bytes + ' B'; 5 | } 6 | var units = si 7 | ? ['kB','MB','GB','TB','PB','EB','ZB','YB'] 8 | : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']; 9 | var u = -1; 10 | do { 11 | bytes /= thresh; 12 | ++u; 13 | } while(Math.abs(bytes) >= thresh && u < units.length - 1); 14 | return bytes.toFixed(1)+' '+units[u]; 15 | } 16 | 17 | (function poll(){ 18 | setTimeout(function(){ 19 | $.ajax({url: "/api/stats", success: function(data){ 20 | //console.log(data); 21 | $('#stats_recv').text(humanFileSize(data.DATA_RECV, true)); 22 | $('#stats_sent').text(humanFileSize(data.DATA_SENT, true)); 23 | $('#stats_req').text(data.REQ_RECV); 24 | $('#stats_res').text(data.RES_SENT); 25 | $('#stats_conn').text(data.NO_CONN); 26 | $('#stats_active').text(data.ACTIVE_CONN); 27 | $('#stats_mem').text(humanFileSize(data.MEM_USAGE, true)); 28 | 29 | poll(); 30 | }, dataType: "json"}); 31 | }, 1000); 32 | })(); 33 | -------------------------------------------------------------------------------- /STREAM/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | double mysecond() 22 | { 23 | return os::nanos_since_boot() / 1.0e9; 24 | } 25 | 26 | void Service::start() 27 | { 28 | //asm("cli"); 29 | // do the STREAM test here 30 | printf("Running STREAM benchmark\n"); 31 | extern int stream_main(); 32 | stream_main(); 33 | } 34 | -------------------------------------------------------------------------------- /LiveUpdate/server.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Master thesis 3 | * by Alf-Andre Walla 2016-2017 4 | * 5 | **/ 6 | #pragma once 7 | #include 8 | 9 | static inline 10 | void server(net::Inet& inet, 11 | const uint16_t port, 12 | delegate callback) 13 | { 14 | auto& server = inet.tcp().listen(port); 15 | server.on_connect( 16 | net::tcp::Connection::ConnectCallback::make_packed( 17 | [callback, port] (auto conn) 18 | { 19 | auto* buffer = new liu::buffer_t; 20 | buffer->reserve(3*1024*1024); 21 | printf("Receiving blob on port %u\n", port); 22 | 23 | // retrieve binary 24 | conn->on_read(9000, 25 | [conn, buffer] (auto buf) 26 | { 27 | buffer->insert(buffer->end(), buf->begin(), buf->end()); 28 | }) 29 | .on_disconnect( 30 | net::tcp::Connection::DisconnectCallback::make_packed( 31 | [buffer, callback] (auto conn, auto) { 32 | printf("* Blob size: %u b stored at %p\n", 33 | (uint32_t) buffer->size(), buffer->data()); 34 | callback(*buffer); 35 | delete buffer; 36 | conn->close(); 37 | })); 38 | })); 39 | } 40 | -------------------------------------------------------------------------------- /demo_service/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | project (demo_service) 7 | if (NOT DEFINED CONAN_DEPENDENCIES) 8 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 9 | if (NOT HAS_CONAN) 10 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 11 | endif() 12 | endif() 13 | conan_basic_setup() 14 | 15 | include(os) 16 | 17 | set(SOURCES 18 | service.cpp 19 | ) 20 | 21 | os_add_executable(demo "IncludeOS Demo Service" ${SOURCES}) 22 | 23 | # DRIVERS / PLUGINS: 24 | 25 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 26 | os_add_drivers(demo solo5net) 27 | else() 28 | os_add_drivers(demo 29 | virtionet # Virtio networking 30 | vmxnet3 31 | boot_logger # Display boot information 32 | # Use "boot --drivers ." to see other drivers 33 | # virtioblk # Virtio block device 34 | # ... Others from src/drivers 35 | ) 36 | endif() 37 | 38 | os_add_stdout(demo default_stdout) 39 | os_add_plugins(demo autoconf) 40 | -------------------------------------------------------------------------------- /TLS_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project (tls_server) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | 20 | include(os) 21 | 22 | set(SOURCES 23 | service.cpp http.cpp 24 | ) 25 | 26 | 27 | os_add_executable(tls_service "TLS server" ${SOURCES}) 28 | 29 | # DRIVERS / PLUGINS: 30 | 31 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 32 | os_add_drivers(tls_service solo5net) 33 | else() 34 | os_add_drivers(tls_service 35 | virtionet # Virtio networking 36 | vmxnet3 37 | ) 38 | endif() 39 | os_add_plugins(tls_service autoconf vfs) 40 | os_add_stdout(tls_service default_stdout) 41 | 42 | # Build memdisk content 43 | os_diskbuilder(tls_service drive) 44 | -------------------------------------------------------------------------------- /UDP_perf/README.md: -------------------------------------------------------------------------------- 1 | # IncludeOS UDP Performance 2 | Runs a udp server or a client as a [IncludeOS](https://github.com/includeos/includeos) unikernel 3 | 4 | ### Pre-requistes 5 | Requires `ncat` 6 | 7 | ## Build and run service 8 | 9 | ``` 10 | mkdir build 11 | cd build 12 | conan install .. -pr 13 | source activate.sh 14 | cmake .. 15 | cmake --build . 16 | ``` 17 | 18 | 19 | ### Howto run as a Server: 20 | 21 | ``` 22 | boot udp_service 23 | 24 | ``` 25 | 26 | To create and send a file, on another terminal run: `./send.sh` 27 | 28 | ### Howto run as a Client: 29 | 30 | To start the client on other terminal run: 31 | 32 | ``` 33 | boot udp_service client 34 | ``` 35 | 36 | To listen on port 1338 and dump received data to `recv.txt`, 37 | on another terminal run: `./receive.sh` 38 | 39 | 40 | ### Closing the service 41 | 42 | ``` 43 | source deactivate.sh 44 | ``` 45 | 46 | ### How sampling is done 47 | Sampling is collected approximately every 5 seconds when the unikernel is run as a server. 48 | Sampling is collected approximately every second when the unikernel is run as a client. The test runs for 10 seconds. 49 | -------------------------------------------------------------------------------- /microLB/server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | 3 | var stringToColour = function(str) { 4 | var hash = 0; 5 | for (var i = 0; i < str.length; i++) { 6 | hash = str.charCodeAt(i) + ((hash << 5) - hash); 7 | } 8 | var colour = '#'; 9 | for (var i = 0; i < 3; i++) { 10 | var value = (hash >> (i * 8)) & 0xFF; 11 | colour += ('00' + value.toString(16)).substr(-2); 12 | } 13 | return colour; 14 | } 15 | 16 | //We need a function which handles requests and send response 17 | function handleRequest(request, response){ 18 | response.setTimeout(500); 19 | var addr = request.connection.localPort; 20 | var bgcolor = stringToColour(addr + "42"); 21 | var body = '

'+ addr +'


' + 'Link established with IP ' + addr + ''; 22 | var page = "" + body + ""; 23 | response.end(page); 24 | } 25 | 26 | http.createServer(handleRequest).listen(6001, '10.0.0.1'); 27 | http.createServer(handleRequest).listen(6002, '10.0.0.1'); 28 | http.createServer(handleRequest).listen(6003, '10.0.0.1'); 29 | http.createServer(handleRequest).listen(6004, '10.0.0.1'); 30 | -------------------------------------------------------------------------------- /IRCd/ircd/modes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct mode_table_t 8 | { 9 | mode_table_t(const char* lut); 10 | 11 | bool is_mode(char c) { 12 | return LUT.find(c) != std::string::npos; 13 | } 14 | int char_to_bit(char c) { 15 | size_t bit = LUT.find(c); 16 | return (bit != std::string::npos) ? bit : -1; 17 | } 18 | char bit_to_char(uint16_t bit) { 19 | if (bit >= LUT.size()) { 20 | printf("Invalid mode bit %u\n", bit); 21 | assert(0); 22 | } 23 | return LUT[bit]; 24 | } 25 | 26 | const std::string& get() const { return LUT; } 27 | 28 | const std::string LUT; 29 | }; 30 | extern mode_table_t usermodes; 31 | extern mode_table_t chanmodes; 32 | 33 | 34 | #define UMODE_AWAY 'a' 35 | #define UMODE_INVIS 'i' 36 | #define UMODE_RESTRICT 'r' 37 | #define UMODE_IRCOP 'o' 38 | #define UMODE_LIRCOP 'O' 39 | #define UMODE_WALLOPS 'w' 40 | #define UMODE_SNOTICE 's' 41 | 42 | #define CMODE_NOEXTERN 'n' 43 | #define CMODE_TOPIC 't' 44 | 45 | extern uint16_t default_user_modes(); 46 | extern uint16_t default_channel_modes(); 47 | -------------------------------------------------------------------------------- /router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project(router_service C CXX) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | include(os) 20 | # Source files to be linked with OS library parts to form bootable image 21 | set(SOURCES 22 | service.cpp # ...add more here 23 | ) 24 | os_add_executable(router_service "IncludeOS Router Service" ${SOURCES}) 25 | 26 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 27 | set(DRIVERS 28 | solo5net 29 | ) 30 | else() 31 | set(DRIVERS 32 | virtionet # Virtio networking 33 | # virtioblock # Virtio block device 34 | # ... Others from src/drivers 35 | ) 36 | endif() 37 | 38 | os_add_drivers(router_service ${DRIVERS}) 39 | -------------------------------------------------------------------------------- /websocket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | # Service 7 | project (websocket) 8 | #check if conan is already run outside of project 9 | if (NOT DEFINED CONAN_DEPENDENCIES) 10 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 11 | if (NOT HAS_CONAN) 12 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 13 | endif() 14 | endif() 15 | conan_basic_setup() 16 | 17 | 18 | include(os) 19 | 20 | 21 | set(SOURCES 22 | service.cpp # ...add more here 23 | ) 24 | 25 | os_add_executable(websocket_service "WebSocket example" ${SOURCES}) 26 | 27 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 28 | os_add_drivers(websocket_service 29 | solo5net 30 | ) 31 | else() 32 | os_add_drivers(websocket_service 33 | virtionet 34 | vmxnet3 35 | e1000 36 | boot_logger 37 | ) 38 | endif() 39 | 40 | os_add_stdout(websocket_service default_stdout) 41 | os_add_plugins(websocket_service autoconf) 42 | 43 | os_diskbuilder(websocket_service disk) 44 | -------------------------------------------------------------------------------- /router/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2017 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | void Service::start() 23 | { 24 | auto& router = net::get_router(); 25 | 26 | auto& eth0 = net::Interfaces::get(0); 27 | auto& eth1 = net::Interfaces::get(1); 28 | 29 | eth0.set_forward_delg(router.forward_delg()); 30 | eth1.set_forward_delg(router.forward_delg()); 31 | } 32 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { label 'ubuntu-18.04' } 3 | triggers { upstream( upstreamProjects: 'IncludeOS/IncludeOS/master, IncludeOS/IncludeOS/dev', threshold: hudson.model.Result.SUCCESS ) } 4 | options { checkoutToSubdirectory('src') } 5 | environment { 6 | CONAN_USER_HOME = "${env.WORKSPACE}" 7 | PROFILE_x86_64 = 'clang-6.0-linux-x86_64' 8 | CPUS = """${sh(returnStdout: true, script: 'nproc')}""" 9 | SRC = "${env.WORKSPACE}/src" 10 | } 11 | 12 | stages { 13 | stage('Setup') { 14 | steps { 15 | sh script: "ls -A | grep -v src | xargs rm -r || :", label: "Clean workspace" 16 | sh script: "conan config install https://github.com/includeos/conan_config.git", label: "conan config install" 17 | } 18 | } 19 | stage('Build examples') { 20 | steps { 21 | dir('build_examples') { 22 | sh script: "conan install $SRC/acorn -pr $PROFILE_x86_64", label: "Trick to get environment set up" 23 | sh script: ". ./activate.sh; cmake $SRC -DCONAN_PROFILE=$PROFILE_x86_64", label: "Cmake" 24 | sh script: "make -j $CPUS", label: "Make" 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /IRCd/ircd/client_timeout.cpp: -------------------------------------------------------------------------------- 1 | #include "client.hpp" 2 | #include "ircd.hpp" 3 | #include 4 | 5 | // ping timeout QUIT message 6 | static const std::string reason( 7 | "Ping timeout: " + std::to_string(IrcServer::ping_timeout().count()) + " seconds"); 8 | 9 | void Client::handle_timeout() 10 | { 11 | assert(this->is_alive()); 12 | 13 | if (this->is_warned() == false) 14 | { 15 | // create and send ping request 16 | char pingreq[32]; 17 | int len = snprintf(pingreq, sizeof(pingreq), "PING :%ld\r\n", RTC::now()); 18 | this->send_raw(pingreq, len); 19 | // set warned 20 | this->set_warned(true); 21 | // registered clients get longer timeouts 22 | const auto d = this->is_reg() ? server.ping_timeout() : server.short_ping_timeout(); 23 | to_timer.restart(d, {this, &Client::handle_timeout}); 24 | } 25 | else { 26 | // kick client for being unresponsive 27 | this->kill(false, reason); 28 | } 29 | } 30 | 31 | void Client::restart_timeout() 32 | { 33 | if (this->is_warned()) { 34 | to_timer.restart(server.short_ping_timeout(), {this, &Client::handle_timeout}); 35 | } 36 | else { 37 | to_timer.restart(server.ping_timeout(), {this, &Client::handle_timeout}); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IRCd/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | # Human-readable name of your service 8 | set(SERVICE_NAME "Linux userspace IRC daemon") 9 | 10 | # Name of your service binary 11 | set(BINARY "linux_ircd") 12 | 13 | # Source files to be linked with OS library parts to form bootable image 14 | set(SOURCES 15 | ../service.cpp 16 | ../autoconf.cpp 17 | ../ircd/channel.cpp 18 | ../ircd/client.cpp 19 | ../ircd/client_commands.cpp 20 | ../ircd/client_new.cpp 21 | ../ircd/client_send.cpp 22 | ../ircd/client_timeout.cpp 23 | ../ircd/ircd.cpp 24 | ../ircd/ircsplit.cpp 25 | ../ircd/modes.cpp 26 | ../ircd/readq.cpp 27 | ../ircd/restore.cpp 28 | ../ircd/selftest.cpp 29 | ../ircd/server.cpp 30 | ../ircd/server_commands.cpp 31 | ../ircd/test.cpp 32 | ../ircd/transform.cpp 33 | ) 34 | 35 | #set(PLUGINS autoconf) 36 | 37 | # Custom version string of the IRC server 38 | set(VERSION "v0.3 IRCd") 39 | add_definitions(-DIRC_SERVER_VERSION="${VERSION}") 40 | 41 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 42 | -------------------------------------------------------------------------------- /microLB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | 7 | #service 8 | project (microLB) 9 | 10 | #check if conan is already run outside of project 11 | if (NOT DEFINED CONAN_DEPENDENCIES) 12 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 13 | if (NOT HAS_CONAN) 14 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 15 | endif() 16 | endif() 17 | conan_basic_setup() 18 | 19 | 20 | include(os) 21 | 22 | set(SOURCES 23 | service.cpp 24 | ) 25 | 26 | os_add_executable(microlb_example "microLB Service" ${SOURCES}) 27 | 28 | # DRIVERS / PLUGINS: 29 | 30 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 31 | os_add_drivers(microlb_example solo5net) 32 | else() 33 | os_add_drivers(microlb_example 34 | virtionet # Virtio networking 35 | vmxnet3 36 | boot_logger # Display boot information 37 | # Use "boot --drivers ." to see other drivers 38 | # virtioblk # Virtio block device 39 | # ... Others from src/drivers 40 | ) 41 | endif() 42 | 43 | os_add_stdout(microlb_example default_stdout) 44 | #os_add_os_library(microlb liveupdate) 45 | #os_add_os_library(microlb microlb) 46 | os_add_plugins(microlb_example autoconf) 47 | -------------------------------------------------------------------------------- /snake/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "snake.hpp" 23 | 24 | void begin_snake() 25 | { 26 | static Snake snake {TextmodeVGA::get()}; 27 | 28 | hw::KBM::set_virtualkey_handler( 29 | [] (int key, bool pressed) 30 | { 31 | snake.user_update(Snake::Direction(key)); 32 | 33 | if (key == hw::KBM::VK_SPACE && snake.finished()) 34 | snake.reset(); 35 | }); 36 | } 37 | 38 | void Service::start(const std::string&) 39 | { 40 | // We have to start snake later to avoid some text output 41 | begin_snake(); 42 | } 43 | -------------------------------------------------------------------------------- /IRCd/autoconf.cpp: -------------------------------------------------------------------------------- 1 | #include "ircd/ircd.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | std::unique_ptr IrcServer::from_config() 7 | { 8 | rapidjson::Document doc; 9 | doc.Parse(Config::get().data()); 10 | 11 | if (doc.IsObject() == false || doc.HasMember("ircd") == false) 12 | throw std::runtime_error("Missing or invalid configuration"); 13 | 14 | const auto& obj = doc["ircd"]; 15 | 16 | // client interface 17 | const int CLIENT_NET = obj["client_iface"].GetInt(); 18 | auto& clinet = net::Interfaces::get(CLIENT_NET); 19 | const int CLIENT_PORT = obj["client_port"].GetUint(); 20 | assert(CLIENT_PORT > 0 && CLIENT_PORT < 65536); 21 | // server interface 22 | const int SERVER_NET = obj["server_iface"].GetInt(); 23 | auto& srvinet = net::Interfaces::get(SERVER_NET); 24 | const int SERVER_PORT = obj["server_port"].GetUint(); 25 | assert(SERVER_PORT > 0 && SERVER_PORT < 65536); 26 | 27 | // unique server ID 28 | const int server_id = obj["server_id"].GetInt(); 29 | // server name 30 | const std::string server_name = obj["server_name"].GetString(); 31 | // server network name 32 | const std::string server_netw = obj["server_netw"].GetString(); 33 | 34 | return std::unique_ptr{new IrcServer( 35 | clinet, CLIENT_PORT, srvinet, SERVER_PORT, 36 | server_id, server_name, server_netw)}; 37 | } 38 | -------------------------------------------------------------------------------- /acorn/app/acorn: -------------------------------------------------------------------------------- 1 | // -*-C++-*- 2 | // This file is a part of the IncludeOS unikernel - www.includeos.org 3 | // 4 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 5 | // and Alfred Bratterud 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | 19 | #ifndef ACORN_WEB_APPLIANCE 20 | #define ACORN_WEB_APPLIANCE 21 | 22 | #include "models/user.hpp" 23 | #include "models/squirrel.hpp" 24 | 25 | #include "routes/routes" 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include "../fs/acorn_fs.hpp" 32 | 33 | #include 34 | 35 | // Middleware 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include 42 | 43 | #endif //< ACORN_WEB_APPLIANCE 44 | -------------------------------------------------------------------------------- /acorn/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1.2) 2 | 3 | #Avoid cmake from test compiling to host 4 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 5 | 6 | #service 7 | project (acorn) 8 | if (NOT DEFINED CONAN_DEPENDENCIES) 9 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 10 | if (NOT HAS_CONAN) 11 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 12 | endif() 13 | endif() 14 | 15 | conan_basic_setup() 16 | 17 | include(os) 18 | include(dependencies.cmake) 19 | 20 | set(SOURCES 21 | service.cpp fs/acorn_fs.cpp 22 | ) 23 | 24 | os_add_config(acorn "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 25 | 26 | os_add_executable(acorn "Acorn Web Appliance" ${SOURCES}) 27 | 28 | #TODO conanify bucket ? 29 | os_include_directories(acorn PRIVATE "app/" ${BUCKET_DIR}) 30 | 31 | 32 | # Make sure bucket is downloaded before service is built 33 | os_add_dependencies(acorn bucket) 34 | 35 | # DRIVERS / PLUGINS: 36 | 37 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 38 | os_add_drivers(acorn solo5net) 39 | else() 40 | os_add_drivers(acorn 41 | virtionet # Virtio networking 42 | vmxnet3 43 | ) 44 | endif() 45 | os_add_plugins(acorn autoconf) 46 | os_add_stdout(acorn default_stdout) 47 | 48 | #imported from the conanfile.txt 49 | #os_add_os_library(acorn mana) 50 | 51 | # Build memdisk content 52 | os_diskbuilder(acorn disk1) 53 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var app = angular.module('acornWebApp', [ 4 | 'ngRoute', 5 | 'ngResource', 6 | 'toastr', 7 | 'ngCookies' 8 | ]) 9 | .config(function($routeProvider, $locationProvider) { 10 | $routeProvider 11 | .when('/app/', { 12 | templateUrl: "app/views/home.html", 13 | controller: "HomeCtrl" 14 | }) 15 | .when('/app/squirrels', { 16 | templateUrl: "app/views/squirrels.html", 17 | controller: "SquirrelCtrl" 18 | }) 19 | .when('/app/dashboard', { 20 | templateUrl: "app/views/dashboard.html", 21 | controller: "DashboardCtrl" 22 | }) 23 | .otherwise({ 24 | templateUrl: "app/views/404.html" 25 | }); 26 | 27 | $locationProvider.html5Mode(true); 28 | }); 29 | 30 | app.filter('bytes', function() { 31 | return function(bytes, precision) { 32 | if (bytes === 0) { return '0 bytes' } 33 | if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-'; 34 | if (typeof precision === 'undefined') precision = 1; 35 | 36 | var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], 37 | number = Math.floor(Math.log(bytes) / Math.log(1024)), 38 | val = (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision); 39 | 40 | return (val.match(/\.0*$/) ? val.substr(0, val.indexOf('.')) : val) + ' ' + units[number]; 41 | } 42 | }).filter('secondsToDateTime', function($filter) { 43 | return function(seconds) { 44 | return new Date(0, 0, 0).setSeconds(seconds); 45 | }; 46 | }); 47 | -------------------------------------------------------------------------------- /LiveUpdate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | option(REAL_HW "Run on real hardware" OFF) 4 | option(LIVEUPDATE "Enable liveupdate" OFF) 5 | 6 | #Avoid cmake from test compiling to host 7 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 8 | 9 | #service 10 | project (liuircd) 11 | 12 | if (NOT DEFINED CONAN_DEPENDENCIES) 13 | include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL RESULT_VARIABLE HAS_CONAN) 14 | if (NOT HAS_CONAN) 15 | message(FATAL_ERROR "missing conanbuildinfo.cmake did you forget to run conan install ?") 16 | endif() 17 | endif() 18 | conan_basic_setup() 19 | 20 | include(os) 21 | 22 | if(TARGET ircd) 23 | message(STATUS "ircd is already defined") 24 | else() 25 | add_subdirectory(../IRCd/ircd ircd) 26 | endif() 27 | 28 | 29 | set(DRIVERS 30 | vmxnet3 31 | ) 32 | 33 | set(STDOUT 34 | default_stdout 35 | ) 36 | 37 | include_directories( 38 | ${CMAKE_CURRENT_BINARY_DIR} 39 | ../IRCd/ircd 40 | ) 41 | 42 | SET(SRCS 43 | service.cpp 44 | ../IRCd/autoconf.cpp 45 | ) 46 | 47 | add_custom_command( 48 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/motd.h 49 | COMMAND xxd -i < ${CMAKE_CURRENT_SOURCE_DIR}/ircd.motd > ${CMAKE_CURRENT_BINARY_DIR}/motd.h 50 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ircd.motd 51 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 52 | ) 53 | 54 | os_add_executable(LiveUpdate_example "IRC service" ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/motd.h) 55 | 56 | os_add_drivers(LiveUpdate_example ${DRIVERS}) 57 | os_add_stdout(LiveUpdate_example ${STDOUT}) 58 | 59 | os_link_libraries(LiveUpdate_example ircd) 60 | -------------------------------------------------------------------------------- /IRCd/ircd/readq.cpp: -------------------------------------------------------------------------------- 1 | #include "readq.hpp" 2 | #include "common.hpp" 3 | #include 4 | 5 | bool ReadQ::read(uint8_t* buf, size_t len, on_read_func on_read) 6 | { 7 | while (len > 0) { 8 | 9 | int search = -1; 10 | 11 | // find line ending 12 | for (size_t i = 0; i < len; i++) 13 | if (buf[i] == 13 || buf[i] == 10) { 14 | search = i; break; 15 | } 16 | 17 | // not found: 18 | if (UNLIKELY(search == -1)) 19 | { 20 | // if clients are sending too much data to server, kill them 21 | if (UNLIKELY(buffer.size() + len >= READQ_MAX)) { 22 | return false; 23 | } 24 | // append entire buffer 25 | this->buffer.append((const char*) buf, len); 26 | break; 27 | } 28 | else if (UNLIKELY(search == 0)) { 29 | buf++; len--; 30 | } else { 31 | 32 | // found CR LF: 33 | // if clients are sending too much data to server, kill them 34 | if (UNLIKELY(buffer.size() + search >= READQ_MAX)) { 35 | return false; 36 | } 37 | // append to clients buffer 38 | this->buffer.append((const char*) buf, search); 39 | 40 | // move forward in socket buffer 41 | buf += search; 42 | // decrease len 43 | len -= search; 44 | 45 | // parse message 46 | if (!buffer.empty()) 47 | { 48 | on_read(this->buffer); 49 | this->buffer.clear(); 50 | } 51 | 52 | // skip over continous line ending characters 53 | if (len != 0 && (buf[0] == 13 || buf[0] == 10)) { 54 | buf++; len--; 55 | } 56 | } 57 | } 58 | return true; 59 | } 60 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/views/squirrels.html: -------------------------------------------------------------------------------- 1 |
2 | 5 | 6 |
7 |
8 |
9 | 10 |
11 | 12 |
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 |
22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
KeyNameAgeOccupationCaptured
{{ squirrel.key }}{{ squirrel.name }}{{ squirrel.age }}{{ squirrel.occupation }}{{ squirrel.created_at | date: 'yyyy-MM-dd HH:mm' }}
44 |
45 | 46 |
47 | -------------------------------------------------------------------------------- /syslog/syslog_example.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | /* ------------------------- POSIX syslog on lubuntu ------------------------- */ 6 | 7 | int invalid_priority = -1; 8 | syslog(invalid_priority, "Invalid %d", invalid_priority); 9 | 10 | invalid_priority = 10; 11 | syslog(invalid_priority, "Invalid %d", invalid_priority); 12 | 13 | invalid_priority = 55; 14 | syslog(invalid_priority, "Invalid %d", invalid_priority); 15 | 16 | syslog(LOG_INFO, "(Info) No open has been called prior to this"); 17 | syslog(LOG_NOTICE, "(Notice) Program created with two arguments: %s and %s", "one", "two"); 18 | 19 | openlog("Prepended message", LOG_CONS | LOG_NDELAY, LOG_MAIL); 20 | 21 | syslog(LOG_ERR, "(Err) Log after prepended message with one argument: %d", 44); 22 | syslog(LOG_WARNING, "(Warning) Log number two after openlog set prepended message"); 23 | 24 | closelog(); 25 | 26 | syslog(LOG_WARNING, "(Warning) Log after closelog with three arguments. One is %u, another is %s, a third is %d", 33, "this", 4011); 27 | 28 | openlog("Second prepended message", LOG_PID | LOG_CONS, LOG_USER); 29 | 30 | syslog(LOG_EMERG, "This is a test of an emergency log. You might need to stop the program manually."); 31 | syslog(LOG_ALERT, "Alert log with the m argument: %m"); 32 | 33 | closelog(); 34 | 35 | syslog(LOG_CRIT, "Critical after cleared prepended message (closelog has been called)"); 36 | 37 | closelog(); 38 | 39 | openlog("Open after close prepended message", LOG_CONS, LOG_MAIL); 40 | 41 | syslog(LOG_INFO, "Info after openlog with both m: %m and two hex arguments: 0x%x and 0x%x", 100, 50); 42 | 43 | closelog(); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /LiveUpdate/liu.hpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #pragma once 19 | #include 20 | #include "server.hpp" 21 | 22 | void setup_liveupdate_server(net::Inet& inet, 23 | const uint16_t PORT, 24 | liu::LiveUpdate::storage_func func) 25 | { 26 | static liu::LiveUpdate::storage_func save_function; 27 | save_function = func; 28 | 29 | // listen for live updates 30 | server(inet, PORT, 31 | [] (liu::buffer_t& buffer) 32 | { 33 | printf("* Live updating from %p (len=%u)\n", 34 | buffer.data(), (uint32_t) buffer.size()); 35 | try 36 | { 37 | // run live update process 38 | liu::LiveUpdate::exec(buffer, "test", save_function); 39 | } 40 | catch (std::exception& err) 41 | { 42 | liu::LiveUpdate::restore_environment(); 43 | printf("Live update failed:\n%s\n", err.what()); 44 | throw; 45 | } 46 | }); 47 | } 48 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | if (NOT CMAKE_BUILD_TYPE) 4 | set(CMAKE_BUILD_TYPE Release) 5 | endif() 6 | 7 | set(EXAMPLES 8 | 256_color_vga 9 | acorn 10 | demo_service 11 | http_client 12 | IRCd 13 | LiveUpdate 14 | microLB 15 | router 16 | scoped_profiler 17 | snake 18 | starlight 19 | STREAM 20 | syslog 21 | tcp 22 | TCP_perf 23 | TLS_server 24 | transfer 25 | UDP_perf 26 | #TODO 27 | #userspace_demo 28 | vlan 29 | websocket 30 | ) 31 | if (PROTOBUF) 32 | list(APPEND EXAMPLES protobuf) 33 | endif() 34 | 35 | if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") 36 | message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") 37 | file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.13/conan.cmake" 38 | "${CMAKE_BINARY_DIR}/conan.cmake") 39 | endif() 40 | 41 | include(${CMAKE_BINARY_DIR}/conan.cmake) 42 | 43 | if (CONAN_PROFILE) 44 | set(CONANPROFILE PROFILE ${CONAN_PROFILE}) 45 | endif() 46 | 47 | foreach(example ${EXAMPLES}) 48 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${example}/conanfile.txt) 49 | set(OLD_DIR ${CMAKE_CURRENT_BINARY_DIR}) 50 | set(CMAKE_CURRENT_BINARY_DIR ${OLD_DIR}/${example}) 51 | file(MAKE_DIRECTORY ${OLD_DIR}/${example}) 52 | #clear any old libs from last pass.. this is a ugly hack 53 | set(CONAN_LIBS "") 54 | conan_cmake_run( 55 | CONANFILE ${example}/conanfile.txt 56 | ${CONANPROFILE} 57 | ) 58 | set(CMAKE_CURRENT_BINARY_DIR ${OLD_DIR}) 59 | endif() 60 | #we cant add the subdir unless conan install is already run 61 | #because the CMakeLists.txt needs coanbuildinfo.cmake which is needed to find os.cmake 62 | add_subdirectory(${example} ${example}) 63 | endforeach() 64 | -------------------------------------------------------------------------------- /syslog/README.md: -------------------------------------------------------------------------------- 1 | # Syslog IncludeOS Plugin Service 2 | 3 | Sending syslog data over UDP port 6514. The message format corresponds to the format specified in RFC5424. 4 | 5 | The default behavior for IncludeOS's syslog implementation is to send the data to printf, which again can be routed anywhere the service specifies. This is intentional since logging over a UDP/UNIX socket wouldn't necessarily work as one might think in IncludeOS, and there's unnecessary overhead using UDP if all you want is simple logging. Instead we provide an optional plugin for sending standard syslog over UDP to an external network interface. 6 | 7 | * To enable the UDP syslog plugin, simply `set(PLUGINS .., syslogd,..)` in CMakeLists.txt or turn on the libsyslogd cmake option. This will override the default. 8 | 9 | # Compatibility with Linux: 10 | This example intends to show how the POSIX syslog interface works the same way in both Linux and IncludeOS. The CMake build creates an IncludeOS bootable image which inlcudes the program `syslog_example.c`. Service::start` in `service.cpp` calls `main` in `syslog_example.c`. The syslog example can also be built and run umodified under Linux: 11 | * `$ make -f Makefile_linux` 12 | Run locally by calling 13 | * `$ ./syslog_linux` 14 | 15 | NOTE: The example will send various types of log messages, including `LOG_ALERT`, `LOG_EMERG` etc. Also note that the IncludeOS service will transmit UDP packets to a remote IP specified by the user. The user is in charge of pointing this IP to a valid syslog server. 16 | 17 | ### Build and run service 18 | 19 | ``` 20 | mkdir build 21 | cd build 22 | conan install .. -pr 23 | source activate.sh 24 | cmake .. 25 | cmake --build . 26 | boot syslog_plugin_example 27 | source deactivate.sh 28 | ``` 29 | -------------------------------------------------------------------------------- /syslog/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | /* For Posix */ 22 | #include 23 | 24 | /* For IncludeOS */ 25 | // #include 26 | 27 | extern "C" int main(); 28 | 29 | void Service::start(const std::string&) 30 | { 31 | // DHCP on interface 0 32 | auto& inet = net::Interfaces::get(0); 33 | inet.negotiate_dhcp(10.0); 34 | // static IP in case DHCP fails 35 | inet.network_config({ 10, 0, 0, 45 }, // IP 36 | { 255, 255, 0, 0 }, // Netmask 37 | { 10, 0, 0, 1 }, // Gateway 38 | { 10, 0, 0, 1} ); // DNS 39 | 40 | 41 | // For now we have to specify the remote syslogd IP 42 | // FIXME: instructions here 43 | 44 | // Starts the python integration test: 45 | printf("Service IP address is %s\n", inet.ip_addr().str().c_str()); 46 | 47 | /* ------------------------- POSIX syslog in IncludeOS ------------------------- */ 48 | main(); 49 | } 50 | -------------------------------------------------------------------------------- /TLS_server/http.cpp: -------------------------------------------------------------------------------- 1 | #include // rand() 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std::chrono; 7 | 8 | std::string HTML_RESPONSE() 9 | { 10 | const int color = rand(); 11 | 12 | // Generate some HTML 13 | std::stringstream stream; 14 | stream << "" 15 | << "" 17 | << "IncludeOS Demo Service" 18 | << "

" 20 | << "IncludeOS

" 21 | << "

The C++ Unikernel

" 22 | << "

You have successfully booted an IncludeOS TCP service with simple https. " 23 | << "For a more sophisticated example, take a look at " 24 | << "Acorn.

" 25 | << "

© 2017 IncludeOS
"; 26 | 27 | return stream.str(); 28 | } 29 | 30 | http::Response_ptr handle_request(const http::Request& req) 31 | { 32 | auto res = http::make_response(); 33 | auto& header = res->header(); 34 | 35 | header.set_field(http::header::Server, "IncludeOS/0.12"); 36 | 37 | // GET / 38 | if(req.method() == http::GET && req.uri().to_string() == "/") 39 | { 40 | // add HTML response 41 | res->add_body(HTML_RESPONSE()); 42 | 43 | // set Content type and length 44 | header.set_field(http::header::Content_Type, "text/html; charset=UTF-8"); 45 | header.set_field(http::header::Content_Length, std::to_string(res->body().size())); 46 | } 47 | else 48 | { 49 | // Generate 404 response 50 | res->set_status_code(http::Not_Found); 51 | } 52 | 53 | header.set_field(http::header::Connection, "close"); 54 | return res; 55 | } 56 | -------------------------------------------------------------------------------- /TLS_server/drive/test.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFXTCCA0WgAwIBAgIJAMKoGEJAbpuNMA0GCSqGSIb3DQEBDQUAMEUxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQwHhcNMTcwMzA5MTM0NTI2WhcNMjcwMzA3MTM0NTI2WjBF 5 | MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 6 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 7 | CgKCAgEAszXcDz3rlOfT4mgkqpJmhWEA1oSmXJl+ODWgAM5ozVLzXvbvAxJovjG5 8 | mRmDJOb0zRpD6xjOcWVSrOLqyr7YKFhDK2N7hWMmKKjTaWl640uWogWMdomQ1nQ2 9 | wdLKyzoepYhY35GVWzDb2oLwG/zVfC+mwVrQOeDZgOQtFanwd9HURipuwld8IC8h 10 | 4JgcB2i99VZGoQXExhRQlcNUGUzUaExDoQMG/+K7e2DmZDzjsmsAnOgeDVGd2CeA 11 | u8WydLenL+HP04qH6bVgxETVdhQ5GXYfSS1ZyRkLavCM/QftLYYCo/ibJ3mK9OCr 12 | EPiKfBM6as3qgTRVp83IqPIgURcVJPRLEAW0i8SpsXvqA56M558NRJ06I4PIT7xH 13 | A7TvR6wD8GH2u7W4+c5AaQwTxX2C4Gbtg/wESEwlSzgfruHGaNIyI4nF97m1hF7x 14 | VbcHXBpvjFK2+6gzBTNJ8isNJL4XFaGR1x1Gm03NYQhkFVGiOaOGF6VEL9uXIbSz 15 | XaHBDePz7nvPZXYytYo93H8AdM/nkoQ5PTOx/6a/SOwgtSjMZAG6TohGI/1H6zvm 16 | 5ToF33O7B+nDkd5bSO/YNsVuDN5NYDwNuBw2i7dVKTWb4E1IcvTAI3rKY1DDd1y9 17 | VpyYZSQvsnWatjKiVwANnbYNitNM0zSvPDufKzvSGq4JraHlK0kCAwEAAaNQME4w 18 | HQYDVR0OBBYEFAHh+il41QCAviLPiUnybxnw8vDCMB8GA1UdIwQYMBaAFAHh+il4 19 | 1QCAviLPiUnybxnw8vDCMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQENBQADggIB 20 | AIG9NyK5uD5A11VI6gHC8cmfnVszHuaLpuc2y7jyVCyZOt38a0YmKGTUD/u+JKUc 21 | C01uREEi/tqJsm1yE9/kxMMlCGSW9/2kKbbkgU9LdVyVQxr4yVA2aHOf6GDfEioT 22 | O1WXPITZyjBUF5N/t6+LCyClF+0CsDnzWkZkIXEiY5W4Nlqctq1Ef4wMzvCVQ5t6 23 | RUX8UpxZuraENjtiZlFP8HjQER7/QK+eQl+tI56snAnyU2AcABcUegP1/IphMCDL 24 | iAAGkqBu1wndeeIwUtT9LHuVGWVGEsr1Zpq0NJuVmU5E0i1VRl7whBJQw+PMqFde 25 | 6CwI/pMyuZEgh+tXVx8VakI4eSJX8TRPaLeMSI+Sr3CfZxm7Zu6YUEXSLgMrwRqY 26 | atx0oGL8lnYTxlozG+Zmdytge8OwwgtBgBHlmiqbko3ePvlSZTw3gx7tpFBByzX9 27 | TbgiVKA9P+j5lhdxScls8WjUkr2wXJBXv9WPIK0pUP4UzLJQltamo9lOUJiPgzf9 28 | v8yPfI4clt4YpRAZw/h1wjhHSYYLmtF6Y8K50NgiFAMuXq5G7q9SlAISt+9oGojA 29 | 80MLVkzin8zNuAvGGKnJ72vggKIqIqpdNUyWFH4yuhOtorN+Xam8uPb3axKjVkeP 30 | x2tytEIsJgJY/xggNU1h8myeo8EJLwgXeEVQWMOiE2jI 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /LiveUpdate/tls/drive/test.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFXTCCA0WgAwIBAgIJAMKoGEJAbpuNMA0GCSqGSIb3DQEBDQUAMEUxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQwHhcNMTcwMzA5MTM0NTI2WhcNMjcwMzA3MTM0NTI2WjBF 5 | MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 6 | ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 7 | CgKCAgEAszXcDz3rlOfT4mgkqpJmhWEA1oSmXJl+ODWgAM5ozVLzXvbvAxJovjG5 8 | mRmDJOb0zRpD6xjOcWVSrOLqyr7YKFhDK2N7hWMmKKjTaWl640uWogWMdomQ1nQ2 9 | wdLKyzoepYhY35GVWzDb2oLwG/zVfC+mwVrQOeDZgOQtFanwd9HURipuwld8IC8h 10 | 4JgcB2i99VZGoQXExhRQlcNUGUzUaExDoQMG/+K7e2DmZDzjsmsAnOgeDVGd2CeA 11 | u8WydLenL+HP04qH6bVgxETVdhQ5GXYfSS1ZyRkLavCM/QftLYYCo/ibJ3mK9OCr 12 | EPiKfBM6as3qgTRVp83IqPIgURcVJPRLEAW0i8SpsXvqA56M558NRJ06I4PIT7xH 13 | A7TvR6wD8GH2u7W4+c5AaQwTxX2C4Gbtg/wESEwlSzgfruHGaNIyI4nF97m1hF7x 14 | VbcHXBpvjFK2+6gzBTNJ8isNJL4XFaGR1x1Gm03NYQhkFVGiOaOGF6VEL9uXIbSz 15 | XaHBDePz7nvPZXYytYo93H8AdM/nkoQ5PTOx/6a/SOwgtSjMZAG6TohGI/1H6zvm 16 | 5ToF33O7B+nDkd5bSO/YNsVuDN5NYDwNuBw2i7dVKTWb4E1IcvTAI3rKY1DDd1y9 17 | VpyYZSQvsnWatjKiVwANnbYNitNM0zSvPDufKzvSGq4JraHlK0kCAwEAAaNQME4w 18 | HQYDVR0OBBYEFAHh+il41QCAviLPiUnybxnw8vDCMB8GA1UdIwQYMBaAFAHh+il4 19 | 1QCAviLPiUnybxnw8vDCMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQENBQADggIB 20 | AIG9NyK5uD5A11VI6gHC8cmfnVszHuaLpuc2y7jyVCyZOt38a0YmKGTUD/u+JKUc 21 | C01uREEi/tqJsm1yE9/kxMMlCGSW9/2kKbbkgU9LdVyVQxr4yVA2aHOf6GDfEioT 22 | O1WXPITZyjBUF5N/t6+LCyClF+0CsDnzWkZkIXEiY5W4Nlqctq1Ef4wMzvCVQ5t6 23 | RUX8UpxZuraENjtiZlFP8HjQER7/QK+eQl+tI56snAnyU2AcABcUegP1/IphMCDL 24 | iAAGkqBu1wndeeIwUtT9LHuVGWVGEsr1Zpq0NJuVmU5E0i1VRl7whBJQw+PMqFde 25 | 6CwI/pMyuZEgh+tXVx8VakI4eSJX8TRPaLeMSI+Sr3CfZxm7Zu6YUEXSLgMrwRqY 26 | atx0oGL8lnYTxlozG+Zmdytge8OwwgtBgBHlmiqbko3ePvlSZTw3gx7tpFBByzX9 27 | TbgiVKA9P+j5lhdxScls8WjUkr2wXJBXv9WPIK0pUP4UzLJQltamo9lOUJiPgzf9 28 | v8yPfI4clt4YpRAZw/h1wjhHSYYLmtF6Y8K50NgiFAMuXq5G7q9SlAISt+9oGojA 29 | 80MLVkzin8zNuAvGGKnJ72vggKIqIqpdNUyWFH4yuhOtorN+Xam8uPb3axKjVkeP 30 | x2tytEIsJgJY/xggNU1h8myeo8EJLwgXeEVQWMOiE2jI 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/views/home_no.html: -------------------------------------------------------------------------------- 1 | 29 | 30 |
31 | 34 |

Sjekk ut det vi har jobbet med!

35 |
36 |
37 | 38 |
39 |
40 | Squirrel has escaped! 41 |

Rest API

42 |

43 | Her kan du finne vår ekorn-samling - avdekket som JSON fra Acorn. 44 |

45 | Se, et ekorn! » 46 |
47 |
48 | 49 |
50 |
51 | A stack of books 52 |

Filsystem

53 |

54 | Sjekk ut innholdet til memdisken vår. Her presenterer vi en katalog med bøker fra filsystemet vårt. 55 |

56 | Les en bok » 57 |
58 |
59 | 60 |
61 |
62 |
63 | 64 | -------------------------------------------------------------------------------- /websocket/disk/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | IncludeOS WebSocket Example 4 | 5 | 72 | 73 |

74 | IncludeOS 75 |

76 |
77 |

WebSocket Echo

78 | 79 | 80 | 81 | 82 |
83 | -------------------------------------------------------------------------------- /IRCd/ircd/ircsplit.cpp: -------------------------------------------------------------------------------- 1 | #include "ircsplit.hpp" 2 | 3 | std::vector 4 | ircsplit(const std::string& text, std::string& source) 5 | { 6 | std::vector retv; 7 | size_t x = 0; 8 | size_t p = 0; 9 | // ignore empty messages 10 | if (text.empty()) return retv; 11 | // check for source 12 | if (text[0] == ':') 13 | { 14 | // if the input is ":" or too short 15 | if (text.size() < 3) return retv; 16 | x = text.find(' ', 1); 17 | // early return for source-only msg 18 | if (x == std::string::npos) return retv; 19 | source = text.substr(x); 20 | p = x+1; 21 | } 22 | // parse remainder 23 | do 24 | { 25 | x = text.find(' ', p+1); 26 | size_t y = text.find(':', x+1); // find last param 27 | 28 | if (x != std::string::npos && y == x+1) 29 | { 30 | // single argument 31 | retv.emplace_back(&text[p], x-p); 32 | // ending text argument 33 | retv.emplace_back(&text[y+1], text.size() - (y+1)); 34 | break; 35 | } 36 | else if (x != std::string::npos) 37 | { 38 | // single argument 39 | retv.emplace_back(&text[p], x-p); 40 | } 41 | else { 42 | // last argument 43 | retv.emplace_back(&text[p], text.size()-p); 44 | } 45 | p = x+1; 46 | 47 | } while (x != std::string::npos); 48 | 49 | return retv; 50 | } 51 | 52 | std::vector 53 | ircsplit(const std::string& text) 54 | { 55 | std::vector retv; 56 | size_t x = 0; 57 | size_t p = 0; 58 | // ignore empty messages 59 | if (text.empty()) return retv; 60 | // parse remainder 61 | do 62 | { 63 | x = text.find(' ', p+1); 64 | size_t y = text.find(':', x+1); // find last param 65 | 66 | if (x != std::string::npos && y == x+1) 67 | { 68 | // single argument 69 | retv.emplace_back(&text[p], x-p); 70 | // ending text argument 71 | retv.emplace_back(&text[y+1], text.size() - (y+1)); 72 | break; 73 | } 74 | else if (x != std::string::npos) 75 | { 76 | // single argument 77 | retv.emplace_back(&text[p], x-p); 78 | } 79 | else { 80 | // last argument 81 | retv.emplace_back(&text[p], text.size()-p); 82 | } 83 | p = x+1; 84 | 85 | } while (x != std::string::npos); 86 | 87 | return retv; 88 | } 89 | -------------------------------------------------------------------------------- /acorn/fs/acorn_fs.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include "acorn_fs.hpp" 19 | 20 | namespace acorn { 21 | 22 | static size_t dir_count; 23 | static size_t file_count; 24 | 25 | static void 26 | recursive_fs_dump(const std::vector& entries, const int depth = 1) 27 | { 28 | const int indent = (depth * 3); 29 | 30 | for (auto&& entry : entries) { 31 | if (entry.is_dir()) { 32 | if (entry.name() not_eq "." and entry.name() not_eq "..") { 33 | ++dir_count; 34 | printf("%*c-[ %s ]\n", indent, '+', entry.name().c_str()); 35 | entry.ls( 36 | [depth] (auto, auto entries) { 37 | recursive_fs_dump(*entries, (depth + 1)); 38 | }); 39 | } else { 40 | printf("%*c %s\n", indent, '+', entry.name().c_str()); 41 | } 42 | } else { 43 | printf("%*c-> %s\n", indent, '+', entry.name().c_str()); 44 | ++file_count; 45 | } 46 | } 47 | 48 | } 49 | 50 | void list_static_content(const fs::File_system& fs) 51 | { 52 | printf("%s\n", 53 | "================================================================================\n" 54 | "STATIC CONTENT LISTING\n" 55 | "================================================================================\n"); 56 | dir_count = 0; 57 | file_count = 0; 58 | recursive_fs_dump(*fs.ls("/").entries); 59 | printf("\n%u %s, %u %s\n", dir_count, "directories", file_count, "files"); 60 | printf("%s", 61 | "================================================================================\n"); 62 | } 63 | 64 | } //< namespace acorn 65 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/js/services/cpusage.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('acornWebApp') 4 | .factory('CPUsage', function() { 5 | // CPU usage chart 6 | var time_data = ['x', new Date()]; 7 | var idle_data = ['idle']; 8 | var active_data = ['active']; 9 | 10 | var cpu_usage_chart = {}; 11 | 12 | var setup = function(html_id) { 13 | cpu_usage_chart = c3.generate({ 14 | bindto: html_id, 15 | padding: { 16 | right: 40, 17 | top: 40 18 | }, 19 | data: { 20 | x: 'x', 21 | columns: [ 22 | time_data, 23 | idle_data, 24 | active_data 25 | ], 26 | colors: { 27 | idle: '#3A8BF1', 28 | active: '#F87E0C' 29 | }, 30 | types: { 31 | idle: 'area', 32 | active: 'area' 33 | }, 34 | area : { 35 | zerobased: true 36 | } 37 | }, 38 | axis: { 39 | x: { 40 | type: 'timeseries', 41 | tick: { 42 | format: '%H:%M:%S' 43 | }, 44 | label: { 45 | position: 'outer-left', 46 | padding: { 47 | top: 100, 48 | left: 100 49 | } 50 | } 51 | }, 52 | y: { 53 | label: { 54 | text: 'percent', 55 | position: 'outer-middle' 56 | }, 57 | tick: { 58 | format: function (d) { 59 | return d + " %"; 60 | } 61 | } 62 | } 63 | } 64 | }); 65 | }; 66 | 67 | function CPUsage(html_id) { 68 | setup(html_id); 69 | }; 70 | 71 | CPUsage.prototype.update = function(usage) { 72 | 73 | if(idle_data.length > 20) { 74 | // Remove second element in each array (first element is name) 75 | time_data.splice(1, 1); 76 | idle_data.splice(1, 1); 77 | active_data.splice(1, 1); 78 | } 79 | 80 | time_data.push(new Date()); 81 | idle_data.push(usage.idle.toFixed(3)); 82 | active_data.push(usage.active.toFixed(3)); 83 | 84 | cpu_usage_chart.axis.labels({x: 'CPU usage over time'}); 85 | cpu_usage_chart.load({ 86 | columns: [ 87 | time_data, 88 | idle_data, 89 | active_data 90 | ] 91 | }); 92 | } 93 | 94 | return CPUsage; 95 | }); 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Demo-examples 2 | 3 | Here you will find a number of [IncludeOS](https://github.com/includeos/IncludeOS) demo examples. 4 | The examples demonstrate various features of IncludeOS. The examples 5 | are also built and started with conan. 6 | 7 | Each example folder contains: 8 | - `README.md`: Instructions on how to build/start the example 9 | - `CMakeLists.txt`: Build requirements 10 | - `config.json`: Network configurations required for the example 11 | - `service.cpp` : the `c++` example service 12 | - `conanfile.txt`: the library/tool dependencies the example requires 13 | - `vm.json`: some examples may have a `vm.json` if it requires some virtual configuration. 14 | 15 | 16 | ## Dependencies 17 | To build and start the examples, ensure the following dependencies are installed on your system. 18 | - conan 19 | - cmake 20 | - git 21 | - clang or gcc 22 | - python3 23 | 24 | > Note that, you may require some other dependencies based on the example you are trying. 25 | 26 | ### Making sure you have the right conan settings 27 | 28 | __Install profiles and IncludeOS remotes__ 29 | 30 | ``` 31 | $ conan config install https://github.com/includeos/conan_config.git 32 | ``` 33 | 34 | __Add the bincrafters remote__ 35 | 36 | ``` 37 | $ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan 38 | ``` 39 | 40 | __Verify remotes__ 41 | 42 | ``` 43 | $ conan remote list 44 | includeos: https://api.bintray.com/conan/includeos/includeos [Verify SSL: True] 45 | bincrafters: https://api.bintray.com/conan/bincrafters/public-conan [Verify SSL: True] 46 | ``` 47 | # Building the Examples 48 | 49 | You can choose between building all the examples together and then use `boot` to run the service you want 50 | to check out or you can build the one example you are 51 | interested in and run that service. Below are instructions for both. 52 | 53 | ### Building and running a single example 54 | To build and run a single example, go into one of the examples and do; 55 | 56 | ```bash 57 | cd 58 | mkdir build 59 | cd build 60 | conan install .. -pr clang-6.0-linux-x86_64 61 | source activate.sh 62 | cmake .. 63 | cmake --build . 64 | boot (service_name) 65 | source deactivate.sh 66 | ``` 67 | 68 | 69 | ### Building all the examples 70 | Create a build folder and do 71 | 72 | ```bash 73 | export CC=clang 74 | export CXX=clang 75 | mkdir build_all 76 | cd build_all 77 | cmake -DCONAN_PROFILE=clang-6.0-linux-x86_64 -DPROTOBUF=ON 78 | ``` 79 | -------------------------------------------------------------------------------- /acorn/disk1/public/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 16px; 3 | } 4 | 5 | .programming { 6 | font-family: Monospace; 7 | } 8 | 9 | .panel-default > .panel-heading { 10 | /*background-color: #A061F2 !important;*/ 11 | background-image: linear-gradient(to bottom,#3A8BF1 0,#3A8BF1 100%); 12 | } 13 | 14 | .panel-default > .panel-heading > .panel-title { 15 | color:#fff !important; 16 | } 17 | 18 | .panel-default { 19 | border-color: #3A8BF1 !important; 20 | } 21 | 22 | [data-toggle="collapse"] { 23 | cursor:pointer; 24 | } 25 | 26 | .vertical-max { 27 | max-height: 350px; 28 | overflow: auto; 29 | } 30 | 31 | .table-responsive { 32 | -webkit-overflow-scrolling: touch; 33 | } 34 | 35 | section { 36 | padding-bottom:50px; 37 | } 38 | 39 | /* List view Statman tree view START */ 40 | 41 | .gap-0 { 42 | padding-left: 1em; 43 | } 44 | 45 | .gap-1 { 46 | padding-left: 3em; 47 | } 48 | 49 | .gap-2 { 50 | padding-left: 6em; 51 | } 52 | 53 | .parent { 54 | padding-right: 1em; 55 | padding-top: 1em; 56 | padding-bottom: 1em; 57 | font-weight: bold; 58 | background-color: #d9d9d9; 59 | } 60 | 61 | .second-parent { 62 | background-color: #eee; 63 | } 64 | 65 | .just-padding { 66 | padding: 15px; 67 | } 68 | 69 | .list-group.list-group-root { 70 | padding: 0; 71 | overflow: hidden; 72 | } 73 | 74 | .list-group.list-group-root .list-group { 75 | margin-bottom: 0; 76 | } 77 | 78 | .list-group.list-group-root .list-group-item { 79 | border-radius: 0; 80 | border-width: 1px 0 0 0; 81 | } 82 | 83 | .list-group.list-group-root > .list-group-item:first-child { 84 | border-top-width: 0; 85 | } 86 | 87 | .list-group.list-group-root > .list-group > .list-group-item { 88 | padding-left: 30px; 89 | } 90 | 91 | .list-group.list-group-root > .list-group > .list-group > .list-group-item { 92 | padding-left: 45px; 93 | } 94 | 95 | /* List view Statman tree view END */ 96 | 97 | /* ------------------------ Index.html ------------------------ */ 98 | 99 | #header { 100 | padding-top: 1em; 101 | } 102 | 103 | #logo-header { 104 | height: 60px; 105 | } 106 | 107 | #jumbo-acorn { 108 | padding-bottom: 0.5em; 109 | } 110 | 111 | .static-link { 112 | padding-top: 3em; 113 | padding-bottom: 3em; 114 | font-size: 1em; 115 | } 116 | 117 | .space-above { 118 | padding-top: 1em; 119 | } 120 | 121 | #logo-footer { 122 | height: 40px; 123 | } 124 | 125 | #footer { 126 | padding-bottom: 1em; 127 | } 128 | -------------------------------------------------------------------------------- /scoped_profiler/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | using namespace std::chrono; 25 | 26 | std::string create_html_response(const std::string& message) 27 | { 28 | return "HTTP/1.1 200 OK\n" 29 | "Date: Mon, 01 Jan 1970 00:00:01 GMT\n" 30 | "Server: IncludeOS prototype 4.0\n" 31 | "Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT\n" 32 | "Content-Type: text/html; charset=UTF-8\n" 33 | "Content-Length: " + std::to_string(message.size()) + "\n" 34 | "Accept-Ranges: bytes\n" 35 | "Connection: close\n" 36 | "\n" 37 | + message; 38 | } 39 | 40 | void Service::start() 41 | { 42 | // DHCP on interface 0 43 | auto& inet = net::Interfaces::get(0); 44 | 45 | // Set up a TCP server on port 80 46 | auto& server = inet.tcp().listen(80); 47 | 48 | server.on_connect([](auto conn) 49 | { 50 | conn->on_read(1024, [conn](net::tcp::buffer_t buf) 51 | { 52 | std::string data(reinterpret_cast(buf->data()), buf->size()); 53 | if (data.find("GET /profile ") != std::string::npos) 54 | { 55 | auto profile_statistics = ScopedProfiler::get_statistics(); 56 | auto response = create_html_response(profile_statistics + "\n"); 57 | conn->write(response.data(), response.size()); 58 | } 59 | else 60 | { 61 | auto response = create_html_response("Hello\n"); 62 | conn->write(response.data(), response.size()); 63 | } 64 | }); 65 | 66 | conn->on_disconnect([](auto conn, auto reason) 67 | { 68 | (void)reason; // Not used 69 | conn->close(); 70 | }); 71 | }); 72 | 73 | printf("*** TEST SERVICE STARTED ***\n"); 74 | } 75 | -------------------------------------------------------------------------------- /IRCd/ircd/server.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "common.hpp" 5 | #include "readq.hpp" 6 | #include 7 | 8 | class IrcServer; 9 | 10 | class Server 11 | { 12 | public: 13 | using Connection = net::tcp::Connection_ptr; 14 | Server(sindex_t, IrcServer&); 15 | 16 | // incoming 17 | void connect(Connection conn); 18 | // outgoing 19 | void connect(Connection conn, std::string name, std::string pass); 20 | 21 | bool is_alive() const noexcept { 22 | return regis & 1; 23 | } 24 | bool is_regged() const noexcept { 25 | return (regis & 7) == 7; 26 | } 27 | sindex_t get_id() const noexcept { 28 | return this->self; 29 | } 30 | // fast b64 assuming max 26 servers 31 | char token() const noexcept { 32 | return 'A' + token_; 33 | } 34 | uint8_t server_id() const noexcept { 35 | return token_; 36 | } 37 | char nl_token() const noexcept { 38 | return 'A' + near_link_; 39 | } 40 | uint8_t near_link() const noexcept { 41 | return near_link_; 42 | } 43 | bool is_local() const noexcept { 44 | return hops_ == 0; 45 | } 46 | uint8_t hop_count() const noexcept { 47 | return hops_; 48 | } 49 | long boot_ts() const noexcept { 50 | return boot_time_; 51 | } 52 | long link_ts() const noexcept { 53 | return link_time_; 54 | } 55 | 56 | const std::string& name() const noexcept { 57 | return sname; 58 | } 59 | const std::string& get_desc() const noexcept { 60 | return sdesc; 61 | } 62 | const std::string& get_pass() const noexcept { 63 | return spass; 64 | } 65 | 66 | IrcServer& get_server() noexcept { 67 | return server; 68 | } 69 | 70 | void send(const std::string&); 71 | void send(const char*, size_t); 72 | 73 | void split_message(const std::string&); 74 | 75 | void squit(const std::string& reason); 76 | 77 | const std::string& name_hash() const noexcept { 78 | return sname; 79 | } 80 | 81 | static void init(); 82 | private: 83 | void setup_dg(); 84 | void handle_commands(const std::vector&); 85 | void handle_unknown(const std::vector&); 86 | void try_auth(); 87 | 88 | sindex_t self; 89 | uint8_t regis; 90 | uint8_t token_; // this servers numeric 91 | uint8_t near_link_; // server numeric facing us 92 | uint8_t hops_; 93 | long boot_time_; 94 | long link_time_; 95 | 96 | IrcServer& server; 97 | Connection conn; 98 | 99 | std::string sname; 100 | std::string spass; 101 | std::string sdesc; 102 | 103 | std::list remote_links; 104 | 105 | ReadQ readq; 106 | }; 107 | -------------------------------------------------------------------------------- /acorn/app/routes/users.hpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #ifndef ROUTES_USERS_HPP 19 | #define ROUTES_USERS_HPP 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace acorn { 26 | namespace routes { 27 | 28 | class Users : public mana::Router { 29 | 30 | using UserBucket = bucket::Bucket; 31 | 32 | public: 33 | 34 | Users(std::shared_ptr users) 35 | { 36 | // GET / 37 | on_get("/", 38 | [users] (auto, auto res) 39 | { 40 | printf("[Users@GET:/] Responding with content inside UserBucket\n"); 41 | using namespace rapidjson; 42 | StringBuffer sb; 43 | Writer writer(sb); 44 | users->serialize(writer); 45 | res->send_json(sb.GetString()); 46 | }); 47 | 48 | // GET /:id(Digit)/:name/something/:something[Letters] 49 | on_get("/:id(\\d+)/:name/something/:something([a-z]+)", 50 | [users] (mana::Request_ptr req, auto res) 51 | { 52 | // Get parameters: 53 | // Alt.: std::string id = req->params().get("id"); 54 | auto& params = req->params(); 55 | std::string id = params.get("id"); 56 | std::string name = params.get("name"); 57 | std::string something = params.get("something"); 58 | 59 | // std::string doesntexist = params.get("doesntexist"); // throws ParamException 60 | 61 | printf("id: %s\n", id.c_str()); 62 | printf("name: %s\n", name.c_str()); 63 | printf("something: %s\n", something.c_str()); 64 | 65 | printf("[Users@GET:/:id(\\d+)/:name/something/:something([a-z]+)] Responding with content inside UserBucket\n"); 66 | using namespace rapidjson; 67 | StringBuffer sb; 68 | Writer writer(sb); 69 | users->serialize(writer); 70 | res->send_json(sb.GetString()); 71 | }); 72 | 73 | 74 | } 75 | }; 76 | 77 | } // < namespace routes 78 | } // < namespace acorn 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/views/home.html: -------------------------------------------------------------------------------- 1 | 29 | 30 |
31 | 34 |

Check out what we've been working on!

35 |
36 |
37 | 38 |
39 |
40 | 41 | Squirrel has escaped! 42 | 43 |

Rest API

44 |

45 | Here you can find our collections of Squirrels - exposed as JSON from Acorn. 46 |

47 | Look, a squirrel! » 48 |
49 |
50 | 51 |
52 |
53 | 54 | A stack of books 55 | 56 |

Filesystem

57 |

58 | Check out the content inside our memdisk. Here we're displaying a directory with books from our filesystem. 59 |

60 | Read a book » 61 |
62 |
63 | 64 |
65 |
66 | 67 | A engine 68 | 69 |

Dashboard

70 |

71 | Wroom wroom 72 |

73 | » 74 |
75 |
76 | 77 |
78 |
79 |
80 | 81 | -------------------------------------------------------------------------------- /IRCd/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import socket 3 | import sys 4 | import random 5 | from inspect import getmodule 6 | from multiprocessing import Pool 7 | 8 | 9 | def async(decorated): 10 | r'''Wraps a top-level function around an asynchronous dispatcher. 11 | 12 | when the decorated function is called, a task is submitted to a 13 | process pool, and a future object is returned, providing access to an 14 | eventual return value. 15 | 16 | The future object has a blocking get() method to access the task 17 | result: it will return immediately if the job is already done, or block 18 | until it completes. 19 | 20 | This decorator won't work on methods, due to limitations in Python's 21 | pickling machinery (in principle methods could be made pickleable, but 22 | good luck on that). 23 | ''' 24 | # Keeps the original function visible from the module global namespace, 25 | # under a name consistent to its __name__ attribute. This is necessary for 26 | # the multiprocessing pickling machinery to work properly. 27 | module = getmodule(decorated) 28 | decorated.__name__ += '_original' 29 | setattr(module, decorated.__name__, decorated) 30 | 31 | def send(*args, **opts): 32 | return async.pool.apply_async(decorated, args, opts) 33 | 34 | return send 35 | 36 | def botname(): 37 | return "bot" + str(int(random.random() * 10000)) 38 | 39 | class Bot: 40 | def __init__(self): 41 | # Create a TCP/IP socket 42 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 43 | self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 44 | self.name = botname() 45 | 46 | def send(self, data): 47 | try: 48 | self.sock.sendall(data + "\r\n") 49 | finally: 50 | return 51 | 52 | def begin(self): 53 | # Connect the socket to the port on the server given by the caller 54 | try: 55 | self.sock.connect(('10.0.0.42', 6667)) 56 | try: 57 | self.send("NICK " + self.name) 58 | self.send("USER 1 2 3 :444") 59 | 60 | self.send("JOIN #test") 61 | 62 | amount_received = 0 63 | amount_expected = 10 64 | while amount_received < amount_expected: 65 | data = self.sock.recv(64) 66 | amount_received += len(data) 67 | 'print >>sys.stderr, received "%s"' % data 68 | 69 | self.send("PRIVMSG #test :spamerino cappuchino etc") 70 | self.send("QUIT :Lates") 71 | finally: 72 | self.sock.close() 73 | finally: 74 | return 75 | 76 | 77 | if __name__ == '__main__': 78 | while True: 79 | bot = Bot() 80 | try: 81 | bot.begin() 82 | finally: 83 | '' 84 | -------------------------------------------------------------------------------- /IRCd/ircd/client_new.cpp: -------------------------------------------------------------------------------- 1 | #include "client.hpp" 2 | #include "ircd.hpp" 3 | #include "tokens.hpp" 4 | #include "modes.hpp" 5 | #include 6 | 7 | inline void Client::need_parms(const std::string& cmd) 8 | { 9 | send(ERR_NEEDMOREPARAMS, cmd + " :Not enough parameters"); 10 | } 11 | 12 | void Client::handle_new(const std::vector& msg) 13 | { 14 | #ifndef USERSPACE_LINUX 15 | volatile ScopedProfiler profile; 16 | #endif 17 | const std::string& cmd = msg[0]; 18 | 19 | if (cmd == TK_CAP) 20 | { 21 | // ignored completely 22 | } 23 | else if (cmd == TK_PASS) 24 | { 25 | if (msg.size() > 1) 26 | { 27 | // ignore passwords for now 28 | //this->passw = msg[1]; 29 | } 30 | else 31 | need_parms(cmd); 32 | } 33 | else if (cmd == TK_NICK) 34 | { 35 | if (msg.size() > 1) 36 | { 37 | // try to acquire nickname 38 | if (change_nick(msg[1])) { 39 | welcome(2); 40 | } 41 | } 42 | else 43 | need_parms(cmd); 44 | } 45 | else if (cmd == TK_USER) 46 | { 47 | if (msg.size() > 1) 48 | { 49 | this->user_ = msg[1]; 50 | welcome(4); 51 | } 52 | else 53 | need_parms(cmd); 54 | } 55 | else 56 | { 57 | send(ERR_NOSUCHCMD, cmd + " :Unknown command"); 58 | } 59 | } 60 | 61 | void Client::auth_notice() 62 | { 63 | static const char auth_proc[] = 64 | "NOTICE AUTH :*** Processing your connection\r\n"; 65 | static const char auth_host[] = 66 | "NOTICE AUTH :*** Looking up your hostname...\r\n"; 67 | static const char auth_idnt[] = 68 | "NOTICE AUTH :*** Checking Ident\r\n"; 69 | send_raw(auth_proc, sizeof auth_proc - 1); 70 | send_raw(auth_host, sizeof auth_host - 1); 71 | send_raw(auth_idnt, sizeof auth_idnt - 1); 72 | //hostname_lookup() 73 | this->host_ = conn->remote().address().to_string(); 74 | //ident_check() 75 | } 76 | void Client::welcome(uint8_t newreg) 77 | { 78 | bool regged = is_reg(); 79 | regis |= newreg; 80 | // not registered before, but registered now 81 | if (!regged && is_reg()) 82 | { 83 | // statistics 84 | server.new_registered_client(); 85 | // welcoming messages 86 | send(RPL_WELCOME, ":Welcome to the Internet Relay Network, " + nickuserhost()); 87 | send(RPL_YOURHOST, ":Your host is " + server.name() + ", running " IRC_SERVER_VERSION); 88 | send(RPL_CREATED, ":This server was created " + server.created()); 89 | send(RPL_MYINFO, server.name() + " " + server.version() + " " + usermodes.get()); 90 | send(RPL_CAPABS, "CHANTYPES=&# EXCEPTS PREFIX=(ov)@+ CHANMODES=eIb,k,l,imnpstu :are supported by this server"); 91 | send(RPL_CAPABS, "NETWORK=" + server.network() + " NICKLEN=" + std::to_string(server.nick_maxlen()) + " CHANNELLEN=" + std::to_string(server.chan_maxlen()) + " :are supported by this server"); 92 | send_motd(); 93 | send_lusers(); 94 | send_modes(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /TLS_server/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #define BENCHMARK_MODE 24 | static const bool ENABLE_TLS = false; 25 | static const bool USE_BOTAN_TLS = false; 26 | 27 | static http::Server* server = nullptr; 28 | extern http::Response_ptr handle_request(const http::Request&); 29 | 30 | void Service::start() 31 | { 32 | fs::memdisk().init_fs( 33 | [] (auto err, auto&) { 34 | assert(!err); 35 | }); 36 | // Auto-configured from config.json 37 | auto& inet = net::Interfaces::get(0); 38 | 39 | #ifndef BENCHMARK_MODE 40 | // Print some useful TCP stats every 30 secs 41 | Timers::periodic(5s, 30s, 42 | [&inet] (uint32_t) { 43 | printf(" TCP STATUS:\n%s\n", inet.tcp().status().c_str()); 44 | }); 45 | #endif 46 | 47 | if (USE_BOTAN_TLS) { 48 | auto& filesys = fs::memdisk().fs(); 49 | auto ca_cert = filesys.stat("/test.pem"); 50 | auto ca_key = filesys.stat("/test.key"); 51 | auto srv_key = filesys.stat("/server.key"); 52 | 53 | server = new http::Botan_server( 54 | "blabla", ca_key, ca_cert, srv_key, inet.tcp()); 55 | printf("Using Botan for HTTPS transport\n"); 56 | } 57 | else if (ENABLE_TLS) { 58 | server = new http::OpenSSL_server( 59 | "/test.pem", "/test.key", inet.tcp()); 60 | printf("Using OpenSSL for HTTPS transport\n"); 61 | } 62 | else { 63 | server = new http::Server(inet.tcp()); 64 | } 65 | 66 | server->on_request( 67 | [] (auto request, auto response_writer) { 68 | response_writer->set_response(handle_request(*request)); 69 | response_writer->write(); 70 | }); 71 | 72 | if (ENABLE_TLS) 73 | // listen on default HTTPS port 74 | server->listen(443); 75 | else 76 | server->listen(80); 77 | } 78 | 79 | #ifdef BENCHMARK_MODE 80 | #include 81 | static void print_heap_info() 82 | { 83 | const std::string heapinfo = HeapDiag::to_string(); 84 | printf("%s\n", heapinfo.c_str()); 85 | //StackSampler::print(10); 86 | } 87 | 88 | void Service::ready() 89 | { 90 | using namespace std::chrono; 91 | Timers::periodic(1s, [] (int) { 92 | //print_heap_info(); 93 | }); 94 | 95 | StackSampler::begin(); 96 | } 97 | #endif 98 | -------------------------------------------------------------------------------- /IRCd/ircd/perf_array.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.hpp" 3 | #include "ciless.hpp" 4 | #include 5 | 6 | class IrcServer; 7 | 8 | template 9 | struct perf_array 10 | { 11 | using typevec = std::deque; 12 | using iterator = typename typevec::iterator; 13 | using const_iterator = typename typevec::const_iterator; 14 | 15 | // generate new id 16 | T& create(IrcServer&); 17 | // create and hash 18 | T& create(IrcServer&, const std::string& name); 19 | // force-create empty element 20 | T& create_empty(IrcServer&); 21 | 22 | T& get(IDX idx) { 23 | return tvec.at(idx); 24 | } 25 | 26 | IDX find(const std::string&) const; 27 | 28 | bool empty() const noexcept { 29 | return tvec.empty(); 30 | } 31 | size_t size() const noexcept { 32 | return tvec.size(); 33 | } 34 | 35 | void free(T& object); 36 | 37 | // T iterators 38 | auto begin() { 39 | return tvec.begin(); 40 | } 41 | auto begin() const { 42 | return tvec.cbegin(); 43 | } 44 | auto end() { 45 | return tvec.end(); 46 | } 47 | auto end() const { 48 | return tvec.cend(); 49 | } 50 | 51 | // hash map 52 | auto& hash_map() noexcept { 53 | return h_map; 54 | } 55 | void hash(const std::string& value, IDX idx) 56 | { 57 | h_map[value] = idx; 58 | } 59 | void emplace_hash(std::string value, IDX idx) 60 | { 61 | h_map.emplace(std::move(value), idx); 62 | } 63 | void erase_hash(const std::string& value) 64 | { 65 | h_map.erase(value); 66 | } 67 | 68 | private: 69 | typevec tvec; 70 | std::vector free_idx; 71 | std::map h_map; 72 | }; 73 | 74 | template 75 | T& perf_array::create(IrcServer& srv) 76 | { 77 | // use prev idx 78 | if (free_idx.empty() == false) { 79 | IDX idx = free_idx.back(); 80 | free_idx.pop_back(); 81 | return tvec[idx]; 82 | } 83 | // create new value 84 | tvec.emplace_back(tvec.size(), srv); 85 | return tvec.back(); 86 | } 87 | template 88 | T& perf_array::create(IrcServer& srv, const std::string& name) 89 | { 90 | auto& type = create(srv); 91 | this->hash(name, type.get_id()); 92 | return type; 93 | } 94 | template 95 | T& perf_array::create_empty(IrcServer& srv) 96 | { 97 | tvec.emplace_back(tvec.size(), srv); 98 | return tvec.back(); 99 | } 100 | 101 | template 102 | IDX perf_array::find(const std::string& name) const 103 | { 104 | auto it = h_map.find(name); 105 | if (it != h_map.end()) return it->second; 106 | return (IDX) -1; 107 | } 108 | 109 | template 110 | void perf_array::free(T& type) 111 | { 112 | // give back id 113 | free_idx.push_back(type.get_id()); 114 | // give back name, if it has been given one 115 | if (!type.name_hash().empty()) 116 | erase_hash(type.name_hash()); 117 | } 118 | -------------------------------------------------------------------------------- /acorn/app/routes/languages.hpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #ifndef ROUTES_LANGUAGES_HPP 19 | #define ROUTES_LANGUAGES_HPP 20 | #include 21 | #include 22 | 23 | namespace acorn { 24 | namespace routes { 25 | 26 | class Languages : public mana::Router { 27 | public: 28 | 29 | Languages() 30 | { 31 | on_get("/english", [](auto req, auto res) { 32 | Languages::lang_handler(req, res, "en-US"); 33 | }); 34 | 35 | on_get("/norwegian", [](auto req, auto res) { 36 | Languages::lang_handler(req, res, "nb-NO"); 37 | }); 38 | 39 | on_get("/clear", [](auto req, auto res) { 40 | Languages::clear(req, res); 41 | }); 42 | } 43 | 44 | private: 45 | 46 | static void lang_handler(mana::Request_ptr req, mana::Response_ptr res, const std::string& lang) { 47 | using namespace mana; 48 | 49 | if (req->has_attribute()) { 50 | auto req_cookies = req->get_attribute(); 51 | 52 | { // Print all the request-cookies 53 | const auto& all_cookies = req_cookies->get_cookies(); 54 | for (const auto& c : all_cookies) { 55 | printf("Cookie: %s=%s\n", c.first.c_str(), c.second.c_str()); 56 | } 57 | } 58 | 59 | const auto& value = req_cookies->cookie_value("lang"); 60 | 61 | if (value == "") { 62 | printf("%s\n", "Cookie with name 'lang' not found! Creating it."); 63 | res->cookie(http::Cookie{"lang", lang}); 64 | } else if (value not_eq lang) { 65 | printf("%s\n", "Cookie with name 'lang' found, but with wrong value. Updating cookie."); 66 | res->update_cookie("lang", lang); 67 | } else { 68 | printf("%s%s%s\n", "Wanted cookie already exists (name 'lang' and value '", lang.c_str(), "')!"); 69 | } 70 | 71 | } else { 72 | printf("%s\n", "Request has no cookies! Creating cookie."); 73 | res->cookie(http::Cookie{"lang", lang}); 74 | } 75 | 76 | res->send(true); 77 | } 78 | 79 | static void clear(mana::Request_ptr, mana::Response_ptr res) { 80 | printf("Clearing cookie!\n"); 81 | res->clear_cookie("lang"); 82 | res->send(true); 83 | } 84 | }; 85 | 86 | } // < namespace routes 87 | } // < namespace acorn 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /IRCd/fill.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import socket 3 | import sys 4 | import random 5 | from inspect import getmodule 6 | from multiprocessing import Pool 7 | import time 8 | 9 | 10 | def async(decorated): 11 | r'''Wraps a top-level function around an asynchronous dispatcher. 12 | 13 | when the decorated function is called, a task is submitted to a 14 | process pool, and a future object is returned, providing access to an 15 | eventual return value. 16 | 17 | The future object has a blocking get() method to access the task 18 | result: it will return immediately if the job is already done, or block 19 | until it completes. 20 | 21 | This decorator won't work on methods, due to limitations in Python's 22 | pickling machinery (in principle methods could be made pickleable, but 23 | good luck on that). 24 | ''' 25 | # Keeps the original function visible from the module global namespace, 26 | # under a name consistent to its __name__ attribute. This is necessary for 27 | # the multiprocessing pickling machinery to work properly. 28 | module = getmodule(decorated) 29 | decorated.__name__ += '_original' 30 | setattr(module, decorated.__name__, decorated) 31 | 32 | def send(*args, **opts): 33 | return async.pool.apply_async(decorated, args, opts) 34 | 35 | return send 36 | 37 | def botname(): 38 | return "bot" + str(int(random.random() * 90000)) 39 | 40 | class Bot: 41 | def __init__(self): 42 | # Create a TCP/IP socket 43 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 44 | self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 45 | self.name = botname() 46 | 47 | def send(self, data): 48 | try: 49 | self.sock.sendall(data + "\r\n") 50 | finally: 51 | return 52 | 53 | def begin(self): 54 | # Connect the socket to the port on the server given by the caller 55 | try: 56 | self.sock.connect(('10.0.0.42', 6667)) 57 | try: 58 | self.send("NICK " + self.name) 59 | self.send("USER 1 2 3 :444") 60 | 61 | self.send("JOIN #test") 62 | 63 | finally: 64 | 'fff' 65 | finally: 66 | return 67 | 68 | def retrieve(self): 69 | try: 70 | amount_received = 0 71 | amount_expected = 10 72 | while amount_received < amount_expected: 73 | data = self.sock.recv(64) 74 | amount_received += len(data) 75 | #print >>sys.stderr, received "%s"' % data 76 | #self.send("PRIVMSG #test :spamerino cappuchino etc") 77 | 78 | #self.send("QUIT :Lates") 79 | finally: 80 | 'fff' 81 | 82 | def theend(self): 83 | try: 84 | self.sock.close() 85 | finally: 86 | 'fff' 87 | 88 | if __name__ == '__main__': 89 | botlist = [] 90 | for i in range(200): 91 | bot = Bot() 92 | try: 93 | bot.begin() 94 | finally: 95 | botlist.append(bot) 96 | for cl in botlist: 97 | cl.retrieve() 98 | time.sleep(16) 99 | -------------------------------------------------------------------------------- /acorn/app/models/user.hpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | // User med en key (tilsvarer cookie-id) 19 | // 20 | // Brukeridentifisering 21 | // 22 | // Starte med: 23 | // Sette en favorittdyr = hest: kommer opp hest på siden 24 | 25 | // Se squirrel.hpp 26 | 27 | #pragma once 28 | #ifndef MODEL_USER_HPP 29 | #define MODEL_USER_HPP 30 | 31 | //#include 32 | //#include 33 | 34 | #include 35 | 36 | namespace acorn { 37 | 38 | /** 39 | * 40 | */ 41 | struct User : mana::Serializable { 42 | size_t key; 43 | 44 | /** 45 | * 46 | */ 47 | User() : key{0} {} 48 | 49 | // More constructors here 50 | 51 | /** 52 | * 53 | */ 54 | std::string json() const; 55 | 56 | /** 57 | * 58 | */ 59 | virtual void serialize(rapidjson::Writer&) const override; 60 | 61 | /** 62 | * 63 | */ 64 | virtual bool deserialize(const rapidjson::Document&) override; 65 | 66 | /** 67 | * 68 | */ 69 | bool is_equal(const User&) const; 70 | 71 | /** 72 | * 73 | */ 74 | static bool is_equal(const User&, const User&); 75 | 76 | }; 77 | 78 | /**--v----------- Implementation Details -----------v--**/ 79 | 80 | inline void User::serialize(rapidjson::Writer& writer) const { 81 | writer.StartObject(); 82 | 83 | writer.Key("key"); 84 | writer.Uint(key); 85 | 86 | // Write more variables here 87 | 88 | writer.EndObject(); 89 | } 90 | 91 | inline bool User::deserialize(const rapidjson::Document& doc) { 92 | key = doc["key"].GetUint(); 93 | 94 | // set more variables here 95 | 96 | return true; 97 | } 98 | 99 | inline std::string User::json() const { 100 | using namespace rapidjson; 101 | StringBuffer sb; 102 | Writer writer(sb); 103 | serialize(writer); 104 | return sb.GetString(); 105 | } 106 | 107 | inline bool User::is_equal(const User& u) const { 108 | return key == u.key; 109 | } 110 | 111 | inline bool User::is_equal(const User& u1, const User& u2) { 112 | return u1.is_equal(u2); 113 | } 114 | 115 | inline std::ostream& operator << (std::ostream& output_device, const User& u) { 116 | return output_device << u.json(); 117 | } 118 | 119 | /**--^----------- Implementation Details -----------^--**/ 120 | 121 | } //< namespace acorn 122 | 123 | #endif //< MODEL_USER_HPP 124 | -------------------------------------------------------------------------------- /websocket/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2017 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | void handle_ws(net::WebSocket_ptr ws) 23 | { 24 | static std::map websockets; 25 | static int idx = 0; 26 | 27 | // nullptr means the WS attempt failed 28 | if(not ws) { 29 | printf("WS failed\n"); 30 | return; 31 | } 32 | printf("WS Connected: %s\n", ws->to_string().c_str()); 33 | 34 | // Write a welcome message 35 | ws->write("Welcome"); 36 | ws->write(ws->to_string()); 37 | // Setup echo reply 38 | ws->on_read = [ws = ws.get()] (auto msg) { 39 | printf("WS Recv: %s\n", msg->to_string().c_str()); 40 | // Extracting the data from the message is performant 41 | ws->write(msg->to_string()); 42 | }; 43 | ws->on_close = [ws = ws.get()](auto code) { 44 | // Notify on close 45 | printf("WS Closing (%u) %s\n", code, ws->to_string().c_str()); 46 | }; 47 | 48 | websockets[idx++] = std::move(ws); 49 | } 50 | 51 | #include 52 | #include 53 | std::unique_ptr server; 54 | 55 | void Service::start() 56 | { 57 | // Retreive the stack (configured from outside) 58 | auto& inet = net::Interfaces::get(0); 59 | Expects(inet.is_configured()); 60 | 61 | // Init the memdisk 62 | auto& disk = fs::memdisk(); 63 | disk.init_fs([] (auto err, auto&) { 64 | Expects(not err); 65 | }); 66 | // Retreive the HTML page from the disk 67 | auto file = disk.fs().read_file("/index.html"); 68 | Expects(file.is_valid()); 69 | auto html = file.get(); 70 | 71 | // Create a HTTP Server and setup request handling 72 | server = std::make_unique(inet.tcp()); 73 | server->on_request([html] (auto req, auto rw) 74 | { 75 | // We only support get 76 | if(req->method() != http::GET) { 77 | rw->write_header(http::Not_Found); 78 | return; 79 | } 80 | // Serve HTML on / 81 | if(req->uri() == "/") { 82 | rw->write(html); 83 | } 84 | // WebSockets go here 85 | else if(req->uri() == "/ws") { 86 | auto ws = net::WebSocket::upgrade(*req, *rw); 87 | handle_ws(std::move(ws)); 88 | } 89 | else { 90 | rw->write_header(http::Not_Found); 91 | } 92 | }); 93 | 94 | // Start listening on port 80 95 | server->listen(80); 96 | printf("WebSocket is available on ws://%s:80/ws\n", 97 | inet.ip_addr().to_string().c_str()); 98 | } 99 | -------------------------------------------------------------------------------- /starlight/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | using namespace std::chrono; 27 | 28 | static uint8_t backbuffer[320*200] __attribute__((aligned(16))); 29 | inline void set_pixel(int x, int y, uint8_t cl) 30 | { 31 | //assert(x >= 0 && x < 320 && y >= 0 && y < 200); 32 | if (x >= 0 && x < 320 && y >= 0 && y < 200) 33 | backbuffer[y * 320 + x] = cl; 34 | } 35 | inline void clear() 36 | { 37 | memset(backbuffer, 0, sizeof(backbuffer)); 38 | } 39 | 40 | static int timev = 0; 41 | 42 | struct Star 43 | { 44 | Star() { 45 | x = rand() % 320; 46 | y = rand() % 200; 47 | cl = 18 + rand() % 14; 48 | } 49 | void render() 50 | { 51 | uint8_t dark = std::max(cl - 6, 16); 52 | set_pixel(x+1, y, dark); 53 | set_pixel(x-1, y, dark); 54 | set_pixel(x, y+1, dark); 55 | set_pixel(x, y-1, dark); 56 | set_pixel(x, y, cl); 57 | } 58 | void modulate() 59 | { 60 | clear(); 61 | if (cl == 16) return; 62 | 63 | float dx = (x - 160); 64 | float dy = (y - 100); 65 | if (dx == 0 && dy == 0) return; 66 | 67 | float mag = 1.0f / sqrtf(dx*dx + dy*dy); 68 | dx *= mag; 69 | dy *= mag; 70 | x += dx * 1.0f; 71 | y += dy * 1.0f; 72 | 73 | render(); 74 | } 75 | void clear() 76 | { 77 | set_pixel(x+1, y, 0); 78 | set_pixel(x-1, y, 0); 79 | set_pixel(x, y+1, 0); 80 | set_pixel(x, y-1, 0); 81 | set_pixel(x, y, 0); 82 | } 83 | 84 | float x, y; 85 | uint8_t cl; 86 | }; 87 | static std::deque stars; 88 | 89 | void Service::start() 90 | { 91 | VGA_gfx::set_mode(VGA_gfx::MODE_320_200_256); 92 | VGA_gfx::clear(); 93 | VGA_gfx::apply_default_palette(); 94 | 95 | clear(); 96 | 97 | Timers::periodic(16ms, 98 | [] (int) { 99 | timev++; 100 | // add new (random) star 101 | if (rand() % 2 == 0) 102 | { 103 | Star star; 104 | star.render(); 105 | stars.push_back(star); 106 | } 107 | // render screen 108 | VGA_gfx::blit_from(backbuffer); 109 | 110 | // work on backbuffer 111 | for (auto& star : stars) 112 | { 113 | star.modulate(); 114 | } 115 | 116 | if (stars.size() > 50) 117 | { 118 | auto& dead_star = stars.front(); 119 | dead_star.clear(); 120 | stars.pop_front(); 121 | } 122 | }); 123 | } 124 | -------------------------------------------------------------------------------- /protobuf/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2017 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | void print_person_info(const char* header, const Person& person) 22 | { 23 | std::cout << header << '\n'; 24 | std::cout << "ID: " << person.id() << '\n'; 25 | std::cout << "Name: " << person.name() << '\n'; 26 | std::cout << "E-mail: " << person.email() << "\n\n"; 27 | } 28 | 29 | void Service::start() 30 | { 31 | //--------------------------------------------------------------------------- 32 | // Verify that the version of the library that we linked against is 33 | // compatible with the version of the headers we compiled against. 34 | //--------------------------------------------------------------------------- 35 | GOOGLE_PROTOBUF_VERIFY_VERSION; 36 | 37 | std::string data; //< Message buffer 38 | 39 | //--------------------------------------------------------------------------- 40 | // Write message to a std::string 41 | //--------------------------------------------------------------------------- 42 | Person person; 43 | person.set_id(1234); 44 | person.set_name("John Doe"); 45 | person.set_email("jdoe@example.com"); 46 | person.SerializeToString(&data); 47 | 48 | //--------------------------------------------------------------------------- 49 | // Clear message information 50 | //--------------------------------------------------------------------------- 51 | person.Clear(); 52 | assert(person.id() == 0); 53 | assert(person.name() == ""); 54 | assert(person.email() == ""); 55 | print_person_info("Cleared message information:", person); 56 | 57 | //--------------------------------------------------------------------------- 58 | // Read message from a std::string 59 | //--------------------------------------------------------------------------- 60 | person.ParseFromString(data); 61 | assert(person.id() == 1234); 62 | assert(person.name() == "John Doe"); 63 | assert(person.email() == "jdoe@example.com"); 64 | print_person_info("Parsed message information:", person); 65 | 66 | //--------------------------------------------------------------------------- 67 | // Print raw message 68 | //--------------------------------------------------------------------------- 69 | std::cout << "Raw message:\n"; 70 | std::cout << data << '\n'; 71 | 72 | //--------------------------------------------------------------------------- 73 | // Optional: Delete all global objects allocated by libprotobuf. 74 | //--------------------------------------------------------------------------- 75 | google::protobuf::ShutdownProtobufLibrary(); 76 | } 77 | -------------------------------------------------------------------------------- /TLS_server/drive/test.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | 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 51 | Tc4qvMOITdZUl1Das9MqYWp4G8Uk8CA= 52 | -----END PRIVATE KEY----- 53 | -------------------------------------------------------------------------------- /LiveUpdate/tls/drive/test.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | 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 51 | Tc4qvMOITdZUl1Das9MqYWp4G8Uk8CA= 52 | -----END PRIVATE KEY----- 53 | -------------------------------------------------------------------------------- /TLS_server/drive/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | 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 51 | 1uTpJ58WkxghOes3Y0e/dJXtjDuH9A== 52 | -----END PRIVATE KEY----- 53 | -------------------------------------------------------------------------------- /IRCd/ircd/channel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "common.hpp" 7 | #include "modes.hpp" 8 | 9 | class IrcServer; 10 | class Client; 11 | namespace liu { 12 | struct Storage; 13 | struct Restore; 14 | } 15 | 16 | class Channel 17 | { 18 | public: 19 | typedef uint16_t index_t; 20 | using ClientList = std::deque; 21 | 22 | Channel(index_t self, IrcServer& sref); 23 | // reset to reuse in other fashion 24 | void reset(const std::string& new_name); 25 | 26 | bool is_alive() const noexcept { 27 | return !clients_.empty(); 28 | } 29 | index_t get_id() const noexcept { 30 | return self; 31 | } 32 | const std::string& name() const noexcept { 33 | return cname; 34 | } 35 | size_t size() const noexcept { 36 | return clients_.size(); 37 | } 38 | long created() const noexcept { 39 | return create_ts; 40 | } 41 | 42 | const ClientList& clients() { 43 | return clients_; 44 | } 45 | 46 | char listed_symb(clindex_t cid) const; 47 | 48 | 49 | bool add(clindex_t); 50 | size_t find(clindex_t); 51 | 52 | // silently remove client from all channel lists 53 | bool remove(clindex_t cl) 54 | { 55 | auto idx = find(cl); 56 | if (idx != NO_SUCH_CHANNEL_INDEX) 57 | { 58 | clients_.erase(clients_.begin() + idx); 59 | voices.erase(cl); 60 | chanops.erase(cl); 61 | } 62 | return idx != NO_SUCH_CHANNEL_INDEX; 63 | } 64 | 65 | // the entire JOIN sequence for a client 66 | bool join(Client&, const std::string& key = ""); 67 | // and the PART command 68 | bool part(Client&, const std::string& msg = ""); 69 | 70 | bool has_topic() const noexcept { 71 | return !ctopic.empty(); 72 | } 73 | const std::string& get_topic() const noexcept { 74 | return ctopic; 75 | } 76 | long get_topic_ts() const noexcept { 77 | return ctopic_ts; 78 | } 79 | const std::string& get_topic_by() const noexcept { 80 | return ctopic_by; 81 | } 82 | 83 | // set new channel topic (and timestamp it) 84 | void set_topic(Client&, const std::string&); 85 | 86 | bool is_banned(clindex_t) const noexcept { 87 | return false; 88 | } 89 | bool is_excepted(clindex_t) const noexcept { 90 | return false; 91 | } 92 | 93 | bool is_chanop(clindex_t cid) const; 94 | bool is_voiced(clindex_t cid) const; 95 | 96 | std::string mode_string() const; 97 | void send_mode(Client&); 98 | void send_topic(Client&); 99 | void send_names(Client&); 100 | 101 | static bool is_channel_identifier(char c) { 102 | static std::string LUT = "&#+!"; 103 | return LUT.find_first_of(c) != std::string::npos; 104 | } 105 | 106 | // send message to all users in a channel 107 | void bcast(const char*, size_t); 108 | void bcast(const std::string& from, uint16_t tk, const std::string& msg); 109 | void bcast_butone(clindex_t src, const char*, size_t); 110 | 111 | void serialize_to(liu::Storage&); 112 | void deserialize(liu::Restore&); 113 | 114 | const std::string& name_hash() const noexcept { 115 | return cname; 116 | } 117 | private: 118 | index_t self; 119 | uint16_t cmodes; 120 | long create_ts; 121 | std::string cname; 122 | std::string ctopic; 123 | std::string ctopic_by; 124 | long ctopic_ts; 125 | std::string ckey; 126 | uint16_t climit; 127 | IrcServer& server; 128 | ClientList clients_; 129 | std::unordered_set chanops; 130 | std::unordered_set voices; 131 | }; 132 | -------------------------------------------------------------------------------- /transfer/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | /** 22 | * An example to show incoming and outgoing TCP Connections. 23 | * In this example, IncludeOS is listening on port 80. 24 | * 25 | * Data received on port 80 will be redirected to a 26 | * outgoing connection to a (in this case) python server (server.py) 27 | * 28 | * Data received from the python server connection 29 | * will be redirected back to the client. 30 | * 31 | * To try it out, use netcat to connect to this IncludeOS instance. 32 | **/ 33 | 34 | using Connection_ptr = net::tcp::Connection_ptr; 35 | using Disconnect = net::tcp::Connection::Disconnect; 36 | 37 | // Address to our python server: 10.0.2.2:1337 38 | // @note: This may have to be modified depending on network and server settings. 39 | net::Socket python_server{ {10,0,0,1} , 1337}; 40 | 41 | void Service::start() 42 | { 43 | #ifdef USERSPACE_LINUX 44 | extern void create_network_device(int N, const char* route, const char* ip); 45 | create_network_device(0, "10.0.0.0/24", "10.0.0.1"); 46 | #endif 47 | auto& inet = net::Interfaces::get(0); 48 | inet.network_config( 49 | { 10, 0, 0, 42 }, // IP 50 | { 255,255,255, 0 }, // Netmask 51 | { 10, 0, 0, 1 }, // Gateway 52 | { 10, 0, 0, 1 }); // DNS 53 | 54 | // Set up a TCP server on port 81 55 | auto& server = inet.tcp().listen(81); 56 | printf("Server listening: %s \n", server.local().to_string().c_str()); 57 | 58 | // When someone connects to our server 59 | server.on_connect( 60 | [&inet] (Connection_ptr client) { 61 | printf("Connected [Client]: %s\n", client->to_string().c_str()); 62 | // Make an outgoing connection to our python server 63 | auto outgoing = inet.tcp().connect(python_server); 64 | // When outgoing connection to python sever is established 65 | outgoing->on_connect( 66 | [client] (Connection_ptr python) { 67 | if (!python) { 68 | printf("Connection failed!\n"); 69 | return; 70 | } 71 | printf("Connected [Python]: %s\n", python->to_string().c_str()); 72 | 73 | // Setup handlers for when data is received on client and python connection 74 | // When client reads data 75 | client->on_read(1024, [python](auto buf) { 76 | python->write(buf); 77 | }); 78 | 79 | // When client is disconnecting 80 | client->on_disconnect([python](Connection_ptr, Disconnect reason) { 81 | printf("Disconnected [Client]: %s\n", reason.to_string().c_str()); 82 | python->close(); 83 | }); 84 | 85 | // When python is disconnecting 86 | python->on_disconnect([client](Connection_ptr, Disconnect reason) { 87 | printf("Disconnected [Python]: %s\n", reason.to_string().c_str()); 88 | client->close(); 89 | }); 90 | }); // << onConnect (outgoing (python)) 91 | }); // << onConnect (client) 92 | } 93 | -------------------------------------------------------------------------------- /IRCd/ircd/tokens.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | inline bool is_reply(size_t numeric) { 4 | return numeric < 400; 5 | } 6 | inline bool is_error(size_t numeric) { 7 | return numeric >= 400; 8 | } 9 | 10 | #define ERR_NOSUCHNICK 401 11 | #define ERR_NOSUCHCHANNEL 403 12 | #define ERR_CANNOTSENDTOCHAN 404 13 | #define ERR_TOOMANYCHANNELS 405 14 | 15 | #define ERR_NOSUCHCMD 421 16 | 17 | #define ERR_NONICKNAMEGIVEN 431 18 | #define ERR_ERRONEUSNICKNAME 432 19 | #define ERR_NICKNAMEINUSE 433 20 | 21 | #define ERR_UNAVAILRESOURCE 437 22 | 23 | #define ERR_USERNOTINCHANNEL 441 24 | #define ERR_NOTONCHANNEL 442 25 | #define ERR_USERONCHANNEL 443 26 | #define ERR_NOLOGIN 444 27 | 28 | #define ERR_NEEDMOREPARAMS 461 29 | #define ERR_ALREADYREGISTRED 462 30 | #define ERR_PASSWDMISMATCH 464 31 | #define ERR_YOUREBANNEDCREEP 465 32 | #define ERR_YOUWILLBEBANNED 466 33 | #define ERR_KEYSET 467 34 | 35 | #define ERR_CHANNELISFULL 471 36 | #define ERR_UNKNOWNMODE 472 37 | #define ERR_INVITEONLYCHAN 473 38 | #define ERR_BANNEDFROMCHAN 474 39 | #define ERR_BADCHANNELKEY 475 40 | #define ERR_BADCHANMASK 476 41 | #define ERR_NOCHANMODES 477 42 | #define ERR_BANLISTFULL 478 43 | 44 | #define ERR_NOPRIVILEGES 481 45 | #define ERR_CHANOPRIVSNEEDED 482 46 | #define ERR_UNIQOPPRIVSNEEDED 485 47 | 48 | #define ERR_UMODEUNKNOWNFLAG 501 49 | #define ERR_USERSDONTMATCH 502 50 | 51 | #define RPL_WELCOME 001 52 | #define RPL_YOURHOST 002 53 | #define RPL_CREATED 003 54 | #define RPL_MYINFO 004 55 | #define RPL_CAPABS 005 56 | 57 | #define RPL_USERHOST 302 58 | 59 | #define RPL_WHOISUSER 311 60 | #define RPL_WHOISIDLE 317 61 | #define RPL_ENDOFWHOIS 318 62 | 63 | #define RPL_ENDOFSTATS 219 64 | #define RPL_STATSUPTIME 242 65 | #define RPL_UMODEIS 221 66 | 67 | 68 | #define RPL_LUSERCLIENT 251 69 | #define RPL_LUSEROP 252 70 | #define RPL_LUSERUNKNOWN 253 71 | #define RPL_LUSERCHANNELS 254 72 | #define RPL_LUSERME 255 73 | 74 | #define RPL_ADMINME 256 75 | #define RPL_ADMINLOC1 257 76 | #define RPL_ADMINLOC2 258 77 | #define RPL_ADMINEMAIL 259 78 | 79 | #define RPL_UNIQOPIS 325 80 | #define RPL_CHANNELMODEIS 324 81 | #define RPL_CHANNELCREATED 329 82 | #define RPL_NOTOPIC 331 83 | #define RPL_TOPIC 332 84 | #define RPL_TOPICBY 333 85 | 86 | #define RPL_VERSION 351 87 | 88 | #define RPL_NAMREPLY 353 89 | #define RPL_ENDOFNAMES 366 90 | 91 | #define RPL_INFO 371 92 | #define RPL_ENDOFINFO 374 93 | 94 | #define RPL_MOTDSTART 375 95 | #define RPL_MOTD 372 96 | #define RPL_ENDOFMOTD 376 97 | 98 | #define RPL_TIME 391 99 | 100 | #define RPL_USERSSTART 392 101 | #define RPL_USERS 393 102 | #define RPL_ENDOFUSERS 394 103 | 104 | 105 | #define TK_CAP "CAP" 106 | #define TK_PASS "PASS" 107 | #define TK_NICK "NICK" 108 | #define TK_USER "USER" 109 | 110 | #define TK_MOTD "MOTD" 111 | #define TK_LUSERS "LUSERS" 112 | #define TK_USERHOST "USERHOST" 113 | #define TK_STATS "STATS" 114 | 115 | #define TK_PING "PING" 116 | #define TK_PONG "PONG" 117 | #define TK_MODE "MODE" 118 | #define TK_JOIN "JOIN" 119 | #define TK_PART "PART" 120 | #define TK_TOPIC "TOPIC" 121 | #define TK_NAMES "NAMES" 122 | #define TK_PRIVMSG "PRIVMSG" 123 | #define TK_QUIT "QUIT" 124 | 125 | #define TK_CONNECT "CONNECT" 126 | #define TK_SQUIT "SQUIT" 127 | #define TK_WALLOPS "WALLOPS" 128 | 129 | #define TK_SVSNICK "SVSNICK" 130 | #define TK_SVSUSER "SVSUSER" 131 | #define TK_SVSHOST "SVSHOST" 132 | -------------------------------------------------------------------------------- /acorn/app/routes/squirrels.hpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #ifndef ROUTES_SQUIRRELS_HPP 19 | #define ROUTES_SQUIRRELS_HPP 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace acorn { 26 | namespace routes { 27 | 28 | class Squirrels : public mana::Router { 29 | 30 | using SquirrelBucket = bucket::Bucket; 31 | 32 | public: 33 | 34 | Squirrels(std::shared_ptr squirrels) 35 | { 36 | // GET / 37 | on_get("/", 38 | [squirrels] (auto, auto res) 39 | { 40 | //printf("[Squirrels@GET:/] Responding with content inside SquirrelBucket\n"); 41 | using namespace rapidjson; 42 | StringBuffer sb; 43 | Writer writer(sb); 44 | squirrels->serialize(writer); 45 | res->send_json(sb.GetString()); 46 | }); 47 | 48 | // POST / 49 | on_post("/", 50 | [squirrels] (mana::Request_ptr req, auto res) 51 | { 52 | using namespace mana; 53 | auto json = req->get_attribute(); 54 | if(!json) { 55 | res->error({http::Internal_Server_Error, "Server Error", "Server needs to be sprinkled with Parsley"}); 56 | } 57 | else { 58 | auto& doc = json->doc(); 59 | try { 60 | // create an empty model 61 | acorn::Squirrel s; 62 | // deserialize it 63 | bool ok = s.deserialize(doc); 64 | if(UNLIKELY(not ok)) 65 | { 66 | printf("[Squirrels@POST:/] Could not deserialize squirrel\n"); 67 | res->error({"Parsing Error", "Could not parse data."}); 68 | return; 69 | } 70 | // add to bucket 71 | auto id = squirrels->capture(s); 72 | assert(id == s.key); 73 | printf("[Squirrels@POST:/] Squirrel captured: %s\n", s.get_name().c_str()); 74 | // setup the response 75 | // location to the newly created resource 76 | using namespace std; 77 | res->header().set_field(http::header::Location, std::string(req->uri().path())); // return back end loc i guess? 78 | // status code 201 Created 79 | res->source().set_status_code(http::Created); 80 | // send the created entity as response 81 | res->send_json(s.json()); 82 | } 83 | catch(const bucket::ConstraintException& e) { 84 | printf("[Squirrels@POST:/] ConstraintException: %s\n", e.what()); 85 | res->error({"Constraint Exception", e.what()}); 86 | } 87 | catch(const bucket::BucketException& e) { 88 | printf("[Squirrels@POST:/] BucketException: %s\n", e.what()); 89 | res->error({"Bucket Exception", e.what()}); 90 | } 91 | } 92 | }); 93 | 94 | } 95 | }; 96 | 97 | } // < namespace routes 98 | } // < namespace acorn 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /http_client/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | static SSL_CTX* init_ssl_context() 22 | { 23 | auto& disk = fs::memdisk(); 24 | disk.init_fs([] (fs::error_t err, auto& fs) { 25 | assert(!err); 26 | 27 | err = fs.print_subtree("/certs"); 28 | assert(err == fs::no_error && "Need certificate bundle folder present"); 29 | }); 30 | 31 | auto ents = disk.fs().ls("/certs"); 32 | // initialize client context 33 | openssl::init(); 34 | return openssl::create_client(ents, true); 35 | } 36 | 37 | #include 38 | #include 39 | using namespace std::literals::string_literals; 40 | 41 | static void begin_http(net::Inet& inet) 42 | { 43 | using namespace http; 44 | 45 | static Basic_client basic{inet.tcp()}; 46 | 47 | const auto url{"http://www.google.com"s}; 48 | INFO("HTTP", "GET %s", url.c_str()); 49 | 50 | basic.get(url, {}, [url](Error err, Response_ptr res, Connection&) 51 | { 52 | if(not err) { 53 | printf("\n%s - Got Response!\n%s\n", url.c_str(), res->to_string().c_str()); 54 | } 55 | else { 56 | printf("\n%s - No response: %s\n", url.c_str(), err.to_string().c_str()); 57 | printf("Make sure the virtual machine can reach internet.\n"); 58 | } 59 | }); 60 | 61 | auto* ctx = init_ssl_context(); 62 | assert(ctx != nullptr); 63 | 64 | static Client client{inet.tcp(), ctx}; 65 | 66 | const auto url_sec{"https://www.google.com"s}; 67 | INFO("HTTPS", "(Secure) GET %s", url_sec.c_str()); 68 | 69 | client.get(url_sec, {}, [url = url_sec](Error err, Response_ptr res, Connection&) 70 | { 71 | if(not err) { 72 | printf("\n%s - Got Response!\n%s\n", url.c_str(), res->to_string().c_str()); 73 | } 74 | else { 75 | printf("\n%s - No response: %s\n", url.c_str(), err.to_string().c_str()); 76 | printf("Make sure the virtual machine can reach internet.\n"); 77 | } 78 | }); 79 | 80 | Client::Options options; 81 | options.follow_redirect = 0; 82 | const auto url_mis{"https://www.facebook.com"s}; 83 | client.get(url_mis, {}, [url = url_mis](Error err, Response_ptr res, Connection&) 84 | { 85 | if(not err) { 86 | std::cout << "\n" << url << " - Got response!\n" << res->status_line() << "\n" << res->header() << "\n"; 87 | } 88 | else { 89 | printf("\n%s - No response: %s\n", url.c_str(), err.to_string().c_str()); 90 | printf("Make sure the virtual machine can reach internet.\n"); 91 | } 92 | }, options); 93 | 94 | options.follow_redirect = 1; 95 | client.get(url_mis, {}, [url = url_mis](Error err, Response_ptr res, Connection&) 96 | { 97 | if(not err) { 98 | std::cout << "\n" << url << " - Got response!\n" << res->status_line() << "\n" << res->header() << "\n"; 99 | } 100 | else { 101 | printf("\n%s - No response: %s\n", url.c_str(), err.to_string().c_str()); 102 | printf("Make sure the virtual machine can reach internet.\n"); 103 | } 104 | }, options); 105 | 106 | } 107 | 108 | #include 109 | void Service::start() 110 | { 111 | auto& inet = net::Interfaces::get(0); 112 | 113 | inet.on_config( 114 | [] (auto& inet) { 115 | begin_http(inet); 116 | }); 117 | 118 | } 119 | -------------------------------------------------------------------------------- /acorn/disk1/public/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Acorn Web Appliance 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 45 | 46 | 47 | 48 |
49 | 50 | 51 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /tcp/service.cpp: -------------------------------------------------------------------------------- 1 | // This file is a part of the IncludeOS unikernel - www.includeos.org 2 | // 3 | // Copyright 2015-2016 Oslo and Akershus University College of Applied Sciences 4 | // and Alfred Bratterud 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | #include 19 | #include 20 | 21 | /** 22 | * An example to show incoming and outgoing TCP Connections. 23 | * In this example, IncludeOS is listening on port 80. 24 | * 25 | * Data received on port 80 will be redirected to a 26 | * outgoing connection to a (in this case) python server (server.py) 27 | * 28 | * Data received from the python server connection 29 | * will be redirected back to the client. 30 | * 31 | * To try it out, use netcat to connect to this IncludeOS instance. 32 | **/ 33 | 34 | using Connection_ptr = net::tcp::Connection_ptr; 35 | using Disconnect = net::tcp::Connection::Disconnect; 36 | 37 | // Address to our python server: 10.0.2.2:1337 38 | // @note: This may have to be modified depending on network and server settings. 39 | net::Socket python_server{ {10,0,2,2} , 1337}; 40 | 41 | // Called when data is received on client (incoming connection) 42 | void handle_client_on_read(Connection_ptr python, const std::string& request) { 43 | printf("Received [Client]: %s\n", request.c_str()); 44 | // Write the request to our python server 45 | python->write(request); 46 | } 47 | 48 | // Called when data is received on python (outgoing connection) 49 | void handle_python_on_read(Connection_ptr client, const std::string& response) { 50 | // Write response to our client 51 | client->write(response); 52 | } 53 | 54 | void Service::start() 55 | { 56 | auto& inet = net::Interfaces::get(0); 57 | 58 | // Set up a TCP server on port 80 59 | auto& server = inet.tcp().listen(80); 60 | printf("Server listening: %s \n", server.local().to_string().c_str()); 61 | 62 | // When someone connects to our server 63 | server.on_connect( 64 | [&inet] (Connection_ptr client) { 65 | printf("Connected [Client]: %s\n", client->to_string().c_str()); 66 | // Make an outgoing connection to our python server 67 | auto outgoing = inet.tcp().connect(python_server); 68 | // When outgoing connection to python sever is established 69 | outgoing->on_connect( 70 | [client] (Connection_ptr python) { 71 | printf("Connected [Python]: %s\n", python->to_string().c_str()); 72 | 73 | // Setup handlers for when data is received on client and python connection 74 | // When client reads data 75 | client->on_read(1024, [python](auto buf) { 76 | std::string data{ (char*)buf->data(), buf->size() }; 77 | handle_client_on_read(python, data); 78 | }); 79 | 80 | // When python server reads data 81 | python->on_read(1024, [client](auto buf) { 82 | std::string data{ (char*)buf->data(), buf->size() }; 83 | handle_python_on_read(client, data); 84 | }); 85 | 86 | // When client is disconnecting 87 | client->on_disconnect([python](Connection_ptr, Disconnect reason) { 88 | printf("Disconnected [Client]: %s\n", reason.to_string().c_str()); 89 | python->close(); 90 | }); 91 | 92 | // When python is disconnecting 93 | python->on_disconnect([client](Connection_ptr, Disconnect reason) { 94 | printf("Disconnected [Python]: %s\n", reason.to_string().c_str()); 95 | client->close(); 96 | }); 97 | }); // << onConnect (outgoing (python)) 98 | }); // << onConnect (client) 99 | } 100 | --------------------------------------------------------------------------------