A telnet chat server written in Rust, running on Lunatic.

Overview

Lunatic.chat

A telnet chat server written in Rust, running on Lunatic.

Lunatic logo

 

If you just would like to try it out, join the hosted version with:

# US server
telnet lunatic.chat
# EU server
telnet eu.lunatic.chat

You should pick the one closer to you as all the rendering is done on the backend and lower latency will mean better UX.

Architecture

The server is written in Rust. The Rust code is then compiled to WebAssembly and runs on top of Lunatic. Each connection runs in a separate (lightweight) process, has it's own state and sends just a diff of esc-sequences back to the terminal to bring it up to date with the current render buffer.

Build & run instructions

If you have rustup installed:

# Add Rust nightly:
> rustup toolchain add nightly
# Add the wasm32-wasi target
> rustup target add wasm32-wasi
# Build the project
> cargo +nightly build

To run it, you will need to have lunatic on your PATH. If this is the case you can just run cargo +nightly run or find the generated telnet-chat.wasm file in the target folder and run it with lunatic path/to/telnet-chat.wasm.

Licence

MIT

Comments
  • I can't build it on my own system

    I can't build it on my own system

    I have to build it on my WSL system(i love the linux commandline), but always got the error, how do i fix it and run it?

    Compiling unicode-width v0.1.8
       Compiling wasi v0.10.0+wasi-snapshot-preview1
       Compiling byteorder v1.4.2
       Compiling hashbrown v0.9.1
       Compiling humansize v1.1.0
       Compiling askama_escape v0.2.0
    error[E0463]: can't find crate for `core`
      |
      = note: the `wasm32-wasi` target may not be installed
    
    error[E0463]: can't find crate for `core`
      |
      = note: the `wasm32-wasi` target may not be installed
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: could not compile `unicode-width`
    
    To learn more, run the command again with --verbose.
    warning: build failed, waiting for other jobs to finish...
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error[E0463]: can't find crate for `std`
      |
      = note: the `wasm32-wasi` target may not be installed
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error[E0463]: can't find crate for `std`
      |
      = note: the `wasm32-wasi` target may not be installed
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error[E0463]: can't find crate for `std`
      |
      = note: the `wasm32-wasi` target may not be installed
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error[E0463]: can't find crate for `core`
      |
      = note: the `wasm32-wasi` target may not be installed
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: build failed
    
    opened by Minecodes 8
  • Change default port to 2323

    Change default port to 2323

    Running an application with a port lower than 1024 requires root privileges on linux. Changing it to something like 8080 allows running the example without having to use sudo.

    opened by hardliner66 3
  • Unsafe Transmute Error when building for Windows

    Unsafe Transmute Error when building for Windows

    I get some low level errors when building for Windows.

    cargo build --target x86_64-pc-windows-gnu --release Compiling lunatic v0.11.4 error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> /home/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/lunatic-0.11.4/src/mailbox.rs:312:51 | 312 | let function: fn(C, Mailbox<M, S>) = unsafe { std::mem::transmute(function) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type:i32(32 bits) = note: target type:fn(C, Mailbox<M, S>)` (64 bits)

    error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> /home/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/lunatic-0.11.4/src/host/mod.rs:73:38 | 73 | let function: fn(i32) = unsafe { std::mem::transmute(function) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type: i32 (32 bits) = note: target type: fn(i32) (64 bits)

    error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> /home/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/lunatic-0.11.4/src/process.rs:321:18 | 321 | unsafe { std::mem::transmute(entry) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type: i32 (32 bits) = note: target type: fn(ProcessRef<T>, <T as AbstractProcess>::Arg) -> <T as AbstractProcess>::State (64 bits)

    error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> /home/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/lunatic-0.11.4/src/process.rs:352:70 | 352 | let handler: fn(state: &mut T::State) = unsafe { std::mem::transmute(handler) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type: i32 (32 bits) = note: target type: for<'r> fn(&'r mut <T as AbstractProcess>::State) (64 bits)

    error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> /home/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/lunatic-0.11.4/src/process.rs:357:34 | 357 | unsafe { std::mem::transmute(handler) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type: i32 (32 bits) = note: target type: for<'r> fn(&'r mut <T as AbstractProcess>::State, Process<()>) (64 bits)

    error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> /home/jack/.cargo/registry/src/github.com-1ecc6299db9ec823/lunatic-0.11.4/src/protocol.rs:303:52 | 303 | let function: fn(C, Protocol<P, S>) = unsafe { std::mem::transmute(function) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type: i32 (32 bits) = note: target type: fn(C, Protocol<P, S>) (64 bits)

    For more information about this error, try rustc --explain E0512. error: could not compile lunatic due to 6 previous errors `

    Since Im new to rust I don't dare to debug the code since its unsafe. App is working fine on Linux, error only appears when building for windows.

    opened by zsmr11 2
  • Switch instead of add if tab already exists

    Switch instead of add if tab already exists

    Adds a new switch that switches to a tab by name, and add_or_switch that adds or switches whenever appropriate. It also changes the command processor to use add_or_switch for information and channel tabs.

    This should make tabs slightly less confusing to use.

    The tabs are still prepared before checking if it already exists. This might not be your preferred behavior, and can be refactored if so desired.

    Resolves part of #1

    opened by justjosias 1
  • Update for lunatic 0.9

    Update for lunatic 0.9

    As a software engineer trying to learn how Lunatic functions I would like this example application to be up to date So that I can learn the most up to date version of Lunatic

    opened by schtauffen 1
  • Refactor to use abstract_process macro

    Refactor to use abstract_process macro

    Refactor to use abstract_process macro

    Refactored all AbstractProcess implementations to the new abstract_process macro.

    • Removed almost all message struct definitions.
    • Updated the docstrings for the handlers.
    opened by MarkintoshZ 0
  • New messages do not show up

    New messages do not show up

    After I /join #swifted a channel, I can send a message. It doesn't show up immediately though, looks like I have to re-join to get the message to show up.

    opened by helje5 2
  • A better way to make tabs more obvious

    A better way to make tabs more obvious

    I like the concept of tabs, but it needs some polishing. It took me a while to figure out that the top words were, indeed, tabs. It doesn't help that, when you're in a channel and no one is ~speaking~ chatting, if you type "/help", then a new help tab is created, and you're taken to the help tab. A casual user like me would think that they are still in the channel, and be puzzled that anything they type is not showing. The user has to cycle through the tabs back to the channel.

    Nice project! I wish you well!

    Edit: typos.

    opened by eighthjouster 1
Owner
Lunatic
Lunatic is an Erlang inspired runtime for WebAssembly
Lunatic
A mini async telnet client.

mini-telnet A mini async telnet client.

kolapapa 15 May 5, 2022
YAC (Yac is Another Chat) is an example of Chat using WebSocket.

YAC (Yac is Another Chat) is an example of Chat using WebSocket. Because often the example you find in internet are "not so production ready", I would like to try to implement something more robust.

Tommaso Allevi 8 May 24, 2022
Super simple tokio chat server for educational purposes.

achat A collection of simple modules which showcase simple use of tasks, channels, and other tokio primitives to implement simple networking applicati

Rafael Bachmann 2 Dec 29, 2022
Basic chat example to demonstrate I/O and other rust features.

Basic chat Provides basic chat functions: create room send messages to room fetch room's messages Components STP - custom string transfer protocol lib

f3kilo 8 Jul 21, 2022
A set of Rust crates for interacting with the Matrix chat network.

Ruma – Your home in Matrix. A set of Rust crates (libraries) for interacting with the Matrix chat network. website • chat • documentation (unstable) G

Ruma 441 Dec 26, 2022
DNS Server written in Rust for fun, see https://dev.to/xfbs/writing-a-dns-server-in-rust-1gpn

DNS Fun Ever wondered how you can write a DNS server in Rust? No? Well, too bad, I'm telling you anyways. But don't worry, this is going to be a fun o

Patrick Elsen 26 Jan 13, 2023
A Markov chain based Discord chat bot.

A Markov chain based Discord chat bot. Building It is recommended to use cargo.

Dominik Miedziński 1 Dec 26, 2021
🤖 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
A tool for defining and running multi-container Docker applications

Ikki Ikki is a tool for defining and running multi-container Docker applications. It is similar to Docker Compose but comes with some differences. Goa

Kirill Vasiltsov 39 Dec 21, 2022
Dav-server-rs - Rust WebDAV server library. A fork of the webdav-handler crate.

dav-server-rs A fork of the webdav-handler-rs project. Generic async HTTP/Webdav handler Webdav (RFC4918) is defined as HTTP (GET/HEAD/PUT/DELETE) plu

messense 30 Dec 29, 2022
axum-server is a hyper server implementation designed to be used with axum framework.

axum-server axum-server is a hyper server implementation designed to be used with axum framework. Features Conveniently bind to any number of addresse

null 79 Jan 4, 2023
Jex Compiler Server - Server that runs Jex code

Server that compiles and runs Jex code.

furetur 3 Nov 18, 2021
A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems.

x-server-stats A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems. x-server(in x-serv

Pratyaksh 11 Oct 17, 2022
QUIC proxy that allows to use QUIC to connect to an SSH server without needing to patch the client or the server.

quicssh-rs ?? quicssh-rs is a QUIC proxy that allows to use QUIC to connect to an SSH server without needing to patch the client or the server. quicss

Jun Ouyang 18 May 5, 2023
Network Block Storage server, written in Rust. Supports pluggable and chainable underlying storage

nbd-rs Disclaimer DO NEVER USE THIS FOR PRODUCTION Do not use this for any data that you cannot afford to lose any moment. Expect data loss, corruptio

Rainlab Inc 10 Sep 30, 2022
An online version of the popular game four in a row, written in Rust on the server side and Flutter + Dart on the client.

Four in a Row - Server An online version of the popular game four in a row, written in Rust on the server side and Flutter + Dart on the client. Downl

Filippo Orrù 8 Sep 16, 2022
A primitive DNS server written in Rust for fun.

vòdo A primitive DNS server written in Rust for fun. @lucavallin ➜ /workspaces/vodo (main) $ ./target/debug/vodo -h A primitive DNS server written in

Luca Cavallin 3 Jul 27, 2023
RDE1 (Rusty Data Exfiltrator) is client and server tool allowing auditor to extract files from DNS and HTTPS protocols written in Rust. 🦀

Information: RDE1 is an old personal project (end 2022) that I didn't continue development on. It's part of a list of projects that helped me to learn

Quentin Texier (g0h4n) 32 Oct 6, 2023
A simple tcp server that written in rustlang

rust_tcp A simple tcp server that written in rustlang How to build In the root dir cargo run Then you can do a test by using telnet as a client telne

null 1 Oct 25, 2021