Skip to content

Commit 616f6f1

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

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ void NotificationEngine::apply( Framebuffer &fb ) const
216216

217217
double since_heard = (double)(now - last_word_from_server) / 1000.0;
218218
double since_ack = (double)(now - last_acked_state) / 1000.0;
219-
const char server_message[] = "contact";
220-
const char reply_message[] = "reply";
219+
const char server_message[] = "contact with";
220+
const char reply_message[] = "reply from";
221221

222222
double time_elapsed = since_heard;
223223
const char *explanation = server_message;
@@ -235,17 +235,17 @@ void NotificationEngine::apply( Framebuffer &fb ) const
235235
return;
236236
}
237237
if ( message.empty() && time_expired ) {
238-
swprintf( tmp, 128, L"mosh: Last %s %s ago.%s", explanation,
238+
swprintf( tmp, 128, L"mosh: Last %s %s %s ago.%s", explanation, server_addr.c_str(),
239239
human_readable_duration( static_cast<int>( time_elapsed ),
240240
"seconds" ).c_str(),
241241
keystroke_str );
242242
} else if ( (!message.empty()) && (!time_expired) ) {
243243
swprintf( tmp, 128, L"mosh: %ls%s", message.c_str(), keystroke_str );
244244
} else {
245-
swprintf( tmp, 128, L"mosh: %ls (%s without %s.)%s", message.c_str(),
245+
swprintf( tmp, 128, L"mosh: %ls (%s without %s %s.)%s", message.c_str(),
246246
human_readable_duration( static_cast<int>( time_elapsed ),
247247
"s" ).c_str(),
248-
explanation, keystroke_str );
248+
explanation, server_addr.c_str(), keystroke_str );
249249
}
250250

251251
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)