Skip to content

Commit e70a888

Browse files
committed
Show server IP on timeout banner
1 parent b1da700 commit e70a888

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/frontend/stmclient.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ void STMClient::init( void )
192192
wstring escape_key_name = std::wstring(tmp.begin(), tmp.end());
193193
escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name;
194194
overlays.get_notification_engine().set_escape_key_string( tmp );
195+
overlays.get_notification_engine().server_address( ip );
195196
}
196197
wchar_t tmp[ 128 ];
197198
swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() );

src/frontend/terminaloverlay.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ void ConditionalCursorMove::apply( Framebuffer &fb, uint64_t confirmed_epoch ) c
159159
NotificationEngine::NotificationEngine()
160160
: last_word_from_server( timestamp() ),
161161
last_acked_state( timestamp() ),
162+
server_addr(),
162163
escape_key_string(),
163164
message(),
164165
message_is_network_error( false ),
@@ -216,8 +217,8 @@ void NotificationEngine::apply( Framebuffer &fb ) const
216217

217218
double since_heard = (double)(now - last_word_from_server) / 1000.0;
218219
double since_ack = (double)(now - last_acked_state) / 1000.0;
219-
const char server_message[] = "contact";
220-
const char reply_message[] = "reply";
220+
const char server_message[] = "contact with";
221+
const char reply_message[] = "reply from";
221222

222223
double time_elapsed = since_heard;
223224
const char *explanation = server_message;
@@ -235,17 +236,17 @@ void NotificationEngine::apply( Framebuffer &fb ) const
235236
return;
236237
}
237238
if ( message.empty() && time_expired ) {
238-
swprintf( tmp, 128, L"mosh: Last %s %s ago.%s", explanation,
239+
swprintf( tmp, 128, L"mosh: Last %s %s %s ago.%s", explanation, server_addr.c_str(),
239240
human_readable_duration( static_cast<int>( time_elapsed ),
240241
"seconds" ).c_str(),
241242
keystroke_str );
242243
} else if ( (!message.empty()) && (!time_expired) ) {
243244
swprintf( tmp, 128, L"mosh: %ls%s", message.c_str(), keystroke_str );
244245
} else {
245-
swprintf( tmp, 128, L"mosh: %ls (%s without %s.)%s", message.c_str(),
246+
swprintf( tmp, 128, L"mosh: %ls (%s without %s %s.)%s", message.c_str(),
246247
human_readable_duration( static_cast<int>( time_elapsed ),
247248
"s" ).c_str(),
248-
explanation, keystroke_str );
249+
explanation, server_addr.c_str(), keystroke_str );
249250
}
250251

251252
wstring string_to_draw( tmp );

src/frontend/terminaloverlay.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ namespace Overlay {
141141
private:
142142
uint64_t last_word_from_server;
143143
uint64_t last_acked_state;
144+
string server_addr;
144145
string escape_key_string;
145146
wstring message;
146147
bool message_is_network_error;
@@ -157,6 +158,7 @@ namespace Overlay {
157158
const wstring &get_notification_string( void ) const { return message; }
158159
void server_heard( uint64_t s_last_word ) { last_word_from_server = s_last_word; }
159160
void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; }
161+
void server_address( const std::string &addr ) { server_addr = addr; }
160162
int wait_time( void ) const;
161163

162164
void set_notification_string( const wstring &s_message, bool permanent = false, bool s_show_quit_keystroke = true )

0 commit comments

Comments
 (0)