Compare commits

...

12 Commits

Author SHA1 Message Date
8c91958ff3 Prepare to release 1.0.2 2020-06-18 07:45:08 +10:00
d2f751f0d3 leave use of default port to ssh command
to prevent overwriting ports configured in ~/.ssh/config
if no port is specified, don't set the port explicitly to 22
2020-06-17 08:04:35 +10:00
9d79bb82c5 Bump pytest-cov from 2.9.0 to 2.10.0
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.9.0...v2.10.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-15 19:14:10 +10:00
a53f026056 Merge pull request #461 from joshuarli/doc/update-py2-removal
doc: py2 removal clean sweep
2020-06-11 09:55:36 +10:00
ae4c7e3a7b remove outdated comment 2020-06-10 16:47:23 -07:00
61bbbca956 another python 3.5 change 2020-06-10 16:46:52 -07:00
e56f8f2349 server side is py3.5+ 2020-06-10 16:46:10 -07:00
0a36eac686 ref: replace usage of deprecated imp (#449)
* Use types instead of imp.new_module.

I can follow up with https://docs.python.org/3/library/importlib.html#importlib.util.module_from_spec if need be.

* use source loader from importlib

* Revert "use source loader from importlib"

This reverts commit 1f255704f7.

* use inspect.getsource, but alas

* placate linter

* use find_spec to resolve a module spec to a file path

* better function naming

* remove outdated comment
2020-06-11 06:57:46 +10:00
16b462880b Merge pull request #460 from alekseymykhailov/fix_connection
fix connection with @ sign in username
2020-06-11 06:15:19 +10:00
500aa65693 fix connection with @ sign in username 2020-06-10 08:20:28 -07:00
7d998f6d42 Bump flake8 from 3.8.2 to 3.8.3
Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.8.2 to 3.8.3.
- [Release notes](https://gitlab.com/pycqa/flake8/tags)
- [Commits](https://gitlab.com/pycqa/flake8/compare/3.8.2...3.8.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-09 18:48:45 +10:00
8c9dad1c6b Fix errors in long_documentation 2020-06-05 08:19:24 +10:00
9 changed files with 46 additions and 54 deletions

View File

@ -9,6 +9,25 @@ adheres to `Semantic Versioning`_.
.. _`Semantic Versioning`: http://semver.org/
1.0.2 - 2020-06-18
------------------
Fixed
~~~~~
* Leave use of default port to ssh command.
* Remove unwanted references to Python 2.7 in docs.
* Replace usage of deprecated imp.
* Fix connection with @ sign in username.
1.0.1 - 2020-06-05
------------------
Fixed
~~~~~
* Errors in python long_documentation.
1.0.0 - 2020-06-05
------------------

View File

@ -98,6 +98,6 @@ https://sshuttle.readthedocs.org/en/latest/
Running as a service
-------------
--------------------
Sshuttle can also be run as a service and configured using a config management system:
https://medium.com/@mike.reider/using-sshuttle-as-a-service-bec2684a65fe

View File

@ -11,7 +11,7 @@ Description
-----------
:program:`sshuttle` allows you to create a VPN connection from your
machine to any remote server that you can connect to via
ssh, as long as that server has python 2.3 or higher.
ssh, as long as that server has python 3.5 or higher.
To work, you must have root access on the local machine,
but you can have a normal account on the server.

View File

@ -57,9 +57,8 @@ cmd.exe with Administrator access. See :doc:`windows` for more information.
Server side Requirements
------------------------
The server can run in any version of Python between 2.4 and 3.6.
However it is recommended that you use Python 2.7, Python 3.5 or later whenever
possible as support for older versions might be dropped in the future.
- Python 3.5 or greater.
Additional Suggested Software

View File

@ -1,7 +1,7 @@
-r requirements.txt
attrs==19.3.0
pytest==5.4.3
pytest-cov==2.9.0
pytest-cov==2.10.0
mock==2.0.0
flake8==3.8.2
flake8==3.8.3
pyflakes==2.2.0

View File

@ -41,6 +41,7 @@ setup(
packages=find_packages(),
license="LGPL2.1+",
long_description=open('README.rst').read(),
long_description_content_type="text/x-rst",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",

View File

@ -1,6 +1,6 @@
import sys
import zlib
import imp
import types
verbosity = verbosity # noqa: F821 must be a previously defined global
z = zlib.decompressobj()
@ -15,7 +15,7 @@ while 1:
% (name, nbytes))
content = z.decompress(sys.stdin.read(nbytes))
module = imp.new_module(name)
module = types.ModuleType(name)
parents = name.rsplit(".", 1)
if len(parents) == 2:
parent, parent_name = parents

View File

@ -3,7 +3,7 @@ import os
import re
import socket
import zlib
import imp
import importlib
import subprocess as ssubprocess
import shlex
from shlex import quote
@ -14,43 +14,15 @@ import sshuttle.helpers as helpers
from sshuttle.helpers import debug2
def readfile(name):
tokens = name.split(".")
f = None
token = tokens[0]
token_name = [token]
token_str = ".".join(token_name)
try:
f, pathname, description = imp.find_module(token_str)
for token in tokens[1:]:
module = imp.load_module(token_str, f, pathname, description)
if f is not None:
f.close()
token_name.append(token)
token_str = ".".join(token_name)
f, pathname, description = imp.find_module(
token, module.__path__)
if f is not None:
contents = f.read()
else:
contents = ""
finally:
if f is not None:
f.close()
return contents.encode("UTF8")
def get_module_source(name):
spec = importlib.util.find_spec(name)
with open(spec.origin, "rt") as f:
return f.read().encode("utf-8")
def empackage(z, name, data=None):
if not data:
data = readfile(name)
data = get_module_source(name)
content = z.compress(data)
content += z.flush(zlib.Z_SYNC_FLUSH)
@ -68,17 +40,17 @@ def parse_hostport(rhostport):
and returns a tuple (username, password, port, host)
"""
# default port for SSH is TCP port 22
port = 22
# leave use of default port to ssh command to prevent overwriting
# ports configured in ~/.ssh/config when no port is given
port = None
username = None
password = None
host = rhostport
if "@" in host:
# split username (and possible password) from the host[:port]
username, host = host.split("@")
username, host = host.rsplit("@", 1)
# Fix #410 bad username error detect
# username cannot contain an @ sign in this scenario
if ":" in username:
# this will even allow for the username to be empty
username, password = username.split(":")
@ -117,7 +89,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
rhost = host
z = zlib.compressobj(1)
content = readfile('sshuttle.assembler')
content = get_module_source('sshuttle.assembler')
optdata = ''.join("%s=%r\n" % (k, v) for (k, v) in list(options.items()))
optdata = optdata.encode("UTF8")
content2 = (empackage(z, 'sshuttle') +
@ -145,6 +117,10 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
sshl = shlex.split(ssh_cmd)
else:
sshl = ['ssh']
if port is not None:
portl = ["-p", str(port)]
else:
portl = []
if python:
pycmd = "'%s' -c '%s'" % (python, pyscript)
else:
@ -155,12 +131,12 @@ def connect(ssh_cmd, rhostport, python, stderr, options):
if password is not None:
os.environ['SSHPASS'] = str(password)
argv = (["sshpass", "-e"] + sshl +
["-p", str(port)] +
portl +
[rhost, '--', pycmd])
else:
argv = (sshl +
["-p", str(port)] +
portl +
[rhost, '--', pycmd])
(s1, s2) = socket.socketpair()

View File

@ -10,15 +10,12 @@ from sshuttle.helpers import b, log, debug1, debug2, debug3, Fatal
MAX_CHANNEL = 65535
LATENCY_BUFFER_SIZE = 32768
# these don't exist in the socket module in python 2.3!
SHUT_RD = 0
SHUT_WR = 1
SHUT_RDWR = 2
HDR_LEN = 8
CMD_EXIT = 0x4200
CMD_PING = 0x4201
CMD_PONG = 0x4202