Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Totoro

Stem - easy internet bridge

Recommended Posts

What is STEM?

Did you ever want to have a linked card, but without this pair-to-pair limitations?

Well, you have internet card. And that is already half of the solution. The other half is to use Stem.

iHjWLMf.png

Stem is a message transmitter for your OpenComputers devices with internet cards.

Using a small OpenOS library you can use Stem to send and receive messages. Unlike the standard `modem` component, Stem-messaging uses not addresses, but `channels`. You can send messages to any channels, and you can subscribe to any number of channels to listen for messages from them.

Installation

The best way is to use HPM:

hpm install stem

If you do not have HPM, install it like this:

pastebin run vf6upeAN

If you do not want to use HPM repository, you can just use wget:

wget https://gitlab.com/UnicornFreedom/stem/raw/master/stem.lua

Example of a program using STEM

local event = require('event')

-- use STEM client library
local stem = require('stem')

-- open a connection to a STEM server
-- the `stem.fomalhaut.me` is a default one
local server = stem.connect('stem.fomalhaut.me')

-- subscribe for messages from the channel with ID 'my-channel-id'
server:subscribe('my-channel-id')

-- then listen for events in a loop...
while true do
  local name, channel_id, message = event.pull('stem_message')
  if name ~= nil then
    print(channel_id, message)
  end
end

-- ...or register an event listener
event.listen('stem_message', function(_, _, channel_id, message)
  print(channel_id, message)
end)

-- you can also send message to the channel
-- (you do not need to be subscribed to this channel, to send a message)
server:send('my-channel-id', 'hello there')

-- unsubscribe from channel
server:unsubscribe('my-channel-id')

-- completely close the connection to the STEM server
server:disconnect()

 

That is all.

But there is more.

Web client

If you open the link to Stem server in your browser: https://stem.fomalhaut.me/

You will see some statistics and the web client. Enter your channel ID into the form, and you can send messages to your robot in real time, right from your phone, without even starting Minecraft.

oiQnnAP.png

The web client is limited with UTF-8 encoding, though.

(Using OpenOS you can send literally anything, as long as the message fits in 64kb of data.)

Security Questions

The channels by default do not have any special security measures applied. They do not have any authentication mechanisms, the do not have any encryption.

Anyone who knows the ID of a channel can send a message to it and can listen for responses. But.

The length of ID is 256 bytes. And that can be any bytes - from 0 to 255. That means, that you have 256^256 possible combinations for your ID. And that is a giant number. If you need to secure your channel - just use something long and incomprehensible as your ID.

As an additional measure you can use end-to-end encryption, or anything else - this is up to you.

Default STEM server uses HTTPS, and does not store any information - message in, message out.

Self-hosted STEM solution

For those of you who are strong in spirit and computer knowledge - there is a self-hosted option. You can build Stem server from sources and run it on your machine.

This is also pretty easy. Additional instructions can be found on GitLab.

Useful links

GitLab repository: https://gitlab.com/UnicornFreedom/stem

Protocol description: https://gitlab.com/UnicornFreedom/stem/wikis/protocol

Default server: https://stem.fomalhaut.me/

HPM package: https://hel.fomalhaut.me/#packages/stem

 

If I forgot something - feel free to ask here, or in IRC (my nickname is Totoro there). Also the project contains at least one "Easter egg" feature, that can offer some interesting options if you know HTML/CSS/JS.

The Stem protocol is open - you can modify it, you can create your own clients in any programming language, etc.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.