void telnet_do(int code) { switch(code) { case 90: if (msp_active) { if (msp_debug) { previous_object()->message("Your client told us to enable MSP but we're already doing it O_O.\n"); } /* ignore */ } else if (msp_pending) { if (msp_debug) { previous_object()->message("Your client granted us permission to enable MSP :).\n"); } msp_active = 1; msp_pending = 0; } else { if (msp_debug) { previous_object()->message("Your client told us to enable MSP :).\n"); } query_conn()->send_will(90); msp_active = 1; } break; default: if (general_debug) { previous_object()->message("Your client sent a request for unknown telnet option " + code + ", refusing.\n"); } query_conn()->send_wont(code); } }
void set_mode(int new_mode) { object conn; ACCESS_CHECK(previous_program() == LIB_CONN || SYSTEM() || calling_object() == this_object()); if (!this_object() || !query_conn() || new_mode == MODE_NOCHANGE) { return; } /* we have to do it this way because set_mode is also called to handle return values for hooks in the user object */ /* this can happen more than once in a connection chain, so we need to intercept disconnects and do them */ /* in a 0 callout to avoid double destruction */ /* since network events are asynchronous anyway we aren't causing any actual harm */ if (new_mode == MODE_DISCONNECT) { query_conn()->set_mode(MODE_BLOCK); conn::close(nil, 1); call_out("self_disconnect", 0); return; } query_conn()->set_mode(new_mode); }
void disable_msp() { query_conn()->send_wont(90); msp_pending = 0; msp_active = 0; }
void telnet_will(int code) { switch(code) { default: if (general_debug) { previous_object()->message("Your client sent an offer for unknown telnet option " + code + ", forbidding.\n"); } query_conn()->send_dont(code); } }
void telnet_dont(int code) { switch(code) { case 90: if (msp_active) { if (msp_debug) { previous_object()->message("Your client disabled MSP :(.\n"); } query_conn()->send_wont(code); msp_active = 0; } else if (msp_pending) { if (msp_debug) { previous_object()->message("Your client forbade MSP :(.\n"); } msp_pending = 0; } break; } }
void enable_msp() { msp_pending = 1; query_conn()->send_will(90); }