Giter VIP home page Giter VIP logo

ydx-2147483647 / bitsrun-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spencerwooo/bitsrun-rs

0.0 0.0 0.0 140 KB

๐ŸŒ A headless login / logout CLI for 10.0.0.55 at BIT, now in Rust. ๅŒ—ไบฌ็†ๅทฅๅคงๅญฆ 10.0.0.55 ๆ กๅ›ญ็ฝ‘็™ปๅฝ•็™ปๅ‡บ็š„ Rust ๅฎž็Žฐ

Home Page: https://crates.io/crates/bitsrun

License: MIT License

Shell 19.60% Rust 80.40%

bitsrun-rs's Introduction

bitsrun

GitHub Workflow Status (CI) GitHub Workflow Status (Release) GitHub release Crates.io

๐ŸŒ A headless login and logout CLI for 10.0.0.55 at BIT, now in Rust.

CleanShot 2023-12-04 at 16 47 26@2x

Install

One-line install (Linux / macOS, recommended)

  • curl -fsSL https://cdn.jsdelivr.net/gh/spencerwooo/bitsrun-rs@main/install.sh | sh -

Ubuntu / Debian (recommended for systemd support)

  • Download the latest .deb package from Releases.
  • sudo apt install </path/to/file>.deb

If bitsrun.service systemd service required:

  • Edit /lib/systemd/system/bitsrun.service to specify absolute config path
  • Then start service with sudo systemctl start bitsrun

Cargo

  • cargo install bitsrun

Download binary

  • Download the latest binary from Releases.
  • Uncompress file: tar -xvf <file>.tar.gz
  • Move binary to $PATH, such as: mv <file>/bitsrun ~/.local/bin/

Usage

To log into or out of the campus network, simply:

$ bitsrun login -u <username> -p <password>
bitsrun: <ip> (<username>) logged in

$ bitsrun logout -u <username>
bitsrun: <ip> logged out

To check device login status:

$ bitsrun status
bitsrun: <ip> (<username>) is online
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Traffic Used   โ”‚ Online Time   โ”‚ User Balance  โ”‚ Wallet  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 188.10 GiB     โ”‚ 2 months      โ”‚ 10.00         โ”‚ 0.00    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

To keep the session alive, use bitsrun keep-alive:

$ bitsrun keep-alive
 INFO  bitsrun::daemon > starting daemon (<username>) with polling interval=3600s
 INFO  bitsrun::daemon > <ip> (<username>): login success,
 ...
 ^C INFO  bitsrun::daemon > <username>: gracefully exiting

Note

Use available system service managers to run bitsrun keep-alive as a daemon. (e.g., systemd for Linux, launchd for macOS, and Windows Service for Windows).

Available commands

$ bitsrun --help
A headless login and logout CLI for 10.0.0.55 at BIT

Usage: bitsrun [OPTIONS] [COMMAND]

Commands:
  login         Login to the campus network
  logout        Logout from the campus network
  status        Check device login status
  config-paths  List all possible config file paths
  keep-alive    Poll the server with login requests to keep the session alive
  help          Print this message or the help of the given subcommand(s)

Options:
  -v, --verbose  Verbose output
  -h, --help     Print help
  -V, --version  Print version

Tip

Use environment variable NO_COLOR=true to disable colored output.

Config and credentials

To save your credentials and configurations, create config file bit-user.json under an available config path as:

{
  "username": "<username>",
  "password": "<password>",
  "dm": true,
  "poll_interval": 3600
}
  • dm is for specifying whether the current device is a dumb terminal, and requires logging out through the alternative endpoint. Set to true (no quotes!) if the device you are working with is a dumb terminal.
  • poll_interval is an optional field for specifying the interval (in seconds) of polling login requests. Default is 3600 seconds (1 hour). Used by bitsrun keep-alive only.

Available config file paths can be listed with:

$ bitsrun config-paths
bitsrun: list of possible config paths
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Priority โ”‚ Possible Config Path                                        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1        โ”‚ /Users/spencerwoo/.config/bit-user.json                     โ”‚
โ”‚ 2        โ”‚ /Users/spencerwoo/.config/bitsrun/bit-user.json             โ”‚
โ”‚ 3        โ”‚ /Users/spencerwoo/Library/Preferences/bitsrun/bit-user.json โ”‚
โ”‚ 4        โ”‚ bit-user.json                                               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Note

The config file location is OS-dependent. Run the command to check the accepted locations on your system.

Set permissions of this file to 600 on Linux and macOS, or bitsrun will refuse to read it.

$ chmod 600 <path/to/bit-user.json>

Related

  • zu1k/srun - Srun authentication system login tools. (Rust)
  • Mmx233/BitSrunLoginGo - ๆทฑๆพœๆ กๅ›ญ็ฝ‘็™ปๅฝ•่„šๆœฌ Go ่ฏญ่จ€็‰ˆ (Go)
  • vouv/srun - An efficient client for BIT campus network. (Go)
  • BITNP/bitsrun - A headless login / logout script for 10.0.0.55 at BIT. (Python)

License

MIT

bitsrun-rs's People

Contributors

spencerwooo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.