[-]
[+]
|
Deleted |
_service:tar_git:mosh.changes
|
@@ -1,3 +0,0 @@
-* Mon Sep 16 2013 Marko Saukko <marko.saukko@jollamobile.com> - 1.2.4
-- [packaging] Package version 1.2.4 of mosh.
-
|
[-]
[+]
|
Changed |
_service:tar_git:mosh.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,8 +1,8 @@
<services>
<service name="tar_git">
- <param name="url">https://github.com/nemomobile-packages/mosh.git</param>
+ <param name="url">https://github.com/tigeli/mosh.git</param>
<param name="branch">master</param>
- <param name="revision">f8ef11bd4b76abadf7cad4bfe2e9192a33831a4d</param>
+ <param name="revision">50692dd65063581cef831c186da1001737ed7e62</param>
</service>
</services>
|
[-]
[+]
|
Deleted |
_service:tar_git:mosh-1.2.4.tar.xz/mosh/conf/bash_completion.d/mosh
^
|
@@ -1 +0,0 @@
-complete -F _known_hosts mosh
|
[-]
[+]
|
Deleted |
_service:tar_git:mosh-1.2.4.tar.xz/mosh/scripts/mosh
^
|
@@ -1,308 +0,0 @@
-#!/usr/bin/env perl
-
-# Mosh: the mobile shell
-# Copyright 2012 Keith Winstein
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# In addition, as a special exception, the copyright holders give
-# permission to link the code of portions of this program with the
-# OpenSSL library under certain conditions as described in each
-# individual source file, and distribute linked combinations including
-# the two.
-#
-# You must obey the GNU General Public License in all respects for all
-# of the code used other than OpenSSL. If you modify file(s) with this
-# exception, you may extend this exception to your version of the
-# file(s), but you are not obligated to do so. If you do not wish to do
-# so, delete this exception statement from your version. If you delete
-# this exception statement from all source files in the program, then
-# also delete it here.
-
-my $MOSH_VERSION = '1.2.4';
-
-use warnings;
-use strict;
-use Socket;
-use Getopt::Long;
-
-$|=1;
-
-my $client = 'mosh-client';
-my $server = 'mosh-server';
-
-my $predict = undef;
-
-my $port_request = undef;
-
-my $ssh = 'ssh';
-
-my $term_init = 1;
-
-my $help = undef;
-my $version = undef;
-
-my @cmdline = @ARGV;
-
-my $usage =
-qq{Usage: $0 [options] [--] [user@]host [command...]
- --client=PATH mosh client on local machine
- (default: "mosh-client")
- --server=COMMAND mosh server on remote machine
- (default: "mosh-server")
-
- --predict=adaptive local echo for slower links [default]
--a --predict=always use local echo even on fast links
--n --predict=never never use local echo
- --predict=experimental aggressively echo even when incorrect
-
--p PORT[:PORT2]
- --port=PORT[:PORT2] server-side UDP port or range
-
- --ssh=COMMAND ssh command to run when setting up session
- (example: "ssh -p 2222")
- (default: "ssh")
-
- --no-init do not send terminal initialization string
-
- --help this message
- --version version and copyright information
-
-Please report bugs to mosh-devel\@mit.edu.
-Mosh home page: http://mosh.mit.edu\n};
-
-my $version_message = qq{mosh $MOSH_VERSION
-Copyright 2012 Keith Winstein <mosh-devel\@mit.edu>
-License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
-This is free software: you are free to change and redistribute it.
-There is NO WARRANTY, to the extent permitted by law.\n};
-
-sub predict_check {
- my ( $predict, $env_set ) = @_;
-
- if ( not exists { adaptive => 0, always => 0,
- never => 0, experimental => 0 }->{ $predict } ) {
- my $explanation = $env_set ? " (MOSH_PREDICTION_DISPLAY in environment)" : "";
- print STDERR qq{$0: Unknown mode \"$predict\"$explanation.\n\n};
-
- die $usage;
- }
-}
-
-GetOptions( 'client=s' => \$client,
- 'server=s' => \$server,
- 'predict=s' => \$predict,
- 'port=s' => \$port_request,
- 'a' => sub { $predict = 'always' },
- 'n' => sub { $predict = 'never' },
- 'p=s' => \$port_request,
- 'ssh=s' => \$ssh,
- 'init!' => \$term_init,
- 'help' => \$help,
- 'version' => \$version,
- 'fake-proxy!' => \my $fake_proxy ) or die $usage;
-
-die $usage if ( defined $help );
-die $version_message if ( defined $version );
-
-if ( defined $predict ) {
- predict_check( $predict, 0 );
-} elsif ( defined $ENV{ 'MOSH_PREDICTION_DISPLAY' } ) {
- $predict = $ENV{ 'MOSH_PREDICTION_DISPLAY' };
- predict_check( $predict, 1 );
-} else {
- $predict = 'adaptive';
- predict_check( $predict, 0 );
-}
-
-if ( defined $port_request ) {
- if ( $port_request =~ m{^(\d+)(:(\d+))?$} ) {
- my ( $low, $clause, $high ) = ( $1, $2, $3 );
- # good port or port-range
- if ( $low <= 0 or $low > 65535 ) {
- die "$0: Server-side (low) port ($low) must be within valid range [1..65535].\n";
- }
- if ( defined $high ) {
- if ( $high <= 0 or $high > 65535 ) {
- die "$0: Server-side high port ($high) must be within valid range [1..65535].\n";
- }
- if ( $low > $high ) {
- die "$0: Server-side port range ($port_request): low port greater than high port.\n";
- }
- }
- } else {
- die "$0: Server-side port or range ($port_request) is not valid.\n";
- }
-}
-
-delete $ENV{ 'MOSH_PREDICTION_DISPLAY' };
-
-if ( defined $fake_proxy ) {
- use Errno qw(EINTR);
- use IO::Socket::INET;
- use POSIX qw(_exit);
-
- my ( $host, $port ) = @ARGV;
-
- # Resolve hostname
- my $packed_ip = gethostbyname $host;
- if ( not defined $packed_ip ) {
- die "$0: Could not resolve hostname $host\n";
- }
- my $ip = inet_ntoa $packed_ip;
-
- print STDERR "MOSH IP $ip\n";
-
- # Act like netcat
- my $sock = IO::Socket::INET->new( PeerAddr => $ip,
- PeerPort => $port,
- Proto => "tcp" )
- or die "$0: connect to host $ip port $port: $!\n";
- binmode($sock);
- binmode(STDIN);
- binmode(STDOUT);
-
- sub cat {
- my ( $from, $to ) = @_;
- while ( my $n = $from->sysread( my $buf, 4096 ) ) {
- next if ( $n == -1 && $! == EINTR );
- $n >= 0 or last;
- $to->write( $buf ) or last;
- }
- }
-
- defined( my $pid = fork ) or die "$0: fork: $!\n";
- if ( $pid == 0 ) {
- cat $sock, \*STDOUT; $sock->shutdown( 0 );
- _exit 0;
- }
- $SIG{ 'HUP' } = 'IGNORE';
- cat \*STDIN, $sock; $sock->shutdown( 1 );
- waitpid $pid, 0;
- exit;
-}
-
-if ( scalar @ARGV < 1 ) {
- die $usage;
-}
-
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/.gitignore
^
|
@@ -12,6 +12,7 @@
/aclocal.m4
/ar-lib
/autom4te.cache
+/compile
/config.h
/config.h.in
/config.h.in~
@@ -23,3 +24,7 @@
/missing
/mosh-*.tar.gz
/stamp-h1
+/test-driver
+/VERSION
+/scripts/mosh
+/version.h
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/AUTHORS
^
|
@@ -3,3 +3,4 @@
Quentin Smith
Richard Tibbetts
Keegan McAllister
+John Hood
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/ChangeLog
^
|
@@ -1,3 +1,51 @@
+2015-07-12 Keith Winstein <mosh-devel@mit.edu>
+
+ * Version 1.2.5 released.
+
+ * New features:
+ * Bind to a specific IP address with --bind-server. (Philipp
+ Haselwarter)
+ * MOSH_ESCAPE_KEY configures escape character. (Timo
+ J. Rinne)
+ * Support non-roaming IPv6. (Anders Kaseorg)
+ * Implement XTerm mouse mode. (Barosl LEE, Andrew Chin,
+ Louis Kruger)
+ * Report Git revision along with version if available.
+ (John Hood)
+
+ * Platform support:
+ * Add pselect() emulation. (Jérémie Courrèges-Anglas)
+ * OpenBSD, OS X: Fix be64toh-related issues. (Jérémie
+ Courrèges-Anglas)
+ * ARM Neon: fix gcc4.8 compiling problem(Pasi Sjöholm)
+ * NaCl: Conditionally rename main to mosh_main. (Richard
+ Woodbury)
+ * FreeBSD: Token pasting, forkpty(), ARM fixes. (John Hood)
+ * AIX: Implement CTTY grabbing when TIOCSCTTY is missing
+ (Anton Lundin)
+ * OS X: Broaden build support to cover OS X 10.5 through
+ 10.10. (John Hood)
+ * Debian: Improve bash-completion install and
+ functionality. (Suggested by Gabriel Filion, John Hood)
+
+ * Bug fixes:
+ * Automake/autoconf workarounds. (Anders Kaseorg)
+ * mosh-server: Allow startup without PTY. (Keith Winstein)
+ * network.cc: Properly close old fd on Socket assignment
+ operator. (Thanks to Igor Bukanov)
+ * mosh-server: Allow startup with zero-window-size PTY.
+ (Igor Bukanov)
+ * AddrInfo: Fix error message generation when node == NULL
+ (Anders Kaseorg)
+ * Timestamp: Prevent integer overflow on Darwin PPC 32-bit
+ (Anders Kaseorg)
+ * scripts/mosh: Fix hang when remote closes the connection
+ (Anders Kaseorg)
+ * Fix issues with parsing of 256-color SGR sequences.
+ (John Hood)
+ * Numerous code hygiene, Coverity, and Clang static analyzer
+ fixes. (Anders Kaseorg, Geoffrey Thomas, John Hood)
+
2013-03-27 Keith Winstein <mosh-devel@mit.edu>
* Version 1.2.4 released.
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/Makefile.am
^
|
@@ -1,3 +1,44 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src scripts man conf
EXTRA_DIST = autogen.sh ocb-license.html README.md COPYING.iOS
+BUILT_SOURCES = version.h
+CLANG_SCAN_BUILD = scan-build
+
+.PHONY: VERSION
+
+VERSION:
+ @echo @PACKAGE_STRING@ > VERSION.dist
+ @set -e; if git describe --dirty --always > VERSION.git 2>&1 && \
+ [ -z `git rev-parse --show-prefix` ]; then \
+ if ! diff -q VERSION.git VERSION > /dev/null 2>&1; then \
+ mv -f VERSION.git VERSION; \
+ fi; \
+ elif ! diff -q VERSION.dist VERSION > /dev/null 2>&1; then \
+ mv -f VERSION.dist VERSION; \
+ fi
+ @rm -f VERSION.dist VERSION.git
+
+version.h: VERSION
+ @printf '#define BUILD_VERSION "%s"\n' "$$(cat VERSION)" > version.h.new
+ @set -e; if ! diff -q version.h version.h.new > /dev/null 2>&1; then \
+ mv -f version.h.new version.h; \
+ fi
+ @rm -f version.h.new
+
+clean-local:
+ @rm -rf version.h VERSION cov-int mosh-coverity.txz
+
+cppcheck: $(BUILT_SOURCES) config.h
+ cppcheck --enable=all --template=gcc -include config.h -I . \
+ -I src/crypto -I src/frontend -I src/network -I src/protobufs \
+ -I src/statesync -I src/terminal -I src/util \
+ -I /usr/include -I /usr/include/google/protobuf -I/usr/include/openssl \
+ .
+
+cov-build: $(BUILT_SOURCES) config.h
+ $(MAKE) clean && rm -rf cov-int && \
+ cov-build --dir cov-int $(MAKE) check && \
+ tar -caf mosh-coverity.txz cov-int
+
+scan-build: $(BUILT_SOURCES) config.h
+ $(MAKE) clean && $(CLANG_SCAN_BUILD) $(MAKE) check
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/THANKS
^
|
@@ -66,3 +66,23 @@
* Luke Mewburn
* Anton Lundin
+
+* Philipp Haselwarter
+
+* Timo J. Rinne
+
+* Barosl Lee
+
+* Andrew Chin
+
+* Louis Kruger
+
+* Jérémie Courrèges-Anglas
+
+* Pasi Sjöholm
+
+* Richard Woodbury
+
+* Igor Bukanov
+
+* Geoffrey Thomas
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/conf/Makefile.am
^
|
@@ -1,3 +1,5 @@
+completionsdir = @completions@
+dist_completions_DATA =
nobase_dist_sysconf_DATA =
if INSTALL_UFW
@@ -5,5 +7,5 @@
endif
if INSTALL_COMPLETION
- nobase_dist_sysconf_DATA += bash_completion.d/mosh
+ dist_completions_DATA += bash-completion/completions/mosh
endif
|
[-]
[+]
|
Added |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/conf/bash-completion/completions/mosh
^
|
@@ -0,0 +1,9 @@
+_mosh () {
+ local cur prev
+
+ _init_completion || return
+
+ _known_hosts_real -a "$cur"
+}
+
+complete -F _mosh mosh
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/configure.ac
^
|
@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.61])
-AC_INIT([mosh], [1.2.4], [mosh-devel@mit.edu])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AC_INIT([mosh], [1.2.5], [mosh-devel@mit.edu])
+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_SRCDIR([src/frontend/mosh-client.cc])
AC_CONFIG_MACRO_DIR([m4])
@@ -33,11 +33,11 @@
;;
maximum)
WARNING_CXXFLAGS="-Wall"
- PICKY_CXXFLAGS="-Wextra -pedantic -Wno-long-long -Weffc++"
+ PICKY_CXXFLAGS="-Wextra -pedantic -Wno-long-long -Weffc++ -Wmissing-declarations"
;;
error)
WARNING_CXXFLAGS="-Wall -Werror"
- PICKY_CXXFLAGS="-Wextra -pedantic -Wno-long-long -Weffc++"
+ PICKY_CXXFLAGS="-Wextra -pedantic -Wno-long-long -Weffc++ -Wmissing-declarations"
;;
*)
AC_MSG_ERROR([Unknown argument '$enableval' to --enable-compile-warnings])
@@ -170,7 +170,28 @@
AC_SEARCH_LIBS([inet_addr], [nsl])
# Checks for header files.
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h limits.h locale.h netinet/in.h stddef.h stdint.h inttypes.h stdlib.h string.h sys/ioctl.h sys/resource.h sys/socket.h sys/stat.h sys/time.h termios.h unistd.h wchar.h wctype.h], [], [AC_MSG_ERROR([Missing required header file.])])
+AC_CHECK_HEADERS(m4_normalize([
+ fcntl.h
+ langinfo.h
+ limits.h
+ locale.h
+ netdb.h
+ netinet/in.h
+ stddef.h
+ stdint.h
+ inttypes.h
+ stdlib.h
+ string.h
+ sys/ioctl.h
+ sys/resource.h
+ sys/socket.h
+ sys/stat.h
+ sys/time.h
+ termios.h
+ unistd.h
+ wchar.h
+ wctype.h
+ ]), [], [AC_MSG_ERROR([Missing required header file.])])
AC_CHECK_HEADERS([pty.h util.h libutil.h paths.h])
AC_CHECK_HEADERS([endian.h sys/endian.h])
@@ -195,7 +216,30 @@
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MBRTOWC
-AC_CHECK_FUNCS([gettimeofday setrlimit inet_ntoa iswprint memchr memset nl_langinfo posix_memalign setenv setlocale sigaction socket strchr strdup strncasecmp strtok strerror strtol wcwidth cfmakeraw])
+AC_CHECK_FUNCS(m4_normalize([
+ gettimeofday
+ setrlimit
+ iswprint
+ memchr
+ memset
+ nl_langinfo
+ posix_memalign
+ setenv
+ setlocale
+ sigaction
+ socket
+ strchr
+ strdup
+ strncasecmp
+ strtok
+ strerror
+ strtol
+ wcwidth
+ cfmakeraw
+ pselect
+ getaddrinfo
+ getnameinfo
+ ]))
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if clock_gettime is available.])])
@@ -285,20 +329,22 @@
[Define if mach_absolute_time is available.])],
, [[#include <mach/mach_time.h>]])
-AC_CHECK_DECL([htobe64],
- [AC_DEFINE([HAVE_HTOBE64], [1],
- [Define if htobe64 and friends exist.])],
- [AC_CHECK_DECL([OSSwapHostToBigInt64],
- [AC_DEFINE([HAVE_OSX_SWAP], [1],
- [Define if OSSwapHostToBigInt64 and friends exist.])],
- [AC_MSG_WARN([Unable to find byte swapping functions; using built-in routines.])],
- [[#include <libkern/OSByteOrder.h>]])],
+AC_CHECK_DECLS([be64toh, betoh64], [], [],
[[#if defined(HAVE_ENDIAN_H)
#include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/types.h>
#include <sys/endian.h>
#endif]])
+AS_IF([test x"$ac_cv_have_decl_be64toh" != xyes &&
+ test x"$ac_cv_have_decl_betoh64" != xyes],
+ [AC_CHECK_DECL([OSSwapHostToBigInt64],
+ [AC_DEFINE([HAVE_OSX_SWAP], [1],
+ [Define if OSSwapHostToBigInt64 and friends exist.])],
+ [AC_MSG_WARN([Unable to find byte swapping functions; using built-in routines.])],
+ [[#include <libkern/OSByteOrder.h>]])])
+
AC_CHECK_DECL([IP_MTU_DISCOVER],
[AC_DEFINE([HAVE_IP_MTU_DISCOVER], [1],
[Define if IP_MTU_DISCOVER is a valid sockopt.])],
@@ -323,6 +369,17 @@
# Checks for protobuf
PKG_CHECK_MODULES([protobuf], [protobuf])
+# Bash completion needs to ask where it goes if >= 2.0 is installed.
+AS_IF([test "$install_completion" != no],
+ [PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
+ [if test "$prefix" = "NONE"; then
+ completions="`pkg-config --variable=completionsdir bash-completion`"
+ else
+ completions="`pkg-config --define-variable=prefix=$prefix --variable=completionsdir bash-completion`"
+ fi],
+ [completions="${sysconfdir}/bash_completion.d"])
+ AC_SUBST([completions])])
+
AC_CONFIG_FILES([
Makefile
src/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/debian/changelog
^
|
@@ -1,3 +1,66 @@
+mosh (1.2.5-1) unstable; urgency=low
+
+ * Version 1.2.5 released.
+
+ -- Keith Winstein <keithw@mit.edu> Sun, 12 Jul 2015 12:42:00 -0400
+
+mosh (1.2.4.95rc2-1) unstable; urgency=low
+
+ * Version 1.2.5 release candidate.
+
+ * New features:
+ * Bind to a specific IP address with --bind-server. (Philipp
+ Haselwarter)
+ * MOSH_ESCAPE_KEY configures escape character. (Timo
+ J. Rinne)
+ * Support non-roaming IPv6. (Anders Kaseorg)
+ * Implement XTerm mouse mode. (Barosl LEE, Andrew Chin,
+ Louis Kruger)
+ * Report Git revision along with version if available.
+ (John Hood)
+
+ * Platform support:
+ * Add pselect() emulation. (Jérémie Courrèges-Anglas)
+ * OpenBSD, OS X: Fix be64toh-related issues. (Jérémie
+ Courrèges-Anglas)
+ * ARM Neon: fix gcc4.8 compiling problem(Pasi Sjöholm)
+ * NaCl: Conditionally rename main to mosh_main. (Richard
+ Woodbury)
+ * FreeBSD: Token pasting, forkpty(), ARM fixes. (John Hood)
+ * AIX: Implement CTTY grabbing when TIOCSCTTY is missing
+ (Anton Lundin)
+ * OS X: Broaden build support to cover OS X 10.5 through
+ 10.10. (John Hood)
+ * Debian: Improve bash-completion install and
+ functionality. (Suggested by Gabriel Filion, John Hood)
+
+ * Bug fixes:
+ * Automake/autoconf workarounds. (Anders Kaseorg)
+ * mosh-server: Allow startup without PTY. (Keith Winstein)
+ * network.cc: Properly close old fd on Socket assignment
+ operator. (Thanks to Igor Bukanov)
+ * mosh-server: Allow startup with zero-window-size PTY.
+ (Igor Bukanov)
+ * AddrInfo: Fix error message generation when node == NULL
+ (Anders Kaseorg)
+ * Timestamp: Prevent integer overflow on Darwin PPC 32-bit
+ (Anders Kaseorg)
+ * scripts/mosh: Fix hang when remote closes the connection
+ (Anders Kaseorg)
+ * Fix issues with parsing of 256-color SGR sequences.
+ (John Hood)
+ * Numerous code hygiene, Coverity, and Clang static analyzer
+ fixes. (Anders Kaseorg, Geoffrey Thomas, John Hood)
+
+ -- Keith Winstein <keithw@mit.edu> Mon, 08 Jun 2015 22:45:00 -0400
+
+mosh (1.2.4a-1) unstable; urgency=low
+
+ * Eliminate redundant ocb.cc test (fixes build warning on ARM/MIPS/s390)
+ * Add explicit cast to int (fixes build warning on older gcc)
+
+ -- Keith Winstein <keithw@mit.edu> Wed, 27 Mar 2013 18:32:33 -0400
+
mosh (1.2.4-1) unstable; urgency=low
* Version 1.2.4 released.
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/debian/control
^
|
@@ -2,16 +2,17 @@
Section: net
Priority: optional
Maintainer: Keith Winstein <keithw@mit.edu>
-DM-Upload-Allowed: yes
-Build-Depends: debhelper (>= 7.0.50), autotools-dev, protobuf-compiler, libprotobuf-dev, dh-autoreconf, pkg-config, libutempter-dev, zlib1g-dev, libncurses5-dev, libssl-dev
-Standards-Version: 3.9.4.0
+Build-Depends: debhelper (>= 7.0.50), autotools-dev, protobuf-compiler, libprotobuf-dev, dh-autoreconf, pkg-config, libutempter-dev, zlib1g-dev, libncurses5-dev, libssl-dev, bash-completion
+Standards-Version: 3.9.6.1
Homepage: http://mosh.mit.edu
Vcs-Git: git://github.com/keithw/mosh.git
Vcs-Browser: https://github.com/keithw/mosh
Package: mosh
Architecture: any
+Pre-Depends: dpkg (>= 1.15.7.2)
Depends: ${shlibs:Depends}, ${misc:Depends}, openssh-client
+Recommends: libio-socket-ip-perl
Description: Mobile shell that supports roaming and intelligent local echo
Mosh is a remote terminal application that supports:
- intermittent network connectivity,
|
[-]
[+]
|
Added |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/debian/mosh.maintscript
^
|
@@ -0,0 +1 @@
+rm_conffile /etc/bash_completion.d/mosh 1.2.5~ -- "$@"
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/fedora/mosh.spec
^
|
@@ -1,5 +1,5 @@
Name: mosh
-Version: 1.2.3
+Version: 1.2.5
Release: 1%{?dist}
Summary: Mobile shell that supports roaming and intelligent local echo
@@ -16,6 +16,7 @@
BuildRequires: openssl-devel
Requires: openssh-clients
Requires: openssl
+Requires: perl-IO-Socket-IP
%description
Mosh is a remote terminal application that supports:
@@ -51,6 +52,24 @@
%changelog
+* Sun Jul 12 2015 John Hood <cgull@glup.org> - 1.2.5-1
+- Update to mosh 1.2.5
+
+* Fri Jun 26 2015 John Hood <cgull@glup.org> - 1.2.4.95rc2-1
+- Update to mosh 1.2.4.95rc2
+
+* Mon Jun 08 2015 John Hood <cgull@glup.org> - 1.2.4.95rc1-1
+- Update to mosh 1.2.4.95rc1
+
+* Wed Mar 27 2013 Alexander Chernyakhovsky <achernya@mit.edu> - 1.2.4-1
+- Update to mosh 1.2.4
+
+* Sun Mar 10 2013 Alexander Chernyakhovsky <achernya@mit.edu> - 1.2.3-3
+- Rebuilt for Protobuf API change from 2.4.1 to 2.5.0
+
+* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.3-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
+
* Fri Oct 19 2012 Alexander Chernyakhovsky <achernya@mit.edu> - 1.2.3-1
- Update to mosh 1.2.3
|
[-]
[+]
|
Added |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/macosx/Distribution.in
^
|
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.6" authoringToolBuild="201">
+ <title>@PACKAGE_VERSION@</title>
+ <options customize="never" allow-external-scripts="no"/>
+ <domains enable_anywhere="true"/>
+ <readme file="ReadMe"/>
+ <license file="License"/>
+ <choices-outline>
+ <line choice="choice0"/>
+ </choices-outline>
+ <choice id="choice0" title="Default" customLocation="/usr">
+ <pkg-ref id="edu.mit.mosh.mosh.pkg"/>
+ </choice>
+ <pkg-ref id="edu.mit.mosh.mosh.pkg" installKBytes="2204" version="@PACKAGE_VERSION@" auth="Root">#edu.mit.mosh.mosh.pkg</pkg-ref>
+</installer-script>
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/macosx/build.sh
^
|
@@ -1,20 +1,45 @@
#!/bin/bash
+#
+# This script is known to work on:
+# OS X 10.5.8, Xcode 3.1.2, SDK 10.5, MacPorts 2.3.3
+# OS X 10.9.5, Xcode 5.1.1, SDK 10.9, MacPorts 2.3.2
+# OS X 10.10.3, XCode 6.3.2, SDK 10.10, Homebrew 0.9.5/8da6986
+#
+# You may need to set PATH to include the location of your
+# PackageMaker binary, if your system is old enough to need that.
+# Setting MACOSX_DEPLOYMENT_TARGET will select an SDK as usual.
+#
+# If you are using Homebrew, you should install protobuf (and any
+# other future Homebrew dependencies) with
+# `--universal --build-bottle`.
+# The first option should be fairly obvious; the second has the side
+# effect of disabling Homebrew's overzealous processor optimization
+# with (effectively) `-march=native`.
+#
+
set -e
+protobuf_LIBS=$(l=libprotobuf.a; for i in /opt/local/lib /usr/local/lib; do if [ -f $i/$l ]; then echo $i/$l; fi; done)
+if [ -z "$protobuf_LIBS" ]; then echo "Can't find libprotobuf.a"; exit 1; fi
+export protobuf_LIBS
+if ! pkg-config --cflags protobuf > /dev/null 2>&1; then
+ protobuf_CFLAGS=-I$(for i in /opt /usr; do d=$i/local/include; if [ -d $d/google/protobuf ]; then echo $d; fi; done)
+ if [ "$protobuf_CFLAGS" = "-I" ]; then echo "Can't find protobuf includes"; exit 1; fi
+ export protobuf_CFLAGS
+fi
+
echo "Building into prefix..."
-PREFIX=`pwd`/prefix
-PREFIX_i386=`pwd`/prefix_i386
-PREFIX_x86_64=`pwd`/prefix_x86_64
-#PREFIX_ppc=`pwd`/prefix_ppc
-#PREFIX_ppc64=`pwd`/prefix_ppc64
-
-mkdir -p "$PREFIX"
-mkdir -p "$PREFIX_i386"
-mkdir -p "$PREFIX_x86_64"
-#mkdir -p "$PREFIX_ppc"
-#mkdir -p "$PREFIX_ppc64"
+
+#
+# XXX This script abuses Configure's --prefix argument badly. It uses
+# it as a $DESTDIR, but --prefix can also affect paths in generated
+# objects. That is not *currently* a problem in mosh.
+#
+PREFIX="$(pwd)/prefix"
+
+ARCHS=" ppc ppc64 i386 x86_64"
pushd .. > /dev/null
@@ -24,85 +49,106 @@
PATH=/opt/local/bin:$PATH ./autogen.sh
fi
-echo "Building for x86_64..."
-./configure --prefix="$PREFIX_x86_64" ac_cv_poll_pty=no \
- CC="clang -arch x86_64" CPP="clang -arch x86_64 -E" CXX="clang++ -arch x86_64" \
- TINFO_LIBS=-lncurses protobuf_LIBS=/opt/local/lib/libprotobuf.a
-make clean
-make install -j8
-
-echo "Building for i386..."
-./configure --prefix="$PREFIX_i386" ac_cv_poll_pty=no \
- CC="clang -arch i386" CPP="clang -arch i386 -E" CXX="clang++ -arch i386" \
- TINFO_LIBS=-lncurses protobuf_LIBS=/opt/local/lib/libprotobuf.a
-make clean
-make install -j8
-
-#echo "Building for ppc..."
-#./configure --prefix="$PREFIX_ppc" ac_cv_poll_pty=no \
-# --target=ppc-apple-darwin --build=i686-apple-darwin --host=ppc-apple-darwin \
-# CC="clang -arch ppc -mmacosx-version-min=10.5" CPP="clang -arch ppc -mmacosx-version-min=10.5 -E" CXX="clang++ -arch ppc -mmacosx-version-min=10.5" \
-# TINFO_LIBS=-lncurses protobuf_LIBS=/opt/local/lib/libprotobuf.a
-#make clean
-#make install -j8
-#
-#echo "Building for ppc64..."
-#./configure --prefix="$PREFIX_ppc64" ac_cv_poll_pty=no \
-# --target=ppc-apple-darwin --build=i686-apple-darwin --host=ppc-apple-darwin \
-# CC="clang -arch ppc64 -mmacosx-version-min=10.5" CPP="clang -arch ppc64 -mmacosx-version-min=10.5 -E" CXX="clang++ -arch ppc64 -mmacosx-version-min=10.5" \
-# TINFO_LIBS=-lncurses protobuf_LIBS=/opt/local/lib/libprotobuf.a
-#make clean
-#make install -j8
-
-echo "Building universal binaries..."
-
-cp -r "$PREFIX_x86_64/" "$PREFIX/"
-
-strip "$PREFIX_i386/bin/mosh-client"
-strip "$PREFIX_i386/bin/mosh-server"
-strip "$PREFIX_x86_64/bin/mosh-client"
-strip "$PREFIX_x86_64/bin/mosh-server"
-#strip "$PREFIX_ppc/bin/mosh-client"
-#strip "$PREFIX_ppc/bin/mosh-server"
-#strip "$PREFIX_ppc64/bin/mosh-client"
-#strip "$PREFIX_ppc64/bin/mosh-server"
-
-#lipo -create "$PREFIX_ppc/bin/mosh-client" "$PREFIX_ppc64/bin/mosh-client" "$PREFIX_i386/bin/mosh-client" "$PREFIX_x86_64/bin/mosh-client" -output "$PREFIX/bin/mosh-client"
-#lipo -create "$PREFIX_ppc/bin/mosh-server" "$PREFIX_ppc64/bin/mosh-server" "$PREFIX_i386/bin/mosh-server" "$PREFIX_x86_64/bin/mosh-server" -output "$PREFIX/bin/mosh-server"
-lipo -create "$PREFIX_i386/bin/mosh-client" "$PREFIX_x86_64/bin/mosh-client" -output "$PREFIX/bin/mosh-client"
-lipo -create "$PREFIX_i386/bin/mosh-server" "$PREFIX_x86_64/bin/mosh-server" -output "$PREFIX/bin/mosh-server"
-
-perl -wlpi -e 's{#!/usr/bin/env perl}{#!/usr/bin/perl}' "$PREFIX/bin/mosh"
-
-popd > /dev/null
+#
+# Build archs one by one.
+#
+for arch in $ARCHS; do
+ echo "Building for ${arch}..."
+ prefix="${PREFIX}_${arch}"
+ rm -rf "${prefix}"
+ mkdir "${prefix}"
+ if ./configure --prefix="${prefix}/local" \
+ CC="cc -arch ${arch}" CPP="cc -arch ${arch} -E" CXX="c++ -arch ${arch}" \
+ TINFO_LIBS=-lncurses \
+ OPENSSL_CFLAGS=" " OPENSSL_LIBS="-lssl -lcrypto -lz" &&
+ make clean &&
+ make install -j8 &&
+ rm -f "${prefix}/etc"
+ then
+ # mosh-client built with Xcode 3.1.2 bus-errors if the binary is stripped.
+ # strip "${prefix}/local/bin/mosh-client" "${prefix}/local/bin/mosh-server"
+ BUILT_ARCHS="$BUILT_ARCHS $arch"
+ fi
+done
-echo "Preprocessing package description..."
-PACKAGE_VERSION=`grep PACKAGE_VERSION ../config.h | sed -e 's/^.*"\(.*\)"$/\1/'`
+if [ -z "$BUILT_ARCHS" ]; then
+ echo "No architectures built successfully"
+ exit 1
+fi
-INDIR=mosh-package.pmdoc.in
-OUTDIR=mosh-package.pmdoc
-OUTFILE="Mosh $PACKAGE_VERSION.pkg"
+echo "Building universal binaries for archs ${BUILT_ARCHS}..."
-mkdir -p "$OUTDIR"
-pushd "$INDIR" > /dev/null
+rm -rf "$PREFIX"
+# Copy one architecture to get all files into place.
+for arch in $BUILT_ARCHS; do
+ cp -Rp "${PREFIX}_${arch}" "${PREFIX}"
+ break
+done
-for file in *
-do
- sed -e 's/$PACKAGE_VERSION/'"$PACKAGE_VERSION"'/g' "$file" > "../$OUTDIR/$file"
+# Build fat binaries
+# XXX will break with spaces in pathname
+for prog in local/bin/mosh-client local/bin/mosh-server; do
+ archprogs=
+ for arch in $BUILT_ARCHS; do
+ archprogs="$archprogs ${PREFIX}_${arch}/$prog"
+ done
+ lipo -create $archprogs -output "${PREFIX}/$prog"
done
+perl -wlpi -e 's{#!/usr/bin/env perl}{#!/usr/bin/perl}' "$PREFIX/local/bin/mosh"
+
popd > /dev/null
-echo "Running PackageMaker..."
-PATH=/Applications/PackageMaker.app/Contents/MacOS:$PATH PackageMaker -d mosh-package.pmdoc -o "$OUTFILE"
+PACKAGE_VERSION=$(cat ../VERSION)
+
+OUTFILE="$PACKAGE_VERSION.pkg"
+
+rm -f "$OUTFILE"
+
+if which -s pkgbuild; then
+ # To replace PackageMaker, you:
+ # * make a bare package with the build products
+ # * essentially take the Distribution file that PackageMaker generated and
+ # use it as the --distribution input file for productbuild
+ echo "Preprocessing package description..."
+ PKGID=edu.mit.mosh.mosh.pkg
+ for file in Distribution; do
+ sed -e "s/@PACKAGE_VERSION@/${PACKAGE_VERSION}/g" ${file}.in > ${file}
+ done
+ echo "Running pkgbuild/productbuild..."
+ mkdir -p Resources/en.lproj
+ cp -p copying.rtf Resources/en.lproj/License
+ cp -p readme.rtf Resources/en.lproj/Readme
+ pkgbuild --root "$PREFIX" --identifier $PKGID $PKGID
+ productbuild --distribution Distribution \
+ --resources Resources \
+ --package-path . \
+ "$OUTFILE"
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/macosx/mosh-package.pmdoc.in/01prefix-contents.xml
^
|
@@ -1,46 +1,50 @@
<pkg-contents spec="1.12">
- <f n="prefix" o="root" g="wheel" p="16877" pt="prefix" m="false" t="file">
- <f n="bin" o="root" g="wheel" p="16877">
- <f n="mosh" o="root" g="wheel" p="33261">
- <mod>group</mod>
- <mod>owner</mod>
- </f>
- <f n="mosh-client" o="root" g="wheel" p="33261">
- <mod>group</mod>
- <mod>owner</mod>
+ <f n="prefix" o="root" g="wheel" p="16877" pt="prefix" m="false" t="file">
+ <f n="local" o="root" g="wheel" p="16877">
+ <f n="bin" o="root" g="wheel" p="16877">
+ <f n="mosh" o="root" g="wheel" p="33261">
+ <mod>group</mod>
+ <mod>owner</mod>
+ </f>
+ <f n="mosh-client" o="root" g="wheel" p="33261">
+ <mod>group</mod>
+ <mod>owner</mod>
+ </f>
+ <f n="mosh-server" o="root" g="wheel" p="33261">
+ <mod>group</mod>
+ <mod>owner</mod>
+ </f>
+ <mod>group</mod>
+ <mod>owner</mod>
+ </f>
+ <f n="share" o="root" g="wheel" p="16877">
+ <f n="man" o="root" g="wheel" p="16877">
+ <f n="man1" o="root" g="wheel" p="16877">
+ <f n="mosh-client.1" o="root" g="wheel" p="33188">
+ <mod>group</mod>
+ <mod>owner</mod>
</f>
- <f n="mosh-server" o="root" g="wheel" p="33261">
- <mod>group</mod>
- <mod>owner</mod>
+ <f n="mosh-server.1" o="root" g="wheel" p="33188">
+ <mod>group</mod>
+ <mod>owner</mod>
</f>
- <mod>group</mod>
- <mod>owner</mod>
- </f>
- <f n="share" o="root" g="wheel" p="16877">
- <f n="man" o="root" g="wheel" p="16877">
- <f n="man1" o="root" g="wheel" p="16877">
- <f n="mosh-client.1" o="root" g="wheel" p="33188">
- <mod>group</mod>
- <mod>owner</mod>
- </f>
- <f n="mosh-server.1" o="root" g="wheel" p="33188">
- <mod>group</mod>
- <mod>owner</mod>
- </f>
- <f n="mosh.1" o="root" g="wheel" p="33188">
- <mod>group</mod>
- <mod>owner</mod>
- </f>
- <mod>group</mod>
- <mod>owner</mod>
- </f>
- <mod>group</mod>
- <mod>owner</mod>
+ <f n="mosh.1" o="root" g="wheel" p="33188">
+ <mod>group</mod>
+ <mod>owner</mod>
</f>
<mod>group</mod>
<mod>owner</mod>
+ </f>
+ <mod>group</mod>
+ <mod>owner</mod>
</f>
<mod>group</mod>
<mod>owner</mod>
+ </f>
+ <mod>group</mod>
+ <mod>owner</mod>
</f>
+ <mod>group</mod>
+ <mod>owner</mod>
+ </f>
</pkg-contents>
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/man/mosh-client.1
^
|
@@ -27,7 +27,7 @@
.br
.SH DESCRIPTION
\fBmosh-client\fP is a helper program for the
-.BR mosh(1)
+.BR mosh (1)
remote terminal application.
\fBmosh\fP itself is a setup script that establishes an SSH
@@ -49,6 +49,29 @@
With the \-c option, \fBmosh-client\fP instead prints the number of colors
of the terminal given by the TERM environment variable.
+.SH ENVIRONMENT VARIABLES
+
+.TP
+.B MOSH_KEY
+This variable must be set, and must contain a Base64-encoded cryptographic key from
+.BR mosh-server (1).
+
+.TP
+.B MOSH_ESCAPE_KEY
+See
+.BR mosh (1).
+
+.TP
+.B MOSH_PREDICTION_DISPLAY
+Controls local echo as described in
+.BR mosh (1).
+
+.TP
+.B MOSH_TITLE_NOPREFIX
+See
+.BR mosh (1).
+
+
.SH SEE ALSO
.BR mosh (1),
.BR mosh-server (1).
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/man/mosh.1
^
|
@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
-.TH MOSH 1 "October 2012"
+.TH MOSH 1 "April 2013"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -121,6 +121,20 @@
Synonym for \-\-predict=never
.TP
+.B --family=\fIFAMILY\fP
+Force the use of a particular address family, which defaults to `inet'
+(IPv4), and can also be `inet6' (IPv6; requires IO::Socket::IP or
+IO::Socket::INET6).
+
+.TP
+.B -4
+Synonym for \-\-family=inet
+
+.TP
+.B -6
+Synonym for \-\-family=inet6
+
+.TP
.B \-p \fIPORT\fP[:\fIPORT2\fP], \-\-port=\fIPORT\fP[:\fIPORT2\fP]
Use a particular server-side UDP port or port range,
for example, if this is the
@@ -129,6 +143,23 @@
61000.
.TP
+.B \-\-bind\-server={ssh|any|\fIIP\fP}
+Control the IP address that the \fBmosh-server\fP binds to.
+
+The default is `ssh', in which case the server will reply from the IP
+address that the SSH connection came from (as found in the
+\fBSSH_CONNECTION\fP environment variable). This is useful for
+multihomed servers.
+
+With \-\-bind\-server=any, the server will reply on the default interface
+and will not bind to a particular IP address. This can be useful if
+the connection is made through \fBsslh\fP or another tool that makes
+the SSH connection appear to come from localhost.
+
+With \-\-bind\-server=\fIIP\fP, the server will attempt to bind to the
+specified IP address.
+
+.TP
.B \-\-no\-init
Do not send the \fBsmcup\fP initialization string and \fBrmcup\fP
deinitialization string to the client's terminal. On many terminals
@@ -136,16 +167,51 @@
.SH ESCAPE SEQUENCES
-The escape sequence to shut down the connection is \fBCtrl-^ .\fP
-(typically typed with Ctrl-Shift-6, then a period). To send a literal
-Ctrl-^, type \fBCtrl-^ ^\fP. The sequence \fBCtrl-^ Ctrl-Z\fP suspends the
-client.
+The default escape character used by Mosh is ASCII RS (decimal 30).
+This is typically typed as \fBCtrl-^\fP or \fBCtrl-Shift-6\fP, on US
+English keyboards. Users of non-English keyboards may find it
+difficult or impossible to type the default escape character, and may
+need to change the escape character. See the description of
+MOSH_ESCAPE_KEY, below. In this description, the configured escape
+character is represented as \fBEsc\fP.
+
+There are two slightly different modes for escape sequences, depending
+whether the escape character is printable or not.
+
+If the escape character is a printable character, it must be prefixed
+with a newline, similar to \fBOpenSSH\fP. To send the escape character
+itself, type it twice. If the escape character is set to \fB~\fP,
+\fBmosh\fP will behave much like \fBOpenSSH\fP.
+
+If the escape character is a non-printable control character, no
+prefix is used and the escape character is recognized at any time. To
+send the escape character itself, type the escape character, then its
+corresponding ASCII character (for \fBCtrl-^\fP you would type \fB^\fP,
+for \fBCtrl-B\fP you would type \fBB\fP).
+
+The escape sequence to shut down the connection is
+\fBEsc .\fP. The sequence \fBEsc Ctrl-Z\fP suspends the client.
+Any other sequence passes both characters through to the server.
.SH ENVIRONMENT VARIABLES
+These variables are not actually interpreted by
+.BR mosh (1)
+itself, but are passed through to
+.BR mosh-server (1).
+They are described here for ease of use.
+
+.TP
+.B MOSH_ESCAPE_KEY
+When set, this configures the escape character used for local
+commands. The escape character may be set to any ASCII character in
+the range 1-127. The variable must be set with a single literal ASCII
+character. Control characters are set with the actual ASCII
+control character, not with a printable representation such as "^B".
.TP
.B MOSH_PREDICTION_DISPLAY
-Controls local echo as described above.
+Controls local echo as described above. The command-line flag
+overrides this variable.
.TP
.B MOSH_TITLE_NOPREFIX
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/scripts/Makefile.am
^
|
@@ -1,4 +1,9 @@
-EXTRA_DIST = wrap-compiler-for-flag-check
+EXTRA_DIST = wrap-compiler-for-flag-check mosh.pl
if BUILD_CLIENT
- dist_bin_SCRIPTS = mosh
+ bin_SCRIPTS = mosh
endif
+CLEANFILES = $(bin_SCRIPTS)
+
+mosh: mosh.pl ../VERSION Makefile
+ @sed -e "s/\@VERSION\@/`cat ../VERSION`/" -e "s/\@PACKAGE_STRING\@/@PACKAGE_STRING@/" $(srcdir)/mosh.pl > mosh
+ @chmod a+x mosh
|
[-]
[+]
|
Added |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/scripts/mosh.pl
^
|
@@ -0,0 +1,342 @@
+#!/usr/bin/env perl
+
+# Mosh: the mobile shell
+# Copyright 2012 Keith Winstein
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# In addition, as a special exception, the copyright holders give
+# permission to link the code of portions of this program with the
+# OpenSSL library under certain conditions as described in each
+# individual source file, and distribute linked combinations including
+# the two.
+#
+# You must obey the GNU General Public License in all respects for all
+# of the code used other than OpenSSL. If you modify file(s) with this
+# exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do
+# so, delete this exception statement from your version. If you delete
+# this exception statement from all source files in the program, then
+# also delete it here.
+
+use warnings;
+use strict;
+use Getopt::Long;
+use IO::Socket;
+
+$|=1;
+
+my $client = 'mosh-client';
+my $server = 'mosh-server';
+
+my $predict = undef;
+
+my $bind_ip = undef;
+
+my $family = 'inet';
+my $port_request = undef;
+
+my $ssh = 'ssh';
+
+my $term_init = 1;
+
+my $help = undef;
+my $version = undef;
+
+my @cmdline = @ARGV;
+
+my $usage =
+qq{Usage: $0 [options] [--] [user@]host [command...]
+ --client=PATH mosh client on local machine
+ (default: "mosh-client")
+ --server=COMMAND mosh server on remote machine
+ (default: "mosh-server")
+
+ --predict=adaptive local echo for slower links [default]
+-a --predict=always use local echo even on fast links
+-n --predict=never never use local echo
+ --predict=experimental aggressively echo even when incorrect
+
+-4 --family=inet use IPv4 only [default]
+-6 --family=inet6 use IPv6 only
+-p PORT[:PORT2]
+ --port=PORT[:PORT2] server-side UDP port or range
+ --bind-server={ssh|any|IP} ask the server to reply from an IP address
+ (default: "ssh")
+
+ --ssh=COMMAND ssh command to run when setting up session
+ (example: "ssh -p 2222")
+ (default: "ssh")
+
+ --no-init do not send terminal initialization string
+
+ --help this message
+ --version version and copyright information
+
+Please report bugs to mosh-devel\@mit.edu.
+Mosh home page: http://mosh.mit.edu\n};
+
+my $version_message = '@PACKAGE_STRING@ [build @VERSION@]' . qq{
+Copyright 2012 Keith Winstein <mosh-devel\@mit.edu>
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.\n};
+
+sub predict_check {
+ my ( $predict, $env_set ) = @_;
+
+ if ( not exists { adaptive => 0, always => 0,
+ never => 0, experimental => 0 }->{ $predict } ) {
+ my $explanation = $env_set ? " (MOSH_PREDICTION_DISPLAY in environment)" : "";
+ print STDERR qq{$0: Unknown mode \"$predict\"$explanation.\n\n};
+
+ die $usage;
+ }
+}
+
+GetOptions( 'client=s' => \$client,
+ 'server=s' => \$server,
+ 'predict=s' => \$predict,
+ 'port=s' => \$port_request,
+ 'a' => sub { $predict = 'always' },
+ 'n' => sub { $predict = 'never' },
+ 'family=s' => \$family,
+ '4' => sub { $family = 'inet' },
+ '6' => sub { $family = 'inet6' },
+ 'p=s' => \$port_request,
+ 'ssh=s' => \$ssh,
+ 'init!' => \$term_init,
+ 'help' => \$help,
+ 'version' => \$version,
+ 'fake-proxy!' => \my $fake_proxy,
+ 'bind-server=s' => \$bind_ip) or die $usage;
+
+die $usage if ( defined $help );
+die $version_message if ( defined $version );
+
+if ( defined $predict ) {
+ predict_check( $predict, 0 );
+} elsif ( defined $ENV{ 'MOSH_PREDICTION_DISPLAY' } ) {
+ $predict = $ENV{ 'MOSH_PREDICTION_DISPLAY' };
+ predict_check( $predict, 1 );
+} else {
+ $predict = 'adaptive';
+ predict_check( $predict, 0 );
+}
+
+if ( defined $port_request ) {
+ if ( $port_request =~ m{^(\d+)(:(\d+))?$} ) {
+ my ( $low, $clause, $high ) = ( $1, $2, $3 );
+ # good port or port-range
+ if ( $low <= 0 or $low > 65535 ) {
+ die "$0: Server-side (low) port ($low) must be within valid range [1..65535].\n";
+ }
+ if ( defined $high ) {
+ if ( $high <= 0 or $high > 65535 ) {
+ die "$0: Server-side high port ($high) must be within valid range [1..65535].\n";
+ }
+ if ( $low > $high ) {
+ die "$0: Server-side port range ($port_request): low port greater than high port.\n";
+ }
+ }
+ } else {
+ die "$0: Server-side port or range ($port_request) is not valid.\n";
+ }
+}
+
+delete $ENV{ 'MOSH_PREDICTION_DISPLAY' };
+
+my @bind_arguments;
+if ( not defined $bind_ip or $bind_ip =~ m{^ssh$}i ) {
+ push @bind_arguments, '-s';
+} elsif ( $bind_ip =~ m{^any$}i ) {
+ # do nothing
+} elsif ( $bind_ip =~ m{^[0-9\.]+$} ) {
+ push @bind_arguments, ('-i', "$bind_ip");
+} else {
+ print STDERR qq{$0: Unknown server binding option: $bind_ip\n};
+
+ die $usage;
+}
+
+if ( defined $fake_proxy ) {
+ use Errno qw(EINTR);
+ my $have_ipv6 = eval {
+ require IO::Socket::IP;
+ IO::Socket::IP->import('-register');
+ 1;
+ } || eval {
+ require IO::Socket::INET6;
+ 1;
+ };
+ use POSIX qw(_exit);
+
+ # Report failure if IPv6 needed and not available.
+ if (lc($family) eq "inet6") {
+ if (!$have_ipv6) {
+ die "$0: IPv6 sockets not available in this Perl install\n";
+ }
+ }
+
+ my ( $host, $port ) = @ARGV;
+
+ # Resolve hostname and connect
+ my $afstr = 'AF_' . uc( $family );
+ my $af = eval { IO::Socket->$afstr } or die "$0: Invalid family $family\n";
+ my $sock = IO::Socket->new( Domain => $af,
+ Family => $af,
+ PeerHost => $host,
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/Makefile.am
^
|
@@ -15,10 +15,3 @@
crypto.cc \
crypto.h \
prng.h
-
-check_PROGRAMS = ocb-test
-TESTS = ocb-test
-
-ocb_test_SOURCES = $(OCB_SRCS)
-ocb_test_CPPFLAGS = -DOCB_TEST_PROGRAM
-ocb_test_LDADD = $(OPENSSL_LIBS)
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/base64.cc
^
|
@@ -35,6 +35,7 @@
#include <openssl/evp.h>
#include "fatal_assert.h"
+#include "base64.h"
bool base64_decode( const char *b64, const size_t b64_len,
char *raw, size_t *raw_len )
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/base64.h
^
|
@@ -33,5 +33,5 @@
bool base64_decode( const char *b64, const size_t b64_len,
char *raw, size_t *raw_len );
-bool base64_encode( const char *raw, const size_t raw_len,
- char *b64, size_t b64_len );
+void base64_encode( const char *raw, const size_t raw_len,
+ char *b64, const size_t b64_len );
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/byteorder.h
^
|
@@ -35,13 +35,20 @@
#include "config.h"
-#ifdef HAVE_HTOBE64
+#if HAVE_DECL_BE64TOH || HAVE_DECL_BETOH64
+
# if defined(HAVE_ENDIAN_H)
# include <endian.h>
# elif defined(HAVE_SYS_ENDIAN_H)
+# include <sys/types.h>
# include <sys/endian.h>
# endif
+#if !HAVE_DECL_BE64TOH && HAVE_DECL_BETOH64
+#define be64toh betoh64
+#define be16toh betoh16
+#endif
+
#elif HAVE_OSX_SWAP
# include <libkern/OSByteOrder.h>
# define htobe64 OSSwapHostToBigInt64
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/crypto.cc
^
|
@@ -41,12 +41,11 @@
#include "byteorder.h"
#include "crypto.h"
#include "base64.h"
+#include "prng.h"
using namespace std;
using namespace Crypto;
-const char rdev[] = "/dev/urandom";
-
long int myatoi( const char *str )
{
char *end;
@@ -122,12 +121,7 @@
Base64Key::Base64Key()
{
- ifstream devrandom( rdev, ifstream::in | ifstream::binary );
-
- devrandom.read( reinterpret_cast<char *>( key ), sizeof( key ) );
- if ( !devrandom ) {
- throw CryptoException( "Could not read from " + string( rdev ) );
- }
+ PRNG().fill( key, sizeof( key ) );
}
string Base64Key::printable_key( void ) const
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/crypto.h
^
|
@@ -38,18 +38,21 @@
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
+#include <exception>
using std::string;
long int myatoi( const char *str );
namespace Crypto {
- class CryptoException {
+ class CryptoException : public std::exception {
public:
string text;
bool fatal;
CryptoException( string s_text, bool s_fatal = false )
: text( s_text ), fatal( s_fatal ) {};
+ const char *what() const throw () { return text.c_str(); }
+ ~CryptoException() throw () {}
};
/* 16-byte-aligned buffer, with length. */
@@ -71,8 +74,8 @@
private:
/* Not implemented */
- AlignedBuffer( const AlignedBuffer& );
- AlignedBuffer& operator=( const AlignedBuffer& );
+ AlignedBuffer( const AlignedBuffer & );
+ AlignedBuffer & operator=( const AlignedBuffer & );
};
class Base64Key {
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/crypto/ocb.cc
^
|
@@ -185,7 +185,7 @@
bl = _mm_slli_epi32(bl, 1);
return _mm_xor_si128(bl,tmp);
}
-#elif __ALTIVEC__
+#elif __ALTIVEC__ && _CALL_ELF != 2
#include <altivec.h>
typedef vector unsigned block;
#define xor_block(x,y) vec_xor(x,y)
@@ -193,7 +193,7 @@
#define unequal_blocks(x,y) vec_any_ne(x,y)
#define swap_if_le(b) (b)
#if __PPC64__
- block gen_offset(uint64_t KtopStr[3], unsigned bot) {
+ static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
union {uint64_t u64[2]; block bl;} rval;
rval.u64[0] = (KtopStr[0] << bot) | (KtopStr[1] >> (64-bot));
rval.u64[1] = (KtopStr[1] << bot) | (KtopStr[2] >> (64-bot));
@@ -201,7 +201,7 @@
}
#else
/* Special handling: Shifts are mod 32, and no 64-bit types */
- block gen_offset(uint64_t KtopStr[3], unsigned bot) {
+ static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
const vector unsigned k32 = {32,32,32,32};
vector unsigned hi = *(vector unsigned *)(KtopStr+0);
vector unsigned lo = *(vector unsigned *)(KtopStr+2);
@@ -246,7 +246,7 @@
}
#define swap_if_le(b) (b) /* Using endian-neutral int8x16_t */
/* KtopStr is reg correct by 64 bits, return mem correct */
- block gen_offset(uint64_t KtopStr[3], unsigned bot) {
+ static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
const union { unsigned x; unsigned char endian; } little = { 1 };
const int64x2_t k64 = {-64,-64};
uint64x2_t hi = *(uint64x2_t *)(KtopStr+0); /* hi = A B */
@@ -260,7 +260,7 @@
}
static inline block double_block(block b)
{
- const block mask = {135,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+ const block mask = {-121,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
block tmp = vshrq_n_s8(b,7);
tmp = vandq_s8(tmp, mask);
tmp = vextq_s8(tmp, tmp, 1); /* Rotate high byte to end */
@@ -286,7 +286,7 @@
}
/* KtopStr is reg correct by 64 bits, return mem correct */
- block gen_offset(uint64_t KtopStr[3], unsigned bot) {
+ static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
block rval;
if (bot != 0) {
rval.l = (KtopStr[0] << bot) | (KtopStr[1] >> (64-bot));
@@ -298,7 +298,7 @@
return swap_if_le(rval);
}
- #if __GNUC__ && __arm__
+ #if __GNUC__ && !__clang__ && __arm__
static inline block double_block(block b) {
__asm__ ("adds %1,%1,%1\n\t"
"adcs %H1,%H1,%H1\n\t"
@@ -1271,7 +1271,7 @@
printf("P=%d,A=%d: ",len,0); pbuf(ct, i, NULL);
}
-void validate()
+static void validate()
{
ALIGN(16) uint8_t pt[1024];
ALIGN(16) uint8_t ct[1024];
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/examples/benchmark.cc
^
|
@@ -44,6 +44,7 @@
#include <signal.h>
#include <time.h>
#include <limits.h>
+#include <exception>
#if HAVE_PTY_H
#include <pty.h>
@@ -62,44 +63,65 @@
using namespace Terminal;
-int main( void )
+int main( int argc, char **argv )
{
- int fbmod = 0;
- Framebuffer local_framebuffers[ 2 ] = { Framebuffer(80,24), Framebuffer(80,24) };
- Framebuffer *local_framebuffer = &(local_framebuffers[ fbmod ]);
- Framebuffer *new_state = &(local_framebuffers[ !fbmod ]);
- Overlay::OverlayManager overlays;
- Display display( true );
- Complete local_terminal( 80, 24 );
-
- /* Adopt native locale */
- set_native_locale();
- fatal_assert( is_utf8_locale() );
-
- for ( int i = 0; i < ITERATIONS; i++ ) {
- /* type a character */
- overlays.get_prediction_engine().new_user_byte( i + 'x', *local_framebuffer );
-
- /* fetch target state */
- *new_state = local_terminal.get_fb();
-
- /* apply local overlays */
- overlays.apply( *new_state );
-
- /* calculate minimal difference from where we are */
- const string diff( display.new_frame( false,
- *local_framebuffer,
- *new_state ) );
-
- /* make sure to use diff */
- if ( diff.size() > INT_MAX ) {
- exit( 1 );
+ try {
+ int fbmod = 0;
+ int width = 80, height = 24;
+ int iterations = ITERATIONS;
+ if (argc > 1) {
+ iterations = atoi(argv[1]);
+ if (iterations < 1 || iterations > 1000000000) {
+ fprintf(stderr, "bogus iteration count\n");
+ exit(1);
+ }
}
-
- fbmod = !fbmod;
- local_framebuffer = &(local_framebuffers[ fbmod ]);
- new_state = &(local_framebuffers[ !fbmod ]);
+ if (argc > 3) {
+ width = atoi(argv[2]);
+ height = atoi(argv[3]);
+ if (width < 1 || width > 1000 || height < 1 || height > 1000) {
+ fprintf(stderr, "bogus window size\n");
+ exit(1);
+ }
+ }
+ Framebuffer local_framebuffers[ 2 ] = { Framebuffer(width,height), Framebuffer(width,height) };
+ Framebuffer *local_framebuffer = &(local_framebuffers[ fbmod ]);
+ Framebuffer *new_state = &(local_framebuffers[ !fbmod ]);
+ Overlay::OverlayManager overlays;
+ Display display( true );
+ Complete local_terminal( width, height );
+
+ /* Adopt native locale */
+ set_native_locale();
+ fatal_assert( is_utf8_locale() );
+
+ for ( int i = 0; i < iterations; i++ ) {
+ /* type a character */
+ overlays.get_prediction_engine().new_user_byte( i + 'x', *local_framebuffer );
+
+ /* fetch target state */
+ *new_state = local_terminal.get_fb();
+
+ /* apply local overlays */
+ overlays.apply( *new_state );
+
+ /* calculate minimal difference from where we are */
+ const string diff( display.new_frame( false,
+ *local_framebuffer,
+ *new_state ) );
+
+ /* make sure to use diff */
+ if ( diff.size() > INT_MAX ) {
+ exit( 1 );
+ }
+
+ fbmod = !fbmod;
+ local_framebuffer = &(local_framebuffers[ fbmod ]);
+ new_state = &(local_framebuffers[ !fbmod ]);
+ }
+ } catch ( const std::exception &e ) {
+ fprintf( stderr, "Exception caught: %s\n", e.what() );
+ return 1;
}
-
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/examples/decrypt.cc
^
|
@@ -62,7 +62,7 @@
(long)message.nonce.val() );
cout << message.text;
} catch ( const CryptoException &e ) {
- cerr << e.text << endl;
+ cerr << e.what() << endl;
exit( 1 );
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/examples/encrypt.cc
^
|
@@ -63,7 +63,7 @@
cout << ciphertext;
} catch ( const CryptoException &e ) {
- cerr << e.text << endl;
+ cerr << e.what() << endl;
exit( 1 );
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/examples/ntester.cc
^
|
@@ -46,7 +46,7 @@
bool server = true;
char *key;
char *ip;
- int port;
+ char *port;
UserStream me, remote;
@@ -59,19 +59,18 @@
key = argv[ 1 ];
ip = argv[ 2 ];
- port = atoi( argv[ 3 ] );
+ port = argv[ 3 ];
n = new Transport<UserStream, UserStream>( me, remote, key, ip, port );
} else {
n = new Transport<UserStream, UserStream>( me, remote, NULL, NULL );
}
- } catch ( const CryptoException &e ) {
- fprintf( stderr, "Fatal error: %s\n", e.text.c_str() );
+ fprintf( stderr, "Port bound is %s, key is %s\n", n->port().c_str(), n->get_key().c_str() );
+ } catch ( const std::exception &e ) {
+ fprintf( stderr, "Fatal startup error: %s\n", e.what() );
exit( 1 );
}
- fprintf( stderr, "Port bound is %d, key is %s\n", n->port(), n->get_key().c_str() );
-
if ( server ) {
Select &sel = Select::get_instance();
uint64_t last_num = n->get_remote_state_num();
@@ -97,8 +96,8 @@
last_num = n->get_remote_state_num();
}
}
- } catch ( const CryptoException &e ) {
- fprintf( stderr, "Cryptographic error: %s\n", e.text.c_str() );
+ } catch ( const std::exception &e ) {
+ fprintf( stderr, "Server error: %s\n", e.what() );
}
}
} else {
@@ -163,11 +162,8 @@
if ( network_ready_to_read ) {
n->recv();
}
- } catch ( const NetworkException &e ) {
- fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
- break;
- } catch ( const CryptoException &e ) {
- fprintf( stderr, "Cryptographic error: %s\n", e.text.c_str() );
+ } catch ( const std::exception &e ) {
+ fprintf( stderr, "Client error: %s\n", e.what() );
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/examples/parse.cc
^
|
@@ -50,6 +50,8 @@
#include <pty.h>
#elif HAVE_UTIL_H
#include <util.h>
+#elif HAVE_LIBUTIL_H
+#include <libutil.h>
#endif
#include "parser.h"
@@ -61,9 +63,9 @@
const size_t buf_size = 1024;
-void emulate_terminal( int fd );
-int copy( int src, int dest );
-int vt_parser( int fd, Parser::UTF8Parser *parser );
+static void emulate_terminal( int fd );
+static int copy( int src, int dest );
+static int vt_parser( int fd, Parser::UTF8Parser *parser );
int main( int argc __attribute__((unused)),
char *argv[] __attribute__((unused)),
@@ -133,7 +135,7 @@
return 0;
}
-void emulate_terminal( int fd )
+static void emulate_terminal( int fd )
{
Parser::UTF8Parser parser;
@@ -164,7 +166,7 @@
}
}
-int copy( int src, int dest )
+static int copy( int src, int dest )
{
char buf[ buf_size ];
@@ -179,7 +181,7 @@
return swrite( dest, buf, bytes_read );
}
-int vt_parser( int fd, Parser::UTF8Parser *parser )
+static int vt_parser( int fd, Parser::UTF8Parser *parser )
{
char buf[ buf_size ];
@@ -204,7 +206,7 @@
if ( act->char_present ) {
if ( iswprint( act->ch ) ) {
- printf( "%s(0x%02x=%lc) ", act->name().c_str(), (unsigned int)act->ch, act->ch );
+ printf( "%s(0x%02x=%lc) ", act->name().c_str(), (unsigned int)act->ch, (wint_t)act->ch );
} else {
printf( "%s(0x%02x) ", act->name().c_str(), (unsigned int)act->ch );
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/examples/termemu.cc
^
|
@@ -51,11 +51,14 @@
#include <sys/types.h>
#include <pwd.h>
#include <sys/time.h>
+#include <exception>
#if HAVE_PTY_H
#include <pty.h>
#elif HAVE_UTIL_H
#include <util.h>
+#elif HAVE_LIBUTIL_H
+#include <libutil.h>
#endif
#include "parser.h"
@@ -68,9 +71,9 @@
const size_t buf_size = 16384;
-void emulate_terminal( int fd );
+static void emulate_terminal( int fd );
-int main( void )
+int main( int argc, char *argv[] )
{
int master;
struct termios saved_termios, raw_termios, child_termios;
@@ -114,19 +117,26 @@
exit( 1 );
}
- /* get shell name */
- struct passwd *pw = getpwuid( geteuid() );
- if ( pw == NULL ) {
- perror( "getpwuid" );
- exit( 1 );
- }
-
char *my_argv[ 2 ];
- my_argv[ 0 ] = strdup( pw->pw_shell );
- assert( my_argv[ 0 ] );
- my_argv[ 1 ] = NULL;
- if ( execv( pw->pw_shell, my_argv ) < 0 ) {
+ if ( argc > 1 ) {
+ argv++;
+ } else {
+ /* get shell name */
+ my_argv[ 0 ] = getenv( "SHELL" );
+ if ( my_argv[ 0 ] == NULL || *my_argv[ 0 ] == '\0' ) {
+ struct passwd *pw = getpwuid( geteuid() );
+ if ( pw == NULL ) {
+ perror( "getpwuid" );
+ exit( 1 );
+ }
+ my_argv[ 0 ] = strdup( pw->pw_shell );
+ }
+ assert( my_argv[ 0 ] );
+ my_argv[ 1 ] = NULL;
+ argv = my_argv;
+ }
+ if ( execvp( argv[ 0 ], argv ) < 0 ) {
perror( "execve" );
exit( 1 );
}
@@ -142,7 +152,11 @@
exit( 1 );
}
- emulate_terminal( master );
+ try {
+ emulate_terminal( master );
+ } catch ( const std::exception &e ) {
+ fprintf( stderr, "\r\nException caught: %s\r\n", e.what() );
+ }
if ( tcsetattr( STDIN_FILENO, TCSANOW, &saved_termios ) < 0 ) {
perror( "tcsetattr" );
@@ -156,8 +170,8 @@
}
/* Print a frame if the last frame was more than 1/50 seconds ago */
-bool tick( Terminal::Framebuffer &state, Terminal::Framebuffer &new_frame,
- const Terminal::Display &display )
+static bool tick( Terminal::Framebuffer &state, Terminal::Framebuffer &new_frame,
+ const Terminal::Display &display )
{
static bool initialized = false;
static struct timeval last_time;
@@ -205,7 +219,7 @@
assume the previous frame was sent to the real terminal.
*/
-void emulate_terminal( int fd )
+static void emulate_terminal( int fd )
{
/* get current window size */
struct winsize window_size;
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/frontend/mosh-client.cc
^
|
@@ -31,9 +31,9 @@
*/
#include "config.h"
+#include "version.h"
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#include "stmclient.h"
@@ -70,15 +70,15 @@
# error "SysV or X/Open-compatible Curses header file required"
#endif
-void usage( const char *argv0 ) {
- fprintf( stderr, "mosh-client (%s)\n", PACKAGE_STRING );
+static void usage( const char *argv0 ) {
+ fprintf( stderr, "mosh-client (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
fprintf( stderr, "Usage: %s IP PORT\n %s -c\n", argv0, argv0 );
}
-void print_colorcount( void )
+static void print_colorcount( void )
{
/* check colors */
setupterm((char *)0, 1, (int *)0);
@@ -93,7 +93,11 @@
printf( "%d\n", color_val );
}
+#ifdef NACL
+int mosh_main( int argc, char *argv[] )
+#else
int main( int argc, char *argv[] )
+#endif
{
/* For security, make sure we don't dump core */
Crypto::disable_dumping_core();
@@ -117,7 +121,6 @@
}
char *ip, *desired_port;
- int port;
if ( argc - optind != 2 ) {
usage( argv[ 0 ] );
@@ -128,13 +131,6 @@
desired_port = argv[ optind + 1 ];
/* Sanity-check arguments */
- if ( ip
- && ( strspn( ip, "0123456789." ) != strlen( ip ) ) ) {
- fprintf( stderr, "%s: Bad IP address (%s)\n\n", argv[ 0 ], ip );
- usage( argv[ 0 ] );
- exit( 1 );
- }
-
if ( desired_port
&& ( strspn( desired_port, "0123456789" ) != strlen( desired_port ) ) ) {
fprintf( stderr, "%s: Bad UDP port (%s)\n\n", argv[ 0 ], desired_port );
@@ -142,8 +138,6 @@
exit( 1 );
}
- port = myatoi( desired_port );
-
/* Read key from environment */
char *env_key = getenv( "MOSH_KEY" );
if ( env_key == NULL ) {
@@ -170,28 +164,25 @@
set_native_locale();
try {
- STMClient client( ip, port, key, predict_mode );
+ STMClient client( ip, desired_port, key, predict_mode );
client.init();
try {
client.main();
- } catch ( const Network::NetworkException &e ) {
- fprintf( stderr, "Network exception: %s: %s\r\n",
- e.function.c_str(), strerror( e.the_errno ) );
- } catch ( const Crypto::CryptoException &e ) {
- fprintf( stderr, "Crypto exception: %s\r\n",
- e.text.c_str() );
+ } catch ( ... ) {
+ client.shutdown();
+ throw;
}
client.shutdown();
- } catch ( const Network::NetworkException& e ) {
- fprintf( stderr, "Network exception: %s: %s\r\n",
- e.function.c_str(), strerror( e.the_errno ) );
- } catch ( const Crypto::CryptoException& e ) {
+ } catch ( const Network::NetworkException &e ) {
+ fprintf( stderr, "Network exception: %s\r\n",
+ e.what() );
+ } catch ( const Crypto::CryptoException &e ) {
fprintf( stderr, "Crypto exception: %s\r\n",
- e.text.c_str() );
- } catch ( const std::string& s ) {
- fprintf( stderr, "Error: %s\r\n", s.c_str() );
+ e.what() );
+ } catch ( const std::exception &e ) {
+ fprintf( stderr, "Error: %s\r\n", e.what() );
}
printf( "\n[mosh is exiting.]\n" );
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/frontend/mosh-server.cc
^
|
@@ -31,6 +31,7 @@
*/
#include "config.h"
+#include "version.h"
#include <errno.h>
#include <locale.h>
@@ -50,8 +51,7 @@
#include <utempter.h>
#endif
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#include <netdb.h>
#include <time.h>
#include <sys/stat.h>
@@ -91,28 +91,28 @@
typedef Network::Transport< Terminal::Complete, Network::UserStream > ServerConnection;
-void serve( int host_fd,
- Terminal::Complete &terminal,
- ServerConnection &network );
-
-int run_server( const char *desired_ip, const char *desired_port,
- const string &command_path, char *command_argv[],
- const int colors, bool verbose, bool with_motd );
+static void serve( int host_fd,
+ Terminal::Complete &terminal,
+ ServerConnection &network );
+
+static int run_server( const char *desired_ip, const char *desired_port,
+ const string &command_path, char *command_argv[],
+ const int colors, bool verbose, bool with_motd );
using namespace std;
-void print_usage( const char *argv0 )
+static void print_usage( const char *argv0 )
{
fprintf( stderr, "Usage: %s new [-s] [-v] [-i LOCALADDR] [-p PORT[:PORT2]] [-c COLORS] [-l NAME=VALUE] [-- COMMAND...]\n", argv0 );
}
-void print_motd( void );
-void chdir_homedir( void );
-bool motd_hushed( void );
-void warn_unattached( const string & ignore_entry );
+static void print_motd( void );
+static void chdir_homedir( void );
+static bool motd_hushed( void );
+static void warn_unattached( const string & ignore_entry );
/* Simple spinloop */
-void spin( void )
+static void spin( void )
{
static unsigned int spincount = 0;
spincount++;
@@ -126,7 +126,7 @@
}
}
-string get_SSH_IP( void )
+static string get_SSH_IP( void )
{
const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" );
if ( !SSH_CONNECTION ) { /* Older sshds don't set this */
@@ -200,7 +200,13 @@
fatal_assert( desired_ip );
break;
case 'c':
- colors = myatoi( optarg );
+ try {
+ colors = myatoi( optarg );
+ } catch ( const CryptoException & ) {
+ fprintf( stderr, "%s: Bad number of colors (%s)\n", argv[ 0 ], optarg );
+ print_usage( argv[ 0 ] );
+ exit( 1 );
+ }
break;
case 'v':
verbose = true;
@@ -227,13 +233,6 @@
}
/* Sanity-check arguments */
- if ( desired_ip
- && ( strspn( desired_ip, "0123456789." ) != strlen( desired_ip ) ) ) {
- fprintf( stderr, "%s: Bad IP address (%s)\n", argv[ 0 ], desired_ip );
- print_usage( argv[ 0 ] );
- exit( 1 );
- }
-
int dpl, dph;
if ( desired_port && ! Connection::parse_portrange( desired_port, dpl, dph ) ) {
fprintf( stderr, "%s: Bad UDP port range (%s)\n", argv[ 0 ], desired_port );
@@ -248,13 +247,17 @@
string shell_name;
if ( !command_argv ) {
/* get shell name */
- struct passwd *pw = getpwuid( geteuid() );
- if ( pw == NULL ) {
- perror( "getpwuid" );
- exit( 1 );
+ const char *shell = getenv( "SHELL" );
+ if ( shell == NULL ) {
+ struct passwd *pw = getpwuid( geteuid() );
+ if ( pw == NULL ) {
+ perror( "getpwuid" );
+ exit( 1 );
+ }
+ shell = pw->pw_shell;
}
- string shell_path( pw->pw_shell );
+ string shell_path( shell );
if ( shell_path.empty() ) { /* empty shell means Bourne shell */
shell_path = _PATH_BSHELL;
}
@@ -317,26 +320,32 @@
try {
return run_server( desired_ip, desired_port, command_path, command_argv, colors, verbose, with_motd );
- } catch ( const Network::NetworkException& e ) {
- fprintf( stderr, "Network exception: %s: %s\n",
- e.function.c_str(), strerror( e.the_errno ) );
+ } catch ( const Network::NetworkException &e ) {
+ fprintf( stderr, "Network exception: %s\n",
+ e.what() );
return 1;
- } catch ( const Crypto::CryptoException& e ) {
+ } catch ( const Crypto::CryptoException &e ) {
fprintf( stderr, "Crypto exception: %s\n",
- e.text.c_str() );
+ e.what() );
return 1;
}
}
-int run_server( const char *desired_ip, const char *desired_port,
- const string &command_path, char *command_argv[],
- const int colors, bool verbose, bool with_motd ) {
+static int run_server( const char *desired_ip, const char *desired_port,
+ const string &command_path, char *command_argv[],
+ const int colors, bool verbose, bool with_motd ) {
/* get initial window size */
struct winsize window_size;
- if ( ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) < 0 ) {
- perror( "ioctl TIOCGWINSZ" );
- fprintf( stderr, "If running with ssh, please use ssh -t to provide a PTY.\n" );
- exit( 1 );
+ if ( ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) < 0 ||
+ window_size.ws_col == 0 ||
+ window_size.ws_row == 0 ) {
+ fprintf( stderr, "Server started without pseudo-terminal. Opening 80x24 terminal.\n" );
+
+ /* Fill in sensible defaults. */
+ /* They will be overwritten by client on first connection. */
+ memset( &window_size, 0, sizeof( window_size ) );
+ window_size.ws_col = 80;
+ window_size.ws_row = 24;
}
/* open parser and terminal */
@@ -350,7 +359,7 @@
network->set_verbose();
}
- printf( "\nMOSH CONNECT %d %s\n", network->port(), network->get_key().c_str() );
+ printf( "\nMOSH CONNECT %s %s\n", network->port().c_str(), network->get_key().c_str() );
fflush( stdout );
/* don't let signals kill us */
@@ -361,13 +370,6 @@
fatal_assert( 0 == sigaction( SIGHUP, &sa, NULL ) );
fatal_assert( 0 == sigaction( SIGPIPE, &sa, NULL ) );
- struct termios child_termios;
-
- /* Get terminal configuration */
- if ( tcgetattr( STDIN_FILENO, &child_termios ) < 0 ) {
- perror( "tcgetattr" );
- exit( 1 );
- }
/* detach from terminal */
pid_t the_pid = fork();
@@ -377,7 +379,7 @@
_exit( 0 );
}
- fprintf( stderr, "\nmosh-server (%s)\n", PACKAGE_STRING );
+ fprintf( stderr, "\nmosh-server (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
@@ -385,13 +387,7 @@
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/frontend/stmclient.cc
^
|
@@ -121,8 +121,75 @@
overlays.set_title_prefix( wstring( L"[mosh] " ) );
}
+ /* Set terminal escape key. */
+ const char *escape_key_env;
+ if ( (escape_key_env = getenv( "MOSH_ESCAPE_KEY" )) != NULL ) {
+ if ( strlen( escape_key_env ) == 1 ) {
+ escape_key = (int)escape_key_env[0];
+ if ( escape_key > 0 && escape_key < 128 ) {
+ if ( escape_key < 32 ) {
+ /* If escape is ctrl-something, pass it with repeating the key without ctrl. */
+ escape_pass_key = escape_key + (int)'@';
+ } else {
+ /* If escape is something else, pass it with repeating the key itself. */
+ escape_pass_key = escape_key;
+ }
+ if ( escape_pass_key >= 'A' && escape_pass_key <= 'Z' ) {
+ /* If escape pass is an upper case character, define optional version
+ as lower case of the same. */
+ escape_pass_key2 = escape_pass_key + (int)'a' - (int)'A';
+ } else {
+ escape_pass_key2 = escape_pass_key;
+ }
+ } else {
+ escape_key = 0x1E;
+ escape_pass_key = '^';
+ escape_pass_key2 = '^';
+ }
+ } else if ( strlen( escape_key_env ) == 0 ) {
+ escape_key = -1;
+ } else {
+ escape_key = 0x1E;
+ escape_pass_key = '^';
+ escape_pass_key2 = '^';
+ }
+ } else {
+ escape_key = 0x1E;
+ escape_pass_key = '^';
+ escape_pass_key2 = '^';
+ }
+
+ /* There are so many better ways to shoot oneself into leg than
+ setting escape key to Ctrl-C, Ctrl-D, NewLine, Ctrl-L or CarriageReturn
+ that we just won't allow that. */
+ if ( escape_key == 0x03 || escape_key == 0x04 || escape_key == 0x0A || escape_key == 0x0C || escape_key == 0x0D ) {
+ escape_key = 0x1E;
+ escape_pass_key = '^';
+ escape_pass_key2 = '^';
+ }
+
+ /* Adjust escape help differently if escape is a control character. */
+ if ( escape_key > 0 ) {
+ char escape_pass_name_buf[16];
+ char escape_key_name_buf[16];
+ snprintf(escape_pass_name_buf, sizeof escape_pass_name_buf, "\"%c\"", escape_pass_key);
+ if (escape_key < 32) {
+ snprintf(escape_key_name_buf, sizeof escape_key_name_buf, "Ctrl-%c", escape_pass_key);
+ escape_requires_lf = false;
+ } else {
+ snprintf(escape_key_name_buf, sizeof escape_key_name_buf, "\"%c\"", escape_key);
+ escape_requires_lf = true;
+ }
+ string tmp;
+ tmp = string( escape_pass_name_buf );
+ wstring escape_pass_name = std::wstring(tmp.begin(), tmp.end());
+ tmp = string( escape_key_name_buf );
+ wstring escape_key_name = std::wstring(tmp.begin(), tmp.end());
+ escape_key_help = L"Commands: Ctrl-Z suspends, \".\" quits, " + escape_pass_name + L" gives literal " + escape_key_name;
+ overlays.get_notification_engine().set_escape_key_string( tmp );
+ }
wchar_t tmp[ 128 ];
- swprintf( tmp, 128, L"Nothing received from server on UDP port %d.", port );
+ swprintf( tmp, 128, L"Nothing received from server on UDP port %s.", port.c_str() );
connecting_notification = wstring( tmp );
}
@@ -143,8 +210,8 @@
}
if ( still_connecting() ) {
- fprintf( stderr, "\nmosh did not make a successful connection to %s:%d.\n", ip.c_str(), port );
- fprintf( stderr, "Please verify that UDP port %d is not firewalled and can reach the server.\n\n", port );
+ fprintf( stderr, "\nmosh did not make a successful connection to %s:%s.\n", ip.c_str(), port.c_str() );
+ fprintf( stderr, "Please verify that UDP port %s is not firewalled and can reach the server.\n\n", port.c_str() );
fprintf( stderr, "(By default, mosh uses a UDP port between 60000 and 61000. The -p option\nselects a specific UDP port number.)\n" );
} else if ( network ) {
if ( !clean_shutdown ) {
@@ -181,7 +248,7 @@
Network::UserStream blank;
Terminal::Complete local_terminal( window_size.ws_col, window_size.ws_row );
network = new Network::Transport< Network::UserStream, Terminal::Complete >( blank, local_terminal,
- key.c_str(), ip.c_str(), port );
+ key.c_str(), ip.c_str(), port.c_str() );
network->set_send_delay( 1 ); /* minimal delay on outgoing keystrokes */
@@ -218,7 +285,7 @@
local_framebuffer = tmp;
}
-bool STMClient::process_network_input( void )
+void STMClient::process_network_input( void )
{
network->recv();
@@ -229,8 +296,6 @@
overlays.get_prediction_engine().set_local_frame_acked( network->get_sent_state_acked() );
overlays.get_prediction_engine().set_send_interval( network->send_interval() );
overlays.get_prediction_engine().set_local_frame_late_acked( network->get_latest_remote_state().state.get_echo_ack() );
-
- return true;
}
bool STMClient::process_user_input( int fd )
@@ -255,8 +320,6 @@
overlays.get_prediction_engine().new_user_byte( the_byte, *local_framebuffer );
- const static wstring help_message( L"Commands: Ctrl-Z suspends, \".\" quits, \"^\" gives literal Ctrl-^" );
-
if ( quit_sequence_started ) {
if ( the_byte == '.' ) { /* Quit sequence is Ctrl-^ . */
if ( network->has_remote_addr() && (!network->shutdown_in_progress()) ) {
@@ -266,7 +329,7 @@
} else {
return false;
}
- } else if ( the_byte == 0x1a ) { /* Suspend sequence is Ctrl-^ Ctrl-Z */
+ } else if ( the_byte == 0x1a ) { /* Suspend sequence is escape_key Ctrl-Z */
/* Restore terminal and terminal-driver state */
swrite( STDOUT_FILENO, display.close().c_str() );
@@ -283,30 +346,34 @@
kill( 0, SIGSTOP );
resume();
- } else if ( the_byte == '^' ) {
- /* Emulation sequence to type Ctrl-^ is Ctrl-^ ^ */
- network->get_current_state().push_back( Parser::UserByte( 0x1E ) );
+ } else if ( (the_byte == escape_pass_key) || (the_byte == escape_pass_key2) ) {
+ /* Emulation sequence to type escape_key is escape_key +
+ escape_pass_key (that is escape key without Ctrl) */
+ network->get_current_state().push_back( Parser::UserByte( escape_key ) );
} else {
- /* Ctrl-^ followed by anything other than . and ^ gets sent literally */
- network->get_current_state().push_back( Parser::UserByte( 0x1E ) );
+ /* Escape key followed by anything other than . and ^ gets sent literally */
+ network->get_current_state().push_back( Parser::UserByte( escape_key ) );
network->get_current_state().push_back( Parser::UserByte( the_byte ) );
}
quit_sequence_started = false;
- if ( overlays.get_notification_engine().get_notification_string() == help_message ) {
+ if ( overlays.get_notification_engine().get_notification_string() == escape_key_help ) {
overlays.get_notification_engine().set_notification_string( L"" );
}
continue;
}
- quit_sequence_started = (the_byte == 0x1E);
+ quit_sequence_started = (escape_key > 0) && (the_byte == escape_key) && (lf_entered || (! escape_requires_lf));
if ( quit_sequence_started ) {
- overlays.get_notification_engine().set_notification_string( help_message, true, false );
+ lf_entered = false;
+ overlays.get_notification_engine().set_notification_string( escape_key_help, true, false );
continue;
}
+ lf_entered = ( (the_byte == 0x0A) || (the_byte == 0x0D) ); /* LineFeed, Ctrl-J, '\n' or CarriageReturn, Ctrl-M, '\r' */
+
if ( the_byte == 0x0C ) { /* Ctrl-L */
repaint_requested = true;
}
@@ -395,7 +462,7 @@
}
if ( network_ready_to_read ) {
- if ( !process_network_input() ) { return; }
+ process_network_input();
}
if ( sel.read( STDIN_FILENO ) ) {
@@ -500,7 +567,7 @@
throw;
} else {
wchar_t tmp[ 128 ];
- swprintf( tmp, 128, L"Crypto exception: %s", e.text.c_str() );
+ swprintf( tmp, 128, L"Crypto exception: %s", e.what() );
overlays.get_notification_engine().set_notification_string( wstring( tmp ) );
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/frontend/stmclient.h
^
|
@@ -45,9 +45,15 @@
class STMClient {
private:
std::string ip;
- int port;
+ std::string port;
std::string key;
+ int escape_key;
+ int escape_pass_key;
+ int escape_pass_key2;
+ bool escape_requires_lf;
+ std::wstring escape_key_help;
+
struct termios saved_termios, raw_termios;
struct winsize window_size;
@@ -58,11 +64,11 @@
Terminal::Display display;
std::wstring connecting_notification;
- bool repaint_requested, quit_sequence_started;
+ bool repaint_requested, lf_entered, quit_sequence_started;
bool clean_shutdown;
void main_init( void );
- bool process_network_input( void );
+ void process_network_input( void );
bool process_user_input( int fd );
bool process_resize( void );
@@ -77,8 +83,10 @@
void resume( void ); /* restore state after SIGCONT */
public:
- STMClient( const char *s_ip, int s_port, const char *s_key, const char *predict_mode )
+ STMClient( const char *s_ip, const char *s_port, const char *s_key, const char *predict_mode )
: ip( s_ip ), port( s_port ), key( s_key ),
+ escape_key( 0x1E ), escape_pass_key( '^' ), escape_pass_key2( '^' ),
+ escape_requires_lf( false ), escape_key_help( L"?" ),
saved_termios(), raw_termios(),
window_size(),
local_framebuffer( NULL ),
@@ -88,6 +96,7 @@
display( true ), /* use TERM environment var to initialize display */
connecting_notification(),
repaint_requested( false ),
+ lf_entered( false ),
quit_sequence_started( false ),
clean_shutdown( false )
{
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/frontend/terminaloverlay.cc
^
|
@@ -166,6 +166,7 @@
NotificationEngine::NotificationEngine()
: last_word_from_server( timestamp() ),
last_acked_state( timestamp() ),
+ escape_key_string(),
message(),
message_is_network_exception( false ),
message_expiration( -1 ),
@@ -233,22 +234,24 @@
explanation = reply_message;
}
- const static char quit_keystroke[] = " [To quit: Ctrl-^ .]";
const static char blank[] = "";
- const char *keystroke_str = show_quit_keystroke ? quit_keystroke : blank;
+ const char *keystroke_str = show_quit_keystroke ? escape_key_string.c_str() : blank;
if ( message.empty() && (!time_expired) ) {
return;
} else if ( message.empty() && time_expired ) {
swprintf( tmp, 128, L"mosh: Last %s %s ago.%s", explanation,
- human_readable_duration( time_elapsed, "seconds" ).c_str(),
+ human_readable_duration( static_cast<int>( time_elapsed ),
+ "seconds" ).c_str(),
keystroke_str );
} else if ( (!message.empty()) && (!time_expired) ) {
swprintf( tmp, 128, L"mosh: %ls%s", message.c_str(), keystroke_str );
} else {
swprintf( tmp, 128, L"mosh: %ls (%s without %s.)%s", message.c_str(),
- human_readable_duration( time_elapsed, "s" ).c_str(), explanation, keystroke_str );
+ human_readable_duration( static_cast<int>( time_elapsed ),
+ "s" ).c_str(),
+ explanation, keystroke_str );
}
wstring string_to_draw( tmp );
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/frontend/terminaloverlay.h
^
|
@@ -40,6 +40,7 @@
#include <vector>
#include <limits.h>
+#include <exception>
namespace Overlay {
using namespace Terminal;
@@ -144,6 +145,7 @@
private:
uint64_t last_word_from_server;
uint64_t last_acked_state;
+ string escape_key_string;
wstring message;
bool message_is_network_exception;
uint64_t message_expiration;
@@ -173,10 +175,17 @@
show_quit_keystroke = s_show_quit_keystroke;
}
- void set_network_exception( const NetworkException &e )
+ void set_escape_key_string( const string &s_name )
+ {
+ char tmp[ 128 ];
+ snprintf( tmp, sizeof tmp, " [To quit: %s .]", s_name.c_str() );
+ escape_key_string = tmp;
+ }
+
+ void set_network_exception( const std::exception &e )
{
wchar_t tmp[ 128 ];
- swprintf( tmp, 128, L"%s: %s", e.function.c_str(), strerror( e.the_errno ) );
+ swprintf( tmp, 128, L"%s", e.what() );
message = tmp;
message_is_network_exception = true;
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/network/network.cc
^
|
@@ -37,13 +37,14 @@
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif
+#include <netdb.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include "dos_assert.h"
+#include "fatal_assert.h"
#include "byteorder.h"
#include "network.h"
#include "crypto.h"
@@ -54,6 +55,10 @@
#define MSG_DONTWAIT MSG_NONBLOCK
#endif
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV 0
+#endif
+
using namespace std;
using namespace Network;
using namespace Crypto;
@@ -119,6 +124,8 @@
assert( !server );
setup();
+ assert( remote_addr_len != 0 );
+ socks.push_back( Socket( remote_addr.sa.sa_family ) );
prune_sockets();
}
@@ -146,8 +153,8 @@
}
}
-Connection::Socket::Socket()
- : _fd( socket( AF_INET, SOCK_DGRAM, 0 ) )
+Connection::Socket::Socket( int family )
+ : _fd( socket( family, SOCK_DGRAM, 0 ) )
{
if ( _fd < 0 ) {
throw NetworkException( "socket", errno );
@@ -180,9 +187,6 @@
void Connection::setup( void )
{
- /* create socket */
- socks.push_back( Socket() );
-
last_port_choice = timestamp();
}
@@ -199,10 +203,28 @@
return ret;
}
+class AddrInfo {
+public:
+ struct addrinfo *res;
+ AddrInfo( const char *node, const char *service,
+ const struct addrinfo *hints ) :
+ res( NULL ) {
+ int errcode = getaddrinfo( node, service, hints, &res );
+ if ( errcode != 0 ) {
+ throw NetworkException( std::string( "Bad IP address (" ) + (node != NULL ? node : "(null)") + "): " + gai_strerror( errcode ), 0 );
+ }
+ }
+ ~AddrInfo() { freeaddrinfo(res); }
+private:
+ AddrInfo(const AddrInfo &);
+ AddrInfo &operator=(const AddrInfo &);
+};
+
Connection::Connection( const char *desired_ip, const char *desired_port ) /* server */
: socks(),
has_remote_addr( false ),
remote_addr(),
+ remote_addr_len( 0 ),
server( true ),
MTU( DEFAULT_SEND_MTU ),
key(),
@@ -237,36 +259,23 @@
throw NetworkException("Invalid port range", 0);
}
- /* convert desired IP */
- uint32_t desired_ip_addr = INADDR_ANY;
-
- if ( desired_ip ) {
- struct in_addr sin_addr;
- if ( inet_aton( desired_ip, &sin_addr ) == 0 ) {
- throw NetworkException( "Invalid IP address", errno );
- }
- desired_ip_addr = sin_addr.s_addr;
- }
-
/* try to bind to desired IP first */
- if ( desired_ip_addr != INADDR_ANY ) {
+ if ( desired_ip ) {
try {
- if ( try_bind( sock(), desired_ip_addr, desired_port_low, desired_port_high ) ) { return; }
- } catch ( const NetworkException& e ) {
- struct in_addr sin_addr;
- sin_addr.s_addr = desired_ip_addr;
- fprintf( stderr, "Error binding to IP %s: %s: %s\n",
- inet_ntoa( sin_addr ),
- e.function.c_str(), strerror( e.the_errno ) );
+ if ( try_bind( desired_ip, desired_port_low, desired_port_high ) ) { return; }
+ } catch ( const NetworkException &e ) {
+ fprintf( stderr, "Error binding to IP %s: %s\n",
+ desired_ip,
+ e.what() );
}
}
/* now try any local interface */
try {
- if ( try_bind( sock(), INADDR_ANY, desired_port_low, desired_port_high ) ) { return; }
- } catch ( const NetworkException& e ) {
- fprintf( stderr, "Error binding to any interface: %s: %s\n",
- e.function.c_str(), strerror( e.the_errno ) );
+ if ( try_bind( NULL, desired_port_low, desired_port_high ) ) { return; }
+ } catch ( const NetworkException &e ) {
+ fprintf( stderr, "Error binding to any interface: %s\n",
+ e.what() );
throw; /* this time it's fatal */
}
@@ -274,11 +283,18 @@
throw NetworkException( "Could not bind", errno );
}
-bool Connection::try_bind( int socket, uint32_t addr, int port_low, int port_high )
+bool Connection::try_bind( const char *addr, int port_low, int port_high )
{
- struct sockaddr_in local_addr;
- local_addr.sin_family = AF_INET;
- local_addr.sin_addr.s_addr = addr;
+ struct addrinfo hints;
+ memset( &hints, 0, sizeof( hints ) );
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV;
+ AddrInfo ai( addr, "0", &hints );
+
+ Addr local_addr;
+ socklen_t local_addr_len = ai.res->ai_addrlen;
+ memcpy( &local_addr.sa, ai.res->ai_addr, local_addr_len );
int search_low = PORT_RANGE_LOW, search_high = PORT_RANGE_HIGH;
@@ -289,16 +305,34 @@
search_high = port_high;
}
+ socks.push_back( Socket( local_addr.sa.sa_family ) );
for ( int i = search_low; i <= search_high; i++ ) {
- local_addr.sin_port = htons( i );
+ switch (local_addr.sa.sa_family) {
+ case AF_INET:
+ local_addr.sin.sin_port = htons( i );
+ break;
+ case AF_INET6:
+ local_addr.sin6.sin6_port = htons( i );
+ break;
+ default:
+ throw NetworkException( "Unknown address family", 0 );
+ }
- if ( bind( socket, (sockaddr *)&local_addr, sizeof( local_addr ) ) == 0 ) {
+ if ( bind( sock(), &local_addr.sa, local_addr_len ) == 0 ) {
return true;
} else if ( i == search_high ) { /* last port to search */
- fprintf( stderr, "Failed binding to %s:%d\n",
- inet_ntoa( local_addr.sin_addr ),
- ntohs( local_addr.sin_port ) );
- throw NetworkException( "bind", errno );
+ int saved_errno = errno;
+ socks.pop_back();
+ char host[ NI_MAXHOST ], serv[ NI_MAXSERV ];
+ int errcode = getnameinfo( &local_addr.sa, local_addr_len,
+ host, sizeof( host ), serv, sizeof( serv ),
+ NI_DGRAM | NI_NUMERICHOST | NI_NUMERICSERV );
+ if ( errcode != 0 ) {
+ throw NetworkException( std::string( "bind: getnameinfo: " ) + gai_strerror( errcode ), 0 );
+ }
+ fprintf( stderr, "Failed binding to %s:%s\n",
+ host, serv );
+ throw NetworkException( "bind", saved_errno );
}
}
@@ -306,10 +340,11 @@
return false;
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/network/network.h
^
|
@@ -41,6 +41,8 @@
#include <math.h>
#include <vector>
#include <assert.h>
+#include <exception>
+#include <string.h>
#include "crypto.h"
@@ -53,12 +55,18 @@
uint16_t timestamp16( void );
uint16_t timestamp_diff( uint16_t tsnew, uint16_t tsold );
- class NetworkException {
+ class NetworkException : public std::exception {
public:
string function;
int the_errno;
- NetworkException( string s_function, int s_errno ) : function( s_function ), the_errno( s_errno ) {}
- NetworkException() : function( "<none>" ), the_errno( 0 ) {}
+ private:
+ string my_what;
+ public:
+ NetworkException( string s_function="<none>", int s_errno=0)
+ : function( s_function ), the_errno( s_errno ),
+ my_what(function + ": " + strerror(the_errno)) {}
+ const char *what() const throw () { return my_what.c_str(); }
+ ~NetworkException() throw () {}
};
enum Direction {
@@ -84,6 +92,13 @@
string tostring( Session *session );
};
+ union Addr {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ struct sockaddr_storage ss;
+ };
+
class Connection {
private:
static const int DEFAULT_SEND_MTU = 1300;
@@ -101,7 +116,7 @@
static const int CONGESTION_TIMESTAMP_PENALTY = 500; /* ms */
- static bool try_bind( int socket, uint32_t addr, int port_low, int port_high );
+ bool try_bind( const char *addr, int port_low, int port_high );
class Socket
{
@@ -110,7 +125,7 @@
public:
int fd( void ) const { return _fd; }
- Socket();
+ Socket( int family );
~Socket();
Socket( const Socket & other );
@@ -119,7 +134,8 @@
std::deque< Socket > socks;
bool has_remote_addr;
- struct sockaddr_in remote_addr;
+ Addr remote_addr;
+ socklen_t remote_addr_len;
bool server;
@@ -161,21 +177,22 @@
public:
Connection( const char *desired_ip, const char *desired_port ); /* server */
- Connection( const char *key_str, const char *ip, int port ); /* client */
+ Connection( const char *key_str, const char *ip, const char *port ); /* client */
void send( string s );
string recv( void );
const std::vector< int > fds( void ) const;
int get_MTU( void ) const { return MTU; }
- int port( void ) const;
+ std::string port( void ) const;
string get_key( void ) const { return key.printable_key(); }
bool get_has_remote_addr( void ) const { return has_remote_addr; }
uint64_t timeout( void ) const;
double get_SRTT( void ) const { return SRTT; }
- const struct in_addr & get_remote_ip( void ) const { return remote_addr.sin_addr; }
+ const Addr &get_remote_addr( void ) const { return remote_addr; }
+ socklen_t get_remote_addr_len( void ) const { return remote_addr_len; }
const NetworkException *get_send_exception( void ) const
{
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/network/networktransport.cc
^
|
@@ -55,7 +55,7 @@
template <class MyState, class RemoteState>
Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState &initial_remote,
- const char *key_str, const char *ip, int port )
+ const char *key_str, const char *ip, const char *port )
: connection( key_str, ip, port ),
sender( &connection, initial_state ),
received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) ),
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/network/networktransport.h
^
|
@@ -69,7 +69,7 @@
Transport( MyState &initial_state, RemoteState &initial_remote,
const char *desired_ip, const char *desired_port );
Transport( MyState &initial_state, RemoteState &initial_remote,
- const char *key_str, const char *ip, int port );
+ const char *key_str, const char *ip, const char *port );
/* Send data or an ack if necessary. */
void tick( void ) { sender.tick(); }
@@ -94,7 +94,7 @@
/* Other side has requested shutdown and we have sent one ACK */
bool counterparty_shutdown_ack_sent( void ) const { return sender.get_counterparty_shutdown_acknowledged(); }
- int port( void ) const { return connection.port(); }
+ std::string port( void ) const { return connection.port(); }
string get_key( void ) const { return connection.get_key(); }
MyState &get_current_state( void ) { return sender.get_current_state(); }
@@ -116,7 +116,8 @@
unsigned int send_interval( void ) const { return sender.send_interval(); }
- const struct in_addr & get_remote_ip( void ) const { return connection.get_remote_ip(); }
+ const Addr &get_remote_addr( void ) const { return connection.get_remote_addr(); }
+ socklen_t get_remote_addr_len( void ) const { return connection.get_remote_addr_len(); }
const NetworkException *get_send_exception( void ) const { return connection.get_send_exception(); }
};
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/network/transportfragment.cc
^
|
@@ -148,7 +148,7 @@
return ret;
}
-bool Fragment::operator==( const Fragment &x )
+bool Fragment::operator==( const Fragment &x ) const
{
return ( id == x.id ) && ( fragment_num == x.fragment_num ) && ( final == x.final )
&& ( initialized == x.initialized ) && ( contents == x.contents );
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/network/transportfragment.h
^
|
@@ -73,7 +73,7 @@
string tostring( void );
- bool operator==( const Fragment &x );
+ bool operator==( const Fragment &x ) const;
};
class FragmentAssembly
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/statesync/completeterminal.h
^
|
@@ -70,7 +70,7 @@
int wait_time( uint64_t now ) const;
/* interface for Network::Transport */
- void subtract( const Complete * ) {}
+ void subtract( const Complete * ) const {}
std::string diff_from( const Complete &existing ) const;
void apply_string( std::string diff );
bool operator==( const Complete &x ) const;
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/statesync/user.cc
^
|
@@ -123,7 +123,7 @@
}
}
-const Parser::Action *UserStream::get_action( unsigned int i )
+const Parser::Action *UserStream::get_action( unsigned int i ) const
{
switch( actions[ i ].type ) {
case UserByteType:
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/statesync/user.h
^
|
@@ -84,7 +84,7 @@
bool empty( void ) const { return actions.empty(); }
size_t size( void ) const { return actions.size(); }
- const Parser::Action *get_action( unsigned int i );
+ const Parser::Action *get_action( unsigned int i ) const;
/* interface for Network::Transport */
void subtract( const UserStream *prefix );
@@ -92,7 +92,7 @@
void apply_string( string diff );
bool operator==( const UserStream &x ) const { return actions == x.actions; }
- bool compare( const UserStream & ) const { return false; }
+ bool compare( const UserStream & ) { return false; }
};
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/parser.cc
^
|
@@ -41,7 +41,7 @@
const Parser::StateFamily Parser::family;
static void append_or_delete( Parser::Action *act,
- std::list<Parser::Action *>&vec )
+ std::list<Parser::Action *> &vec )
{
assert( act );
@@ -63,6 +63,7 @@
}
append_or_delete( tx.action, ret );
+ tx.action = NULL;
if ( tx.next_state != NULL ) {
append_or_delete( tx.next_state->enter(), ret );
@@ -76,6 +77,7 @@
: parser(), buf_len( 0 )
{
assert( BUF_SIZE >= (size_t)MB_CUR_MAX );
+ buf[0] = '\0';
}
std::list<Parser::Action *> Parser::UTF8Parser::input( char c )
@@ -104,9 +106,6 @@
/* this returns 0 when n = 0! */
- /* This function annoying returns a size_t so we have to check
- the negative values first before the "> 0" branch */
-
if ( bytes_parsed == 0 ) {
/* character was NUL, accept and clear buffer */
assert( buf_len == 1 );
@@ -129,13 +128,11 @@
/* can't parse incomplete multibyte character */
total_bytes_parsed += buf_len;
continue;
- } else if ( bytes_parsed > 0 ) {
+ } else {
/* parsed into pwc, accept */
assert( bytes_parsed <= buf_len );
memmove( buf, buf + bytes_parsed, buf_len - bytes_parsed );
buf_len = buf_len - bytes_parsed;
- } else {
- throw std::string( "Unknown return value from mbrtowc" );
}
/* Cast to unsigned for checks, because some
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/parseraction.cc
^
|
@@ -43,7 +43,7 @@
char thechar[ 10 ] = { 0 };
if ( char_present ) {
if ( iswprint( ch ) )
- snprintf( thechar, 10, "(%lc)", ch );
+ snprintf( thechar, 10, "(%lc)", (wint_t)ch );
else
snprintf( thechar, 10, "(0x%x)", (unsigned int)ch );
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/parserstate.cc
^
|
@@ -56,7 +56,7 @@
return Transition( &family->s_CSI_Entry );
}
- return Transition( NULL, NULL ); /* don't allocate an Ignore action */
+ return Transition(( State * )NULL, NULL ); /* don't allocate an Ignore action */
}
Transition State::input( wchar_t ch ) const
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/parsertransition.h
^
|
@@ -43,6 +43,8 @@
class Transition
{
public:
+ // Transition is only a courier for an Action; it should
+ // never create/delete one on its own.
Action *action;
State *next_state;
@@ -56,14 +58,21 @@
return *this;
}
- virtual ~Transition() {}
+ virtual ~Transition()
+ {
+ // Indicate to checkers that we don't own *action anymore
+ action = NULL;
+ }
Transition( Action *s_action=new Ignore, State *s_next_state=NULL )
: action( s_action ), next_state( s_next_state )
{}
- Transition( State *s_next_state )
- : action( new Ignore ), next_state( s_next_state )
+ // This is only ever used in the 1-argument form;
+ // we use this instead of an initializer to
+ // tell Coverity the object never owns *action.
+ Transition( State *s_next_state, Action *s_action=new Ignore )
+ : action( s_action ), next_state( s_next_state )
{}
};
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/terminaldisplay.cc
^
|
@@ -51,7 +51,10 @@
std::string Display::close() const
{
- return std::string( "\033[?1l\033[0m\033[?25h" ) + std::string( rmcup ? rmcup : "" );
+ return std::string( "\033[?1l\033[0m\033[?25h"
+ "\033[?1003l\033[?1002l\033[?1001l\033[?1000l"
+ "\033[?1015l\033[?1006l\033[?1005l" ) +
+ std::string( rmcup ? rmcup : "" );
}
std::string Display::new_frame( bool initialized, const Framebuffer &last, const Framebuffer &f ) const
@@ -78,7 +81,7 @@
for ( std::deque<wchar_t>::const_iterator i = window_title.begin();
i != window_title.end();
i++ ) {
- snprintf( tmp, 64, "%lc", *i );
+ snprintf( tmp, 64, "%lc", (wint_t)*i );
frame.append( tmp );
}
frame.append( "\007" );
@@ -90,7 +93,7 @@
for ( std::deque<wchar_t>::const_iterator i = icon_name.begin();
i != icon_name.end();
i++ ) {
- snprintf( tmp, 64, "%lc", *i );
+ snprintf( tmp, 64, "%lc", (wint_t)*i );
frame.append( tmp );
}
frame.append( "\007" );
@@ -100,7 +103,7 @@
for ( std::deque<wchar_t>::const_iterator i = window_title.begin();
i != window_title.end();
i++ ) {
- snprintf( tmp, 64, "%lc", *i );
+ snprintf( tmp, 64, "%lc", (wint_t)*i );
frame.append( tmp );
}
frame.append( "\007" );
@@ -143,7 +146,7 @@
int lines_scrolled = 0;
int scroll_height = 0;
- for ( int row = 0; row < f.ds.get_height(); row++ ) {
+ for ( int row = 0; row < frame.last_frame.ds.get_height(); row++ ) {
if ( *(f.get_row( 0 )) == *(frame.last_frame.get_row( row )) ) {
/* found a scroll */
lines_scrolled = row;
@@ -286,6 +289,53 @@
frame.current_rendition = f.ds.get_renditions();
}
+ /* has bracketed paste mode changed? */
+ if ( (!initialized)
+ || (f.ds.bracketed_paste != frame.last_frame.ds.bracketed_paste) ) {
+ frame.append( f.ds.bracketed_paste ? "\033[?2004h" : "\033[?2004l" );
+ }
+
+ /* has mouse reporting mode changed? */
+ if ( (!initialized)
+ || (f.ds.mouse_reporting_mode != frame.last_frame.ds.mouse_reporting_mode) ) {
+ if (f.ds.mouse_reporting_mode == DrawState::MOUSE_REPORTING_NONE) {
+ frame.append("\033[?1003l");
+ frame.append("\033[?1002l");
+ frame.append("\033[?1001l");
+ frame.append("\033[?1000l");
+ } else {
+ if (frame.last_frame.ds.mouse_reporting_mode != DrawState::MOUSE_REPORTING_NONE) {
+ snprintf(tmp, sizeof(tmp), "\033[?%dl", frame.last_frame.ds.mouse_reporting_mode);
+ frame.append(tmp);
+ }
+ snprintf(tmp, sizeof(tmp), "\033[?%dh", f.ds.mouse_reporting_mode);
+ frame.append(tmp);
+ }
+ }
+
+ /* has mouse focus mode changed? */
+ if ( (!initialized)
+ || (f.ds.mouse_focus_event != frame.last_frame.ds.mouse_focus_event) ) {
+ frame.append( f.ds.mouse_focus_event ? "\033[?1004h" : "\033[?1004l" );
+ }
+
+ /* has mouse encoding mode changed? */
+ if ( (!initialized)
+ || (f.ds.mouse_encoding_mode != frame.last_frame.ds.mouse_encoding_mode) ) {
+ if (f.ds.mouse_encoding_mode == DrawState::MOUSE_ENCODING_DEFAULT) {
+ frame.append("\033[?1015l");
+ frame.append("\033[?1006l");
+ frame.append("\033[?1005l");
+ } else {
+ if (frame.last_frame.ds.mouse_encoding_mode != DrawState::MOUSE_ENCODING_DEFAULT) {
+ snprintf(tmp, sizeof(tmp), "\033[?%dl", frame.last_frame.ds.mouse_encoding_mode);
+ frame.append(tmp);
+ }
+ snprintf(tmp, sizeof(tmp), "\033[?%dh", f.ds.mouse_encoding_mode);
+ frame.append(tmp);
+ }
+ }
+
return frame.str;
}
@@ -371,7 +421,7 @@
for ( std::vector<wchar_t>::const_iterator i = cell->contents.begin();
i != cell->contents.end();
i++ ) {
- snprintf( tmp, 64, "%lc", *i );
+ snprintf( tmp, 64, "%lc", (wint_t)*i );
frame.append( tmp );
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/terminaldisplay.h
^
|
@@ -65,9 +65,9 @@
class Display {
private:
- bool ti_flag( const char *capname ) const;
- int ti_num( const char *capname ) const;
- const char *ti_str( const char *capname ) const;
+ static bool ti_flag( const char *capname );
+ static int ti_num( const char *capname );
+ static const char *ti_str( const char *capname );
bool has_ech; /* erase character is part of vt200 but not supported by tmux
(or by "screen" terminfo entry, which is what tmux advertises) */
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/terminaldisplayinit.cc
^
|
@@ -37,6 +37,7 @@
#include "terminaldisplay.h"
#include <string>
+#include <stdexcept>
#if defined HAVE_NCURSESW_CURSES_H
# include <ncursesw/curses.h>
@@ -61,29 +62,29 @@
using namespace Terminal;
-bool Display::ti_flag( const char *capname ) const
+bool Display::ti_flag( const char *capname )
{
int val = tigetflag( const_cast<char *>( capname ) );
if ( val == -1 ) {
- throw std::string( "Invalid terminfo boolean capability " ) + capname;
+ throw std::invalid_argument( std::string( "Invalid terminfo boolean capability " ) + capname );
}
return val;
}
-int Display::ti_num( const char *capname ) const
+int Display::ti_num( const char *capname )
{
int val = tigetnum( const_cast<char *>( capname ) );
if ( val == -2 ) {
- throw std::string( "Invalid terminfo numeric capability " ) + capname;
+ throw std::invalid_argument( std::string( "Invalid terminfo numeric capability " ) + capname );
}
return val;
}
-const char *Display::ti_str( const char *capname ) const
+const char *Display::ti_str( const char *capname )
{
const char *val = tigetstr( const_cast<char *>( capname ) );
if ( val == (const char *)-1 ) {
- throw std::string( "Invalid terminfo string capability " ) + capname;
+ throw std::invalid_argument( std::string( "Invalid terminfo string capability " ) + capname );
}
return val;
}
@@ -98,16 +99,16 @@
if ( ret != OK ) {
switch ( errret ) {
case 1:
- throw std::string( "Terminal is hardcopy and cannot be used by curses applications." );
+ throw std::runtime_error( "Terminal is hardcopy and cannot be used by curses applications." );
break;
case 0:
- throw std::string( "Unknown terminal type." );
+ throw std::runtime_error( "Unknown terminal type." );
break;
case -1:
- throw std::string( "Terminfo database could not be found." );
+ throw std::runtime_error( "Terminfo database could not be found." );
break;
default:
- throw std::string( "Unknown terminfo error." );
+ throw std::runtime_error( "Unknown terminfo error." );
break;
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/terminalframebuffer.cc
^
|
@@ -62,7 +62,8 @@
renditions( 0 ), save(),
next_print_will_wrap( false ), origin_mode( false ), auto_wrap_mode( true ),
insert_mode( false ), cursor_visible( true ), reverse_video( false ),
- application_mode_cursor_keys( false )
+ bracketed_paste( false ), mouse_reporting_mode( MOUSE_REPORTING_NONE ), mouse_focus_event( false ),
+ mouse_alternate_scroll( false ), mouse_encoding_mode( MOUSE_ENCODING_DEFAULT ), application_mode_cursor_keys( false )
{
reinitialize_tabs( 0 );
}
@@ -182,7 +183,7 @@
tabs[ col ] = false;
}
-int DrawState::get_next_tab( void )
+int DrawState::get_next_tab( void ) const
{
for ( int i = cursor_col + 1; i < width; i++ ) {
if ( tabs[ i ] ) {
@@ -214,12 +215,12 @@
}
}
-int DrawState::limit_top( void )
+int DrawState::limit_top( void ) const
{
return origin_mode ? scrolling_region_top_row : 0;
}
-int DrawState::limit_bottom( void )
+int DrawState::limit_bottom( void ) const
{
return origin_mode ? scrolling_region_bottom_row : height - 1;
}
@@ -388,7 +389,7 @@
}
Renditions::Renditions( int s_background )
- : bold( false ), underlined( false ), blink( false ),
+ : bold( false ), italic( false ), underlined( false ), blink( false ),
inverse( false ), invisible( false ), foreground_color( 0 ),
background_color( s_background )
{}
@@ -397,7 +398,7 @@
void Renditions::set_rendition( int num )
{
if ( num == 0 ) {
- bold = underlined = blink = inverse = invisible = false;
+ bold = italic = underlined = blink = inverse = invisible = false;
foreground_color = background_color = 0;
return;
}
@@ -426,6 +427,7 @@
switch ( num ) {
case 1: case 22: bold = (num == 1); break;
+ case 3: case 23: italic = (num == 3); break;
case 4: case 24: underlined = (num == 4); break;
case 5: case 25: blink = (num == 5); break;
case 7: case 27: inverse = (num == 7); break;
@@ -453,6 +455,7 @@
ret.append( "\033[0" );
if ( bold ) ret.append( ";1" );
+ if ( italic ) ret.append( ";3" );
if ( underlined ) ret.append( ";4" );
if ( blink ) ret.append( ";5" );
if ( inverse ) ret.append( ";7" );
@@ -570,7 +573,7 @@
}
}
-wchar_t Cell::debug_contents( void ) const
+wint_t Cell::debug_contents( void ) const
{
if ( contents.empty() ) {
return '_';
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/terminalframebuffer.h
^
|
@@ -44,7 +44,7 @@
namespace Terminal {
class Renditions {
public:
- bool bold, underlined, blink, inverse, invisible;
+ bool bold, italic, underlined, blink, inverse, invisible;
int foreground_color;
int background_color;
@@ -58,7 +58,7 @@
bool operator==( const Renditions &x ) const
{
- return (bold == x.bold) && (underlined == x.underlined)
+ return (bold == x.bold) && (italic == x.italic) && (underlined == x.underlined)
&& (blink == x.blink) && (inverse == x.inverse)
&& (invisible == x.invisible) && (foreground_color == x.foreground_color)
&& (background_color == x.background_color);
@@ -102,7 +102,7 @@
&& (wrap == x.wrap) );
}
- wchar_t debug_contents( void ) const;
+ wint_t debug_contents( void ) const;
bool is_blank( void ) const
{
@@ -111,7 +111,7 @@
|| (contents.front() == 0xA0) ) ) );
}
- bool contents_match ( const Cell& other ) const
+ bool contents_match ( const Cell &other ) const
{
return ( is_blank() && other.is_blank() )
|| ( contents == other.contents );
@@ -189,6 +189,26 @@
bool insert_mode;
bool cursor_visible;
bool reverse_video;
+ bool bracketed_paste;
+
+ enum MouseReportingMode {
+ MOUSE_REPORTING_NONE = 0,
+ MOUSE_REPORTING_X10 = 9,
+ MOUSE_REPORTING_VT220 = 1000,
+ MOUSE_REPORTING_VT220_HILIGHT = 1001,
+ MOUSE_REPORTING_BTN_EVENT = 1002,
+ MOUSE_REPORTING_ANY_EVENT = 1003
+ } mouse_reporting_mode;
+
+ bool mouse_focus_event; // 1004
+ bool mouse_alternate_scroll; // 1007
+
+ enum MouseEncodingMode {
+ MOUSE_ENCODING_DEFAULT = 0,
+ MOUSE_ENCODING_UTF8 = 1005,
+ MOUSE_ENCODING_SGR = 1006,
+ MOUSE_ENCODING_URXVT = 1015
+ } mouse_encoding_mode;
bool application_mode_cursor_keys;
@@ -208,15 +228,15 @@
void clear_tab( int col );
void clear_default_tabs( void ) { default_tabs = false; }
/* Default tabs can't be restored without resetting the draw state. */
- int get_next_tab( void );
+ int get_next_tab( void ) const;
void set_scrolling_region( int top, int bottom );
int get_scrolling_region_top_row( void ) const { return scrolling_region_top_row; }
int get_scrolling_region_bottom_row( void ) const { return scrolling_region_bottom_row; }
- int limit_top( void );
- int limit_bottom( void );
+ int limit_top( void ) const;
+ int limit_bottom( void ) const;
void set_foreground_color( int x ) { renditions.set_foreground_color( x ); }
void set_background_color( int x ) { renditions.set_background_color( x ); }
@@ -237,7 +257,10 @@
/* only compare fields that affect display */
return ( width == x.width ) && ( height == x.height ) && ( cursor_col == x.cursor_col )
&& ( cursor_row == x.cursor_row ) && ( cursor_visible == x.cursor_visible ) &&
- ( reverse_video == x.reverse_video ) && ( renditions == x.renditions );
+ ( reverse_video == x.reverse_video ) && ( renditions == x.renditions ) &&
+ ( bracketed_paste == x.bracketed_paste ) && ( mouse_reporting_mode == x.mouse_reporting_mode ) &&
+ ( mouse_focus_event == x.mouse_focus_event ) && ( mouse_alternate_scroll == x.mouse_alternate_scroll) &&
+ ( mouse_encoding_mode == x.mouse_encoding_mode );
}
};
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/terminal/terminalfunctions.cc
^
|
@@ -50,7 +50,7 @@
}
/* erase in line */
-void CSI_EL( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_EL( Framebuffer *fb, Dispatcher *dispatch )
{
switch ( dispatch->getparam( 0, 0 ) ) {
case 0: /* default: active position to end of line, inclusive */
@@ -68,7 +68,7 @@
static Function func_CSI_EL( CSI, "K", CSI_EL );
/* erase in display */
-void CSI_ED( Framebuffer *fb, Dispatcher *dispatch ) {
+static void CSI_ED( Framebuffer *fb, Dispatcher *dispatch ) {
switch ( dispatch->getparam( 0, 0 ) ) {
case 0: /* active position to end of screen, inclusive */
clearline( fb, -1, fb->ds.get_cursor_col(), fb->ds.get_width() - 1 );
@@ -93,7 +93,7 @@
static Function func_CSI_ED( CSI, "J", CSI_ED );
/* cursor movement -- relative and absolute */
-void CSI_cursormove( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_cursormove( Framebuffer *fb, Dispatcher *dispatch )
{
int num = dispatch->getparam( 0, 1 );
@@ -127,7 +127,7 @@
static Function func_CSI_cursormove_f( CSI, "f", CSI_cursormove );
/* device attributes */
-void CSI_DA( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch )
+static void CSI_DA( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch )
{
dispatch->terminal_to_host.append( "\033[?62c" ); /* plain vt220 */
}
@@ -135,7 +135,7 @@
static Function func_CSI_DA( CSI, "c", CSI_DA );
/* secondary device attributes */
-void CSI_SDA( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch )
+static void CSI_SDA( Framebuffer *fb __attribute((unused)), Dispatcher *dispatch )
{
dispatch->terminal_to_host.append( "\033[>1;10;0c" ); /* plain vt220 */
}
@@ -143,7 +143,7 @@
static Function func_CSI_SDA( CSI, ">c", CSI_SDA );
/* screen alignment diagnostic */
-void Esc_DECALN( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Esc_DECALN( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
for ( int y = 0; y < fb->ds.get_height(); y++ ) {
for ( int x = 0; x < fb->ds.get_width(); x++ ) {
@@ -156,7 +156,7 @@
static Function func_Esc_DECALN( ESCAPE, "#8", Esc_DECALN );
/* line feed */
-void Ctrl_LF( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_LF( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
fb->move_rows_autoscroll( 1 );
}
@@ -168,7 +168,7 @@
static Function func_Ctrl_FF( CONTROL, "\x0c", Ctrl_LF );
/* carriage return */
-void Ctrl_CR( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_CR( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
fb->ds.move_col( 0 );
}
@@ -176,7 +176,7 @@
static Function func_Ctrl_CR( CONTROL, "\x0d", Ctrl_CR );
/* backspace */
-void Ctrl_BS( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_BS( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
fb->ds.move_col( -1, true );
}
@@ -184,7 +184,7 @@
static Function func_Ctrl_BS( CONTROL, "\x08", Ctrl_BS );
/* reverse index -- like a backwards line feed */
-void Ctrl_RI( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_RI( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
fb->move_rows_autoscroll( -1 );
}
@@ -192,7 +192,7 @@
static Function func_Ctrl_RI( CONTROL, "\x8D", Ctrl_RI );
/* newline */
-void Ctrl_NEL( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_NEL( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
fb->ds.move_col( 0 );
fb->move_rows_autoscroll( 1 );
@@ -201,7 +201,7 @@
static Function func_Ctrl_NEL( CONTROL, "\x85", Ctrl_NEL );
/* horizontal tab */
-void Ctrl_HT( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_HT( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
int col = fb->ds.get_next_tab();
if ( col == -1 ) { /* no tabs, go to end of line */
@@ -219,7 +219,7 @@
static Function func_Ctrl_HT( CONTROL, "\x09", Ctrl_HT, false );
/* horizontal tab set */
-void Ctrl_HTS( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
+static void Ctrl_HTS( Framebuffer *fb, Dispatcher *dispatch __attribute((unused)) )
{
fb->ds.set_tab();
}
@@ -227,7 +227,7 @@
static Function func_Ctrl_HTS( CONTROL, "\x88", Ctrl_HTS );
/* tabulation clear */
-void CSI_TBC( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_TBC( Framebuffer *fb, Dispatcher *dispatch )
{
int param = dispatch->getparam( 0, 0 );
switch ( param ) {
@@ -268,28 +268,48 @@
return &(fb->ds.auto_wrap_mode);
case 25:
return &(fb->ds.cursor_visible);
+ case 1004: /* xterm mouse focus event */
+ return &(fb->ds.mouse_focus_event);
+ case 1007: /* xterm mouse alternate scroll */
+ return &(fb->ds.mouse_alternate_scroll);
+ case 2004: /* bracketed paste */
+ return &(fb->ds.bracketed_paste);
}
return NULL;
}
+/* helper for CSI_DECSM and CSI_DECRM */
+static void set_if_available( bool *mode, bool value )
+{
+ if ( mode ) { *mode = value; }
+}
+
/* set private mode */
-void CSI_DECSM( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_DECSM( Framebuffer *fb, Dispatcher *dispatch )
{
for ( int i = 0; i < dispatch->param_count(); i++ ) {
- bool *mode = get_DEC_mode( dispatch->getparam( i, 0 ), fb );
- if ( mode ) {
- *mode = true;
+ int param = dispatch->getparam( i, 0 );
+ if (param == 9 || (param >= 1000 && param <= 1003)) {
+ fb->ds.mouse_reporting_mode = (Terminal::DrawState::MouseReportingMode) param;
+ } else if (param == 1005 || param == 1006 || param == 1015) {
+ fb->ds.mouse_encoding_mode = (Terminal::DrawState::MouseEncodingMode) param;
+ } else {
+ set_if_available( get_DEC_mode( param, fb ), true );
}
}
}
/* clear private mode */
-void CSI_DECRM( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_DECRM( Framebuffer *fb, Dispatcher *dispatch )
{
for ( int i = 0; i < dispatch->param_count(); i++ ) {
- bool *mode = get_DEC_mode( dispatch->getparam( i, 0 ), fb );
- if ( mode ) {
- *mode = false;
+ int param = dispatch->getparam( i, 0 );
+ if (param == 9 || (param >= 1000 && param <= 1003)) {
+ fb->ds.mouse_reporting_mode = Terminal::DrawState::MOUSE_REPORTING_NONE;
+ } else if (param == 1005 || param == 1006 || param == 1015) {
+ fb->ds.mouse_encoding_mode = Terminal::DrawState::MOUSE_ENCODING_DEFAULT;
+ } else {
+ set_if_available( get_DEC_mode( param, fb ), false );
}
}
}
@@ -307,7 +327,7 @@
}
/* set mode */
-void CSI_SM( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_SM( Framebuffer *fb, Dispatcher *dispatch )
{
for ( int i = 0; i < dispatch->param_count(); i++ ) {
bool *mode = get_ANSI_mode( dispatch->getparam( i, 0 ), fb );
@@ -318,7 +338,7 @@
}
/* clear mode */
-void CSI_RM( Framebuffer *fb, Dispatcher *dispatch )
+static void CSI_RM( Framebuffer *fb, Dispatcher *dispatch )
{
for ( int i = 0; i < dispatch->param_count(); i++ ) {
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/tests/encrypt-decrypt.cc
^
|
@@ -56,7 +56,7 @@
#define NONCE_FMT "%016"PRIx64
-std::string random_payload( void ) {
+static std::string random_payload( void ) {
const size_t len = prng.uint32() % MESSAGE_SIZE_MAX;
char *buf = new char[len];
prng.fill( buf, len );
@@ -66,13 +66,13 @@
return payload;
}
-void test_bad_decrypt( Session &decryption_session ) {
+static void test_bad_decrypt( Session &decryption_session ) {
std::string bad_ct = random_payload();
bool got_exn = false;
try {
decryption_session.decrypt( bad_ct );
- } catch ( const CryptoException& e ) {
+ } catch ( const CryptoException &e ) {
got_exn = true;
/* The "bad decrypt" exception needs to be non-fatal, otherwise we are
@@ -87,7 +87,7 @@
}
/* Generate a single key and initial nonce, then perform some encryptions. */
-void test_one_session( void ) {
+static void test_one_session( void ) {
Base64Key key;
Session encryption_session( key );
Session decryption_session( key );
@@ -142,9 +142,9 @@
for ( size_t i=0; i<NUM_SESSIONS; i++ ) {
try {
test_one_session();
- } catch ( const CryptoException& e ) {
+ } catch ( const CryptoException &e ) {
fprintf( stderr, "Crypto exception: %s\r\n",
- e.text.c_str() );
+ e.what() );
fatal_assert( false );
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/tests/ocb-aes.cc
^
|
@@ -55,26 +55,26 @@
bool verbose = false;
-bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
+static bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
return ( a.len() == b.len() )
&& !memcmp( a.data(), b.data(), a.len() );
}
-AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
+static AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
AlignedBuffer *ctx_buf = new AlignedBuffer( ae_ctx_sizeof() );
fatal_assert( ctx_buf );
fatal_assert( AE_SUCCESS == ae_init( (ae_ctx *)ctx_buf->data(), key.data(), key.len(), NONCE_LEN, TAG_LEN ) );
return ctx_buf;
}
-void scrap_ctx( AlignedBuffer *ctx_buf ) {
+static void scrap_ctx( AlignedBuffer *ctx_buf ) {
fatal_assert( AE_SUCCESS == ae_clear( (ae_ctx *)ctx_buf->data() ) );
delete ctx_buf;
}
-void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
- const AlignedBuffer &plaintext, const AlignedBuffer &assoc,
- const AlignedBuffer &expected_ciphertext ) {
+static void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
+ const AlignedBuffer &plaintext, const AlignedBuffer &assoc,
+ const AlignedBuffer &expected_ciphertext ) {
AlignedBuffer *ctx_buf = get_ctx( key );
ae_ctx *ctx = (ae_ctx *)ctx_buf->data();
@@ -97,10 +97,10 @@
scrap_ctx( ctx_buf );
}
-void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
- const AlignedBuffer &ciphertext, const AlignedBuffer &assoc,
- const AlignedBuffer &expected_plaintext,
- bool valid ) {
+static void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
+ const AlignedBuffer &ciphertext, const AlignedBuffer &assoc,
+ const AlignedBuffer &expected_plaintext,
+ bool valid ) {
AlignedBuffer *ctx_buf = get_ctx( key );
ae_ctx *ctx = (ae_ctx *)ctx_buf->data();
@@ -129,10 +129,10 @@
scrap_ctx( ctx_buf );
}
-void test_vector( const char *key_p, const char *nonce_p,
- size_t assoc_len, const char *assoc_p,
- size_t plaintext_len, const char *plaintext_p,
- size_t ciphertext_len, const char *ciphertext_p ) {
+static void test_vector( const char *key_p, const char *nonce_p,
+ size_t assoc_len, const char *assoc_p,
+ size_t plaintext_len, const char *plaintext_p,
+ size_t ciphertext_len, const char *ciphertext_p ) {
AlignedBuffer key ( KEY_LEN, key_p );
AlignedBuffer nonce ( NONCE_LEN, nonce_p );
@@ -172,7 +172,7 @@
#define TEST_VECTOR( _key, _nonce, _assoc, _pt, _ct ) \
test_vector( _key, _nonce, sizeof(_assoc)-1, _assoc, sizeof(_pt)-1, _pt, sizeof(_ct)-1, _ct )
-void test_all_vectors( void ) {
+static void test_all_vectors( void ) {
/* Test vectors from http://tools.ietf.org/html/draft-krovetz-ocb-03#appendix-A */
const char ietf_key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F";
@@ -463,7 +463,7 @@
/* http://tools.ietf.org/html/draft-krovetz-ocb-03#appendix-A
also specifies an iterative test algorithm, which we implement here. */
-void test_iterative( void ) {
+static void test_iterative( void ) {
/* Key is always all zeros */
AlignedBuffer key( KEY_LEN );
memset( key.data(), 0, KEY_LEN );
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/util/pty_compat.cc
^
|
@@ -62,7 +62,7 @@
master = open( PTY_DEVICE, O_RDWR | O_NOCTTY );
if ( master < 0 ) {
- perror( "open("PTY_DEVICE")" );
+ perror( "open(" PTY_DEVICE ")" );
return -1;
}
@@ -140,12 +140,22 @@
case 0: /* Child */
if ( setsid() < 0 )
perror( "setsid" );
-#ifndef _AIX
+#ifdef TIOCSCTTY
if ( ioctl( slave, TIOCSCTTY, NULL ) < 0 ) {
perror( "ioctl" );
return -1;
}
-#endif
+#else
+ {
+ int dummy_fd;
+ dummy_fd = open (slave_name, O_RDWR);
+ if (dummy_fd < 0) {
+ perror( "open(slave_name)" );
+ return -1;
+ }
+ close (dummy_fd);
+ }
+#endif /* TIOCSCTTY */
close( master );
dup2( slave, STDIN_FILENO );
dup2( slave, STDOUT_FILENO );
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/util/select.h
^
|
@@ -98,7 +98,7 @@
FD_ZERO( &all_fds );
}
- void add_signal( int signum )
+ static void add_signal( int signum )
{
fatal_assert( signum >= 0 );
fatal_assert( signum <= MAX_SIGNAL_NUMBER );
@@ -118,6 +118,7 @@
fatal_assert( 0 == sigaction( signum, &sa, NULL ) );
}
+ /* timeout unit: milliseconds; negative timeout means wait forever */
int select( int timeout )
{
memcpy( &read_fds, &all_fds, sizeof( read_fds ) );
@@ -125,18 +126,34 @@
clear_got_signal();
got_any_signal = 0;
+#ifdef HAVE_PSELECT
struct timespec ts;
struct timespec *tsp = NULL;
if ( timeout >= 0 ) {
- // timeout in milliseconds
ts.tv_sec = timeout / 1000;
ts.tv_nsec = 1000000 * (long( timeout ) % 1000);
tsp = &ts;
}
- // negative timeout means wait forever
int ret = ::pselect( max_fd + 1, &read_fds, NULL, &error_fds, tsp, &empty_sigset );
+#else
+ struct timeval tv;
+ struct timeval *tvp = NULL;
+ sigset_t old_sigset;
+
+ if ( timeout >= 0 ) {
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = 1000 * (long( timeout ) % 1000);
+ tvp = &tv;
+ }
+
+ int ret = sigprocmask( SIG_SETMASK, &empty_sigset, &old_sigset );
+ if ( ret != -1 ) {
+ ret = ::select( max_fd + 1, &read_fds, NULL, &error_fds, tvp );
+ sigprocmask( SIG_SETMASK, &old_sigset, NULL );
+ }
+#endif
if ( ( ret == -1 ) && ( errno == EINTR ) ) {
/* The user should process events as usual. */
|
[-]
[+]
|
Changed |
_service:tar_git:mosh-1.2.5.tar.xz/mosh/src/util/timestamp.cc
^
|
@@ -72,14 +72,16 @@
}
#elif HAVE_MACH_ABSOLUTE_TIME
static mach_timebase_info_data_t s_timebase_info;
+ static double absolute_to_millis;
if (s_timebase_info.denom == 0) {
mach_timebase_info(&s_timebase_info);
+ absolute_to_millis = 1e-6 * s_timebase_info.numer / s_timebase_info.denom;
}
// NB: mach_absolute_time() returns "absolute time units"
// We need to apply a conversion to get milliseconds.
- millis_cache = ((mach_absolute_time() * s_timebase_info.numer) / (1000000 * s_timebase_info.denom));
+ millis_cache = mach_absolute_time() * absolute_to_millis;
return;
#elif HAVE_GETTIMEOFDAY
// NOTE: If time steps backwards, timeouts may be confused.
|