Skip to content

Commit

Permalink
Small tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
KenKundert committed Dec 10, 2015
1 parent 7dcd816 commit 7447723
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
21 changes: 17 additions & 4 deletions README.rst
Expand Up @@ -849,19 +849,32 @@ you would like to use a proxy, you use the --proxy (or -P) command line argument
to specify the proxy by name. For example::

PROXIES = {
'work_proxy': 'proxytunnel -q -p webproxy.ext.workinghard.com:80 -d %h:%p',
'school_proxy': 'proxytunnel -q -p sproxy.fna.learning.edu:1080 -d %h:%p',
'work_proxy': 'corkscrew webproxy.ext.workinghard.com 80 %h %p',
'school_proxy': 'corkscrew sproxy.fna.learning.edu 1080 %h %p',
}

Two HTTP proxies are described, the first capable of bypassing the corporate
firewall and the second does the same for the school's firewall. If preferred,
you can use socat rather than proxytunnel to accomplish the same thing::
firewall and the second does the same for the school's firewall. Each is
a command that takes its input from stdin and produces its output on stdout.
The program 'corkscrew' is designed to proxy a TCP connection through an HTTP
proxy. The first two arguments are the host name and port number of the proxy.
corkscrew connects to the proxy and passes the third and fourth arguments, the
host name and port number of desired destination.

There are many alternatives to corkscrew. One is socat::

PROXIES = {
'work_proxy': 'socat - PROXY:webproxy.ext.workinghard.com:%h:%p,proxyport=80',
'school_proxy': 'socat - PROXY:sproxy.fna.learning.edu:%h:%p,proxyport=1080',
}

Another alternative is proxytunnel::

PROXIES = {
'work_proxy': 'proxytunnel -q -p webproxy.ext.workinghard.com:80 -d %h:%p',
'school_proxy': 'proxytunnel -q -p sproxy.fna.learning.edu:1080 -d %h:%p',
}

When at work, you should generate your ssh config file using::

gensshconfig --proxy=work_proxy
Expand Down
2 changes: 2 additions & 0 deletions clean
Expand Up @@ -7,6 +7,8 @@ rm -f README.pdf
# the rest is common to all python directories
rm -f *.pyc *.pyo .test*.sum expected result install.out
rm -rf build *.egg-info dist __pycache__ .coverage .coverage-html
rm -f resp*.html

foreach i (*/clean)
if ($i == "*/clean") break
#echo $i
Expand Down
5 changes: 3 additions & 2 deletions core.py
@@ -1,6 +1,6 @@
# Core Internal Classes for SSHConfig

from sshconfig import NetworkEntry, locations
from sshconfig import NetworkEntry, locations, ports
from scripts import join, normpath, head, Run, ScriptError
import os

Expand Down Expand Up @@ -348,7 +348,8 @@ def initializeNetwork(network):
script.wait()
except AttributeError:
pass
except ScriptError as error:
except ScriptError:
# not capturing output, so user should already have error message
print("%s network init_script failed (ignored): '%s'" % (
network.name(), str(script)
))
Expand Down
8 changes: 6 additions & 2 deletions gensshconfig
Expand Up @@ -111,7 +111,7 @@ if unknown:
print(' ' + '\n '.join(sorted(unknown)))

# Get description of this situation
desc = [network.Name(), 'network']
desc = [network.Name() if network else 'Unknown', 'network']
if networkDesc:
desc += ['(%s)' % networkDesc]
if locations.my_location:
Expand Down Expand Up @@ -150,7 +150,11 @@ body = []
suffix = []

# Output header
header.append('# SSH Configuration for %s network.' % network.Name())
header.append(
'# SSH Configuration for %s network.' % network.Name()
if network else
'unknown'
)
header.append(time.strftime("# Generated at %-I:%M %p on %d %B %Y."))
header.append(dedent('''\
#
Expand Down
6 changes: 6 additions & 0 deletions sshconfig.py
Expand Up @@ -21,6 +21,12 @@ def gethostname():
def getusername():
return getpass.getuser()

# is_ip_addr {{{2
import re
ip_addr_ptn = re.compile(r"\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*\Z")
def is_ip_addr(addr):
return ip_addr_ptn.match(addr)

# VNC {{{2
# Generates forwards for VNC
def VNC(
Expand Down

0 comments on commit 7447723

Please sign in to comment.