Rust implementation of the legacy Master Server Query Protocol

Overview

msq-rs

Rust library implementation of the legacy Master Server Query Protocol.

Usage

Add this to your Cargo.toml:

[dependencies]
msq = "0.2"

If you want to get straight from the latest master branch:

[dependencies]
msq = { git = "https://github.com/mtcw99/msq-rs.git" }

To get started using msq, see the Quick Start section below and take a look at the documentation (stable).

Features

By default, both async MSQClient and non-async/blocking MSQClientBlock are included. However, if you want to only include one or the other, you could do the following:

For non-async/MSQClientBlock only:

[dependencies]
msq = { version = "0.2", default-features = false, features = ["non-async"] }

For async/MSQClient only:

[dependencies]
msq = { version = "0.2", default-features = false, features = ["async"] }

Quick Start

use msq::{MSQClient, Region, Filter};
use std::io::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Startup the client
    let mut client = MSQClient::new().await?;

    // Connect to the master server
    client.connect("hl2master.steampowered.com:27011").await?;

    // Maximum amount of servers we wanted to query
    client.max_servers_on_query(256);

    let servers = client
        .query(Region::Europe,  // Restrict query to Europe region
            Filter::new()       // Create a Filter builder
                .appid(240)     // appid of 240 (CS:S)
                .nand()         // Start of NAND special filter
                    .map("de_dust2")     // Map is de_dust2
                    .empty(true)         // Server is empty
                .end()          // End of NAND special filter
                .gametype(&vec!["friendlyfire", "alltalk"])).await?;

    // nand filter excludes servers that has de_dust2 as
    // its map and is empty

    // nand and nor are both special filters, both closed by
    // using the end method

    Ok(())
}

Blocking/Non-Async version

If you don't want to use async, then a blocking version is available. The methods functionalities and names should matches its async counterpart.

use msq::{MSQClientBlock, Region, Filter};
use std::io::Result;

fn main() -> Result<()> {
    let mut client = MSQClientBlock::new()?;
    client.connect("hl2master.steampowered.com:27011")?;
    client.max_servers_on_query(256);

    let servers = client
        .query(Region::Europe,  // Restrict query to Europe region
            Filter::new()       // Create a Filter builder
                .appid(240)     // appid of 240 (CS:S)
                .nand()         // Start of NAND special filter
                    .map("de_dust2")     // Map is de_dust2
                    .empty(true)         // Server is empty
                .end()          // End of NAND special filter
                .gametype(&vec!["friendlyfire", "alltalk"]))?;
    Ok(())
}

API Changes

From v0.1.X to v0.2.X

  • REMOVED: msq::region and msq::filter modules are no longer exposed. Just use msq::Region enum and msq::Filter struct directly.
  • REPLACED: as_string replaces as_str in msq::Filter
  • NEW: single_query method in msq::MSQClient and msq::MSQClientBlock to do a single query in one function
  • NEW: msq::MSQClientBlock for a non-async version
  • NEW: Can now define features async and non-async. Both are enabled by default.

License

msq-rs is released under the MIT License

Dependencies

Misc

The following library goes well with this one:

You might also like...
PM-Tools - a simple Rust util to easily create server directories

PM-Tools PM-Tools is a simple Rust util to easily create server directories or plugins without the hassle of unzipping or creating directories Progres

An ActivityPub home server written in Rust, implementing the Mastodon API.

Tafarn An ActivityPub home server written in Rust, implementing the Mastodon API. At present no web UI is provided, the API is the only way to interac

An MVP-worthy background job server for PostgreSQL, written in Rust
An MVP-worthy background job server for PostgreSQL, written in Rust

Pointguard An MVP-worthy background job server for PostgreSQL, written in Rust A simple background job server (database) on top of PostgreSQL, that ca

client-server notification center for dbus desktop notifications

tsuchita A client-server notification center for dbus desktop notifications. Specifically org.freedesktop.Notifications dbus messages. Motivation I ju

Simple fake AWS Cognito User Pool API server for development.

Fakey Cognito 🏡 Homepage Simple fake AWS Cognito API server for development. ✅ Implemented features AdminXxx on User Pools API. Get Started # run wit

A custom invoke system for Tauri that leverages a localhost server

Tauri Invoke HTTP This is a crate that provides a custom invoke system for Tauri using a localhost server. Each message is delivered through a XMLHttp

Build your service-server fast, easy (and without hosting!)
Build your service-server fast, easy (and without hosting!)

service-io is a library to build servers that offering services with really little effort. Choose an input connector. Choose an output connector. Choo

A stupidly simple and easy to self-host, personal server for file hosting on the web
A stupidly simple and easy to self-host, personal server for file hosting on the web

Grasswave CDN A stupidly simple and easy to self-host, personal server for file hosting on the web. Written in Rust. Thanks, @Maciejowski, for the sty

tree-sitter server for kakoune

tree-sitter.kak Warning This currently just a proof-of-concept, and isn't stable yet. A Tree-sitter server that keeps parsed ASTs in memory. This is u

Comments
  • Improve documentation

    Improve documentation

    I am trying to use the library on Linux. It complies successfully but it doesn't seem to work. It just gets stuck here. It works fine on Windows so I assume this might be a bug with the library since I don't wee a reason why this wouldn't work.

    https://gitlab.com/dhalucario/tf2-cqp/-/blob/devel/linux/src/casual_quickplay_controller.rs#L70

    documentation 
    opened by dhalucario 5
  • Filter nor in combination with gametype does not seem to work

    Filter nor in combination with gametype does not seem to work

    I am trying to make a blacklist for all the tags that are in the blacklist Vec. Putting it into a nor does not seem to blacklist the tags in the gametype.

    The gameservers I get returned contain whatever is in the second gametype but of in the first call. Am I misunderstanding something here or is this an issue?

        Filter::new()
            .appid(440)
            .gametype(!vec["cp"])
            .nor()
            .gametype(!vec["alltalk"])
            .end();
    
    opened by dhalucario 2
  • Non-async functions/methods support

    Non-async functions/methods support

    • [x] Provide a non-async alternative methods relative to their respective async counter-part.
    • [x] Allow the library user to set a feature flag to want async, non-async, or both
    enhancement 
    opened by nullsystem 1
Releases(v0.2.1)
  • v0.2.1(Mar 19, 2022)

    API and dependency Changes

    From v0.2.0 to v0.2.1

    • Reduced tokio dependency
    • msq::Region::from_u8 turns given byte into Region enum

    Documentation

    • Fixed to using current username
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(May 24, 2021)

    API Changes

    From v0.1.X to v0.2.X

    • REMOVED: msq::region and msq::filter modules are no longer exposed. Just use msq::Region enum and msq::Filter struct directly.
    • REPLACED: as_string replaces as_str in msq::Filter
    • NEW: single_query method in msq::MSQClient and msq::MSQClientBlock to do a single query in one function
    • NEW: msq::MSQClientBlock for a non-async version
    • NEW: Can now define features async and non-async. Both are enabled by default.

    Documentation

    • Documentation has improved over v0.1.1, should include more examples and useful information

    https://github.com/mtcw99/msq-rs/milestone/1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(May 5, 2021)

Language Integrated Query in Rust.

Linq in Rust Language Integrated Query in Rust (created by declarative macros). Inspired by LINQ in .NET. What's LINQ This project is under developmen

StardustDL 91 Dec 8, 2022
A program written in pure Rust to query music info from mpd and display it in a notification.

musinfo A program written in pure Rust to query music info from mpd and display it in a notification. Note: Cover art is expected to be placed at /tmp

Cpt.Howdy 10 Aug 16, 2022
A rust implementation of the reverse-engineered Glorious mouse protocol

gloryctl This project is an implementation of the vendor-specific HID protocol in use by Glorious mice used to configure parameters such as DPI profil

Samuel Čavoj 6 Oct 17, 2022
Yjs/Yrs sync protocol implementation

Yjs/Yrs sync protocol implementation This crate comes with the default implementation of Yjs/Yrs synchronization protocol - it's shared between the pr

null 7 Dec 17, 2022
An implementation of the SMP protocol as used in zephyr, mcuboot, mcumgr, and more.

SMP An implementation of the SMP protocol in pure Rust. This repository contains: ./mcumgr-smp: A SMP library implementation to be used in your own pr

Gessler GmbH 3 Dec 10, 2023
An unofficial and incomplete no_std Rust library for implementing the ElectricUI Binary Protocol

An unofficial and incomplete no_std Rust library for implementing the ElectricUI Binary Protocol

Jon 2 Mar 29, 2022
Traction is a protocol for issuing American options on Solana.

Traction is a protocol for issuing American options on Solana.

TractionDAO 5 Jun 5, 2022
Noir Pay - Fork of the Light Protocol Program for local testing / optimisation.

Noir Pay v0 Built on Light Protocol Noir Pay will be directly built ontop of the Light Protocol SDK and provide users with a beautifully simple privat

0xNico 1 Feb 12, 2022
Melnet2: Themelio's peer-to-peer protocol

melnet2: Themelio's peer-to-peer protocol melnet2 is Themelio's peer-to-peer protocol. It is an overlay network that can be built over any nanorpc tra

Themelio 2 Sep 13, 2022
This is the github repo for the Spot Lite protocol.

spot-contract This is the github repo for the Spot Lite protocol. Set up local Sei Please follow the documentation on the official Sei doc to set up y

nick 3 Nov 8, 2023