Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set nicknames for individual subscribers #19

Merged
merged 5 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ types:
| 1 | Zone |
| 2 | Chat |


For the `Debug` OP, the CHANNEL 9000 indicates the `HELLO` CHANNEL.

### Data

For payloads with OP `Debug`, the payload is simply debug-logged.
Expand All @@ -117,8 +120,25 @@ CHANNEL.

### Debug OP

Any payload sent with the `Debug` OP will be simply be debug-logged and an `OK`
response will be sent back to the requesting subscriber.
Any payload sent with the `Debug` OP with a CHANNEL other than `HELLO` will be
simply be debug-logged and an `OK` response will be sent back to the requesting
subscriber.

For payloads with the `Debug` OP and the `HELLO` channel, the DATA sent will
be set as the nickname for the current subscriber.

These are the restrictions on the values of nickname that are accepted:
- The bytes in DATA must be valid UTF-8.
- Must contain only ASCII alphanumeric characters or underscores (`^[A-Za-z0-9_]+$`)
- Must be 30 characters or less
- Names are allowed to be the same as other subscribers.

For example:
```c
Payload { OP: OP.Debug, CHANNEL: 9000, DATA: u8"TEST_CLIENT" }
// Deucalion: Nickname set response
Payload { OP: OP.Debug, CHANNEL: 9000, DATA: u8"CHANGED NICKNAME: TEST_CLIENT (subscriber 0)" }
```

### Ping OP

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const SEND_SIG: &str = "E8 $ { ' } 8B 53 2C 48 8D 8B";
const SEND_LOBBY_SIG: &str = "40 53 48 83 EC 20 44 8B 41 28";

fn handle_payload(payload: rpc::Payload, hs: Arc<hook::State>) -> Result<()> {
info!("Received payload from subscriber: {:?}", payload);
if payload.op == rpc::MessageOps::Recv || payload.op == rpc::MessageOps::Send {
let hook_type = match payload.op {
rpc::MessageOps::Recv => hook::HookType::Recv,
Expand Down Expand Up @@ -148,7 +147,7 @@ async fn main_with_result() -> Result<()> {
drop(shutdown_tx);
info!("Shutting down broadcast loop...");
msg_loop_handle.await?;
info!("Shut down!");
info!("Shutting down...");
Ok(())
}

Expand Down Expand Up @@ -189,7 +188,7 @@ fn logging_setup() -> Result<()> {

#[cfg(debug_assertions)]
{
let _ = CombinedLogger::init(vec![
CombinedLogger::init(vec![
SimpleLogger::new(LevelFilter::Debug, simplelog::Config::default()),
WriteLogger::new(LevelFilter::Debug, simplelog::Config::default(), log_file),
])?;
Expand Down Expand Up @@ -220,6 +219,7 @@ unsafe extern "system" fn main(dll_base_addr: LPVOID) -> u32 {
error!("Panic happened: {:?}", cause);
pause();
}
info!("Shut down!");
#[cfg(debug_assertions)]
wincon::FreeConsole();
libloaderapi::FreeLibraryAndExitThread(dll_base_addr as HMODULE, 0);
Expand Down
Loading