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:

Issues
  • 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 mtcw99 1
Releases(v0.2.0)
  • 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)

C to Rust translator

Corrode: Automatic semantics-preserving translation from C to Rust This program reads a C source file and prints an equivalent module in Rust syntax.

Jamey Sharp 2.1k Jun 11, 2021
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

Jeff Zhao 6 May 26, 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 56 Jun 9, 2021
transmute-free Rust library to work with the Arrow format

Arrow2: Transmute-free Arrow This repository contains a Rust library to work with the Arrow format. It is a re-write of the official Arrow crate using

Jorge Leitao 69 Jun 16, 2021
This is an implementation defining standard for client-side-validation

Client-side-validation Foundation Libraries This is an implementation defining standard of client-side-validation representing a set of its Foundation

LNP/BP Association 3 May 14, 2021
PartiQL libraries and tools in Rust.

This is a collection of crates to provide Rust support for the PartiQL query language.

null 12 Jun 15, 2021
A stack-allocated box that stores trait objects.

This crate allows saving DST objects in the provided buffer. It allows users to create global dynamic objects on a no_std environment without a global allocator.

Aleksey Sidorov 3 May 27, 2021
Strongly typed routes for Rust

routetype This repository is a work in progress, experimental exploration of strongly typed routing in Rust. It follows my previous work with Yesod in

Michael Snoyman 22 Jun 14, 2021
Keep your dependencies up-to-date

Deps.rs - Dependency status at a glance Deps.rs is a service that shows you at a glance if any of your dependencies are out of date or insecure. This

deps.rs 261 Jun 3, 2021
A high level diffing library for rust based on diffs

Similar: A Diffing Library Similar is a dependency free crate for Rust that implements different diffing algorithms and high level interfaces for it.

Armin Ronacher 402 Jun 12, 2021
Command line interface to manage clipboard

cb Command line interface to manage clipboard How to install Pre-Compiled you can download a pre-compiled executable, then you should copy that execut

Navid 52 Jun 1, 2021
[DEPRECATED] password manager thing

NOTE: this is pretty much abandoned, I recommend Bitwarden now. There is an export command in the CLI that produces CSV suitable for import into Bitwa

null 307 Apr 6, 2021
Apache Arrow in WebAssembly

WASM Arrow This package compiles the Rust library of Apache Arrow to WebAssembly. This might be a viable alternative to the pure JavaScript library. R

Dominik Moritz 37 Jun 12, 2021
Simple color picker that lets the user create harmonic palettes with ease.

epick Simple color picker that lets the user create harmonic palettes with ease. Get it You can checkout the web demo over here or get a native binary

Wojciech Kępka 11 Jun 2, 2021