An API for managing your servers

Overview

Intecture APIs Build Status Coverage Status Gitter

Intecture is an API for managing your servers. Visit intecture.io.

API docs can be found here: intecture.io/api/intecture_api/.


Intecture's APIs (cough and a binary) are the heart and soul of Intecture. Check out each component's README.md for details:

  • core - The core API that does all the heavy lifting
  • bindings - Rust FFI and language bindings
  • proj - Helpers and boilerplate for building Intecture projects
  • agent - Tiny daemon that exposes the core API as a service (for your hosts!)

Getting started

Intecture is pretty light on external dependencies. In fact, all you'll need to get started is Rust!

Once you've installed Rust, create a new Cargo binary project:

cargo new --bin

Next, add Intecture to your Cargo.toml:

[dependencies]
futures = "0.1"
intecture_api = {git = "https://github.com/intecture/api", version = "0.4"}
tokio-core = "0.1"

This is all we need to do if we only want to manage the local machine. Just make sure you use the Local host type, like so:

// You can ignore these two lines. They are boilerplate from `tokio-core` that
// drive Intecture's asynchronous API.
let mut core = Core::new().unwrap();
let handle = core.handle();

let host = Local::new(&handle).and_then(|host| {
    // Do stuff on the local host...
});

// You can ignore this line. It is more `tokio-core` boilerplate.
core.run(host).unwrap();

You can find some basic examples here: core/examples. Also you should refer to the API docs: intecture.io/api/intecture_api/

For remote hosts only

To manage a remote machine with Intecture, you need to take a few extra steps. On the remote machine...

Install Rust.

Clone this GitHub repository:

git clone https://github.com/intecture/api

Build the project:

cd api && cargo build --release

Then run the agent, specifying an address to bind to:

target/release/intecture_agent --address 0.0.0.0:7101

Remember, the agent must be running in order for the API to connect to this host.

Finally we can get back to what we came here for - Rust codez! To manage this machine, make sure you use the Plain remote host type, like so:

let host = Plain::connect("<ip_of_host>:7101").and_then(|host| {
    // Do stuff on the remote host...
});

Note the type is Plain, rather than Remote. At the moment, Intecture does no encryption, making it unsafe for use over insecure networks (i.e. the internet). The type Plain signifies this. In the future we will add support for encrypted remote host types as well, but for now, we cannot recommend strongly enough that you only use this on a secure local network.

What's new?

Check out RELEASES.md for details.

Comments
  • Add NixOS target

    Add NixOS target

    @petehayes102 Tests for PHP bindings are failing with:-

    configure: error: host_connect function not found in libinapi
    

    This isn't related to this pull request though.

    Fixes https://github.com/intecture/api/issues/34.

    opened by rushmorem 2
  • Merge Agent with API

    Merge Agent with API

    The Agent provides endpoints for the API that are routable via a ZeroMQ pipe. However all the metadata required to autogenerate endpoints and serialize the data for transit is contained within the API.

    In order to reduce duplication and unnecessary admin overhead, a parser should be built to interpret API endpoints and autogenerate the required stubs (agent_endpoints.rs). A Rust module, agent.rs, would be the binary target responsible for initialising ZMQ sockets and starting the Agent service.

    This issue is blocked by https://github.com/Intecture/api/issues/14.

    enhancement blocked 
    opened by petehayes102 2
  • Update to serde 0.9

    Update to serde 0.9

    Among other benefits, the 0.9 JSON value is a lot nicer to work with. This line in api/src/host/data/mod.rs:

    me.as_object_mut().unwrap().insert("_payloads".into(), serde_json::to_value(payloads));
    

    could be:

    me["_payloads"] = json!(payloads);
    
    opened by dtolnay 1
  • Implement pager

    Implement pager

    At runtime, all status output (apart from errors) has to be done manually by the user. I.e. printing a message to stdout before and after a job so the user can keep track of Intecture's progress.

    Intecture primitives should instead publish their status to a PUB socket which the user can subscribe to. This way the user is saved from having to write their own status output.

    opened by petehayes102 1
  • PHP binding Telemetry upgrade

    PHP binding Telemetry upgrade

    Currently in the PHP binding, using the Telemetry primitive requires two lines:

    $telemetry = Telemetry::init($host);
    $tdata = $telemetry->get();
    echo $tdata['os']['platform'];
    

    This sucks. A better way to do it would be to allow declaring a new Telemetry object rather than the unimplemented singleton pattern, and to extend the ArrayObject class. The result would look like this:

    $telemetry = new Telemetry($host);
    echo $telemetry['os']['platform'];
    
    enhancement 
    opened by petehayes102 1
  • API-Agent heartbeat

    API-Agent heartbeat

    Currently the API relies on a static timeout when communicating with an Agent. This is totally unreliable and has to be set unreasonably high to prevent timeouts on intential long running processes.

    Instead a heartbeat should be used over the API socket to ascertain the uptime of both API and Agent.

    enhancement 
    opened by petehayes102 1
  • Rewrite target interface

    Rewrite target interface

    Currently API primitives achieve cross-platform compatibility by splitting API endpoints into target specific implementations. This results in one file per platform (i.e. CentOS, FreeBSD, Mac OS etc.), which can get quite bloated. Also, there is a deliniation between "local-run" (for the Agent) and "remote-run" (for the dev box) features which muddies the waters significantly.

    Instead, we should keep primitives' target specific implementations in the same place as their public APIs, and refer to them by technology instead of OS (e.g. Service::systemd, Service::init etc.). A Provider trait will be used to expose an available() method to determine which providers are available for the platform.

    OS targets become text file definitions that provide a list of default providers for each primitive. build.rs will autogenerate Rust code from these targets.

    Dependency injection will be used to inject the correct Provider into each primitive upon initialisation. Remote and local features will be removed in favour of DI. For a connected Host, DI will select the Remote Provider. For a disconnected [local] host, DI will select a Provider based on their availability (Provider::available()), filtered by the OS target definition.

    enhancement blocker 
    opened by petehayes102 1
  • Create project data layer

    Create project data layer

    Currently Intecture does not provide a way to manage data associated with a payload.

    Here is a very informal spec:

    1. Nodes, payloads, tags etc. are all data files
      1. A data file with the type “node” will be the entry point for any build
      2. Apart from “node” type, types are arbitrary strings (do we want this?)
    2. Data files can optionally have an “include” parameter for requiring other files/payloads
    3. Data file items can have conditions that allow them to specify when they are applied
      1. Like CSS, the most specific item wins
      2. If two items have the same specificity, the higher order file wins - i.e. the winning file is the one that included the other file, thus is higher in the data hierarchy
    4. Data file items can optionally merge with less specific items, rather than overwriting
      1. Merges will either append to an existing array, or create an array containing the two merged items
    enhancement blocker 
    opened by petehayes102 1
  • Host struct should read auth server endpoint from config

    Host struct should read auth server endpoint from config

    Currently the authentication server's endpoint (e.g. "auth.example.com:7101") is specified in both the project config file (project.json) as well as the Host::connect() signature. As it's a data point that is unlikely to change, and also not specific to a Host, it belongs in config and not in code.

    The Host::connect implementation must be changed to read the auth_server parameter from an external source. Either:

    1. project.json in the project root - requires including the zdaemon crate for config file helpers and duplicating config.rs from the CLI repo, or,
    2. Preferably, pass in the value from the CLI => stdin of the user project. In this case an args handler would need to be written to retrieve and cache 'system' values, while exposing user defined values back to the user.
    enhancement 
    opened by petehayes102 1
  • Test FFI structs prior to converting them to Rust equivalents

    Test FFI structs prior to converting them to Rust equivalents

    Currently we test user provided pointers to make sure they are valid. However we don't provide the same level of due diligence on struct member pointers before converting the struct into the Rust-native equivalent.

    We need some way of testing structs succinctly that allows us to return a Result<> type that we can handle safely. One way of doing this is to throw out the native convert trait implementations and roll our own with a friendly return signature. This isn't ideal as we don't want to lose Rust's implicit conversions.

    Another method is to create a trait that would be implemented by FFI structs to check their own members:

    trait HasNull {
        fn has_null(&self) -> Option<Vec<&'static str>>;
    }
    
    impl HasNull for Ffi__MyStruct {
        fn has_null(&self) -> Option<Vec<&'static str>> {
            let mut null_fields = Vec::new();
            if self.ptr_member.is_null() {
                null_fields.push("ptr_member");
            }
    
            if null_fields.len() > 0 {
                Some(null_fields);
            } else {
                None
            }
        }
    }
    

    ^^^ Firing from the hip!

    enhancement wontfix 
    opened by petehayes102 1
  • Implement `catch_unwrap()` on FFI modules

    Implement `catch_unwrap()` on FFI modules

    The FFI still relies on some unwrap()s, especially in the convert trait implementations. As a failsafe, we should implement catch_unwrap() to trigger an error instead of crashing the thread.

    enhancement 
    opened by petehayes102 1
  • Fix inconsistencies in method/struct naming

    Fix inconsistencies in method/struct naming

    Cases that I'm currently aware of:

    • File::mv vs. File::copy - should also have File::cp and File::move with the long names as aliases
    • DirectoryOpts vs FileOptions - Should be DirectoryOptions, deprecate DirectoryOpts
    • Service::new_service() accepts a ServiceRunnable::Service OR ServiceRunnable::Command, which is misleading. Should perhaps be Service::new_runnable?
    opened by petehayes102 0
  • Port Linux CPU telemetry to `lscpu`

    Port Linux CPU telemetry to `lscpu`

    Some earlier versions of Debian /proc/cpuinfo do not contain all the key/values that Intecture expects to find. For example, "cpu cores" is missing on Debian Wheezy.

    It seems that by using the lscpu command, we will get more predictable output across flavours/versions.

    opened by petehayes102 0
  • Redesign inter-Payload interface

    Redesign inter-Payload interface

    Currently payloads are executed as standalone processes with ZMQ pipes for IPC. This is bad for a number of reasons:

    • For large projects, it can lead to a massive number of child processes being spawned
    • Each project must be compiled individually, which is incredibly slow (assuming not interpreted)
    • Data exchange is very poor and prevents programmers from exposing rich APIs to other payloads

    Any new design must allow programmers to include same-language payloads as libraries instead of processes.

    Challenges:

    • Exchanging data across language barriers is complex
    • Most developers will not want to write FFI code themselves for interop
    • Ideally interpreted payloads should stay within the same process to allow shared memory, which would require hooks into the interpreter itself (e.g. reimplementing PHP's SAPI so that it can be called as a library from Rust)
    opened by petehayes102 0
  • Switch to need_macro!()

    Switch to need_macro!()

    Data macros (host::data::macros) are currently hardcoded, which had led to a lot of code duplication. A macro exists (need_macro!) to generate the required macros, however there is an issue with the eager expansion of $crate::.

    See issue: https://users.rust-lang.org/t/crate-being-expanded-too-eagerly-for-nested-macros/7592

    opened by petehayes102 0
Owner
Intecture
An API for your servers
Intecture
Full fake REST API generator written with Rust

Weld Full fake REST API generator. This project is heavily inspired by json-server, written with rust. Synopsis Our first aim is to generate a fake ap

Seray Uzgur 243 Dec 31, 2022
The LibreTranslate API for Rust.

libretranslate-rs A LibreTranslate API for Rust. libretranslate = "0.2.4" libretranslate allows you to use open source machine translation in your pr

Grant Handy 51 Jan 5, 2023
Cross-platform tool to update DNS such as Gandi.net with your dynamic IP address

GDU | Generic DNS Update A cross-platform tool to update DNS zonefiles (such as Gandi.net) when you have a dynamic public IP address. It's a DynDNS or

Damien Lecan 10 Jan 20, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Rewrite of the Discord Bot used for Managing the Infinity Bot List Servers.

Arcadia Rewrite of the Discord Bot used for Managing the Infinity Bot List Servers. Contributing Always run fmt.sh before making a Pull Request! MacOS

InfinityBotList 3 Dec 15, 2022
Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game

Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game. Home - Docs - Twitter - Discord ?? Features Everythi

Rivet 58 Jun 25, 2023
A CLI app to set and organize your favorite DNS servers.

rdns A CLI app to set and organize your favorite DNS servers. Introduction rdns is a CLI utility that can set your system DNS, either directly or by m

null 4 Feb 19, 2024
An utility application to help managing your C++ OI workspaces.

oi_helper oi_helper is an utility application to help managing your C++ OI workspaces. Why oi_helper We all know that we often need a project manager

27Onion Nebell 11 Aug 24, 2022
CLI tool for managing your 2FA authentication codes written in pure Rust.

(O)TP (VA)ULT - ova. ova is a simple CLI tool which lets you manage your TOTPs, or basically lets you get your two-way authentication code straight to

Giorgi Anakidze 3 Apr 28, 2023
🗂️ A simple, opinionated, tool, written in Rust, for declaratively managing Git repos on your machine.

gitrs ??️ A simple, opinionated, tool, written in Rust, for declaretively managing Git repos on your machine. "simple" - limited in what it supports.

Colton J. McCurdy 14 May 30, 2023
booky is a minimalstic Tui tool for managing your growing book collection.

booky booky is a minimalistic TUI tool for managing your growing book collection. It is writtin in Rust and uses diesel as it's orm together with sqli

null 3 Jul 21, 2023
A Rust crate for writing servers that speak PostgreSQL's wire protocol

Convergence A Rust crate for writing servers that speak PostgreSQL's wire protocol. Additionally, the experimental convergence-arrow crate enables con

ReservoirDB 63 Jan 2, 2023
🤖 brwrs is a new protocol running over TCP/IP that is intended to be a suitable candidate for terminal-only servers

brwrs is a new protocol running over TCP/IP that is intended to be a suitable candidate for terminal-only servers (plain text data). That is, although it can be accessed from a browser, brwrs will not correctly interpret the browser's GET request.

daCoUSB 3 Jul 30, 2021
An implementation of webauthn components for Rustlang servers

Webauthn-rs Webauthn is a modern approach to hardware based authentication, consisting of a user with an authenticator device, a browser or client tha

Kanidm 232 Jan 8, 2023
Safe Rust crate for creating socket servers and clients with ease.

bitsock Safe Rust crate for creating socket servers and clients with ease. Description This crate can be used for Client <--> Server applications of e

Lorenzo Torres 3 Nov 25, 2021
A list of publicly available STUN servers, refreshed every hour.

Always Online: STUN servers Have you ever thought: Gosh, why isn't there a regularly updated, comprehensive list of publicly available STUN servers? W

null 210 Dec 30, 2022
An implementation of webauthn components for Rustlang servers

Webauthn-rs Webauthn is a modern approach to hardware based authentication, consisting of a user with an authenticator device, a browser or client tha

Kanidm 226 Dec 28, 2022
A Discord bot focused on addressing the inherent problems with Discord, to allow a more socialist/anarchist organization of servers.

ACABot A Discord bot focused on addressing the inherent problems with Discord, to allow a more socialist/anarchist organization of servers (or "guilds

null 4 May 3, 2022
A library to quickly create OAuth2.1 compliant servers from scratch.

oauth21-server A library to easily create an OAuth 2.1 compliant authorization server. The motivation to develop this library comes from the fact that

Revanth Pothukuchi 3 Mar 14, 2022
chain nats.io servers with transformation & processing pipelines

NATS proxy service Simple tool to forward specific topics from one nats.io cluster to the same server or another. Provides support to process messages

Marquitos 8 Sep 19, 2022