Merge pull request #47 from mcarbonneaux/master

This pull request add windows build through Travis-CI, plus upload of the build on Github Release.
This commit is contained in:
Mark Janssen 2020-08-12 10:03:23 +02:00 committed by GitHub
commit e43a4d5a6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 238 additions and 45 deletions

View file

@ -1,14 +1,60 @@
os:
- linux
- windows
language: c
compiler:
- clang
- gcc
before_install:
- |-
case $TRAVIS_OS_NAME in
windows)
[[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
choco uninstall -y mingw
choco upgrade --no-progress -y msys2
export msys2='cmd //C RefreshEnv.cmd '
export msys2+='& set MSYS=winsymlinks:nativestrict '
export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
export msys2+=" -msys2 -c "\"\$@"\" --"
$msys2 pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain gcc make openssl openssl-devel zip unzip xmlto asciidoc curl awk bash
## Install more MSYS2 packages from https://packages.msys2.org/base here
taskkill //IM gpg-agent.exe //F # https://travis-ci.community/t/4967
export PATH=/C/tools/msys64/mingw64/bin:$PATH
export MAKE=mingw32-make # so that Autotools can find it
;;
esac
before_cache:
- |-
case $TRAVIS_OS_NAME in
windows)
# https://unix.stackexchange.com/a/137322/107554
$msys2 pacman --sync --clean --noconfirm
;;
esac
cache:
directories:
- $HOME/AppData/Local/Temp/chocolatey
- /C/tools/msys64
addons:
apt:
packages:
- asciidoc
- xmlto
install:
- make clean
script:
- make
- make docs
- |-
case $TRAVIS_OS_NAME in
windows)
cmd //C RefreshEnv.cmd
set MSYS=winsymlinks:nativestrict
C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start -msys2 -here -c ./buildwin.sh
;;
linux)
make
make docs
;;
esac
exit 0

27
INSTALL
View file

@ -1,27 +0,0 @@
Short guide to installing proxytunnel
On most modern unix systems, use the normal Makefile, possibly uncommenting
the section related to your system (darwin/cygwin/solaris/openbsd)
If you want to enable setproctitle functionality, add a CFLAGS define
-DSETPROCTITLE (uncomment sample in Makefile)
Run make and optionally 'make install'.
If you manually want to install, copy proxytunnel to /usr/local/bin
and optionally the manual-page from the debian-subdirectory to your manpath
---------------------------------------------------------------------------------
Cygwin:
Currently cygwin's openssl isn't in a compilable state, change md4.h and
md5.h in /usr/include
and replace 'size_t' with 'unsigned long'
To link the final executable:
gcc -o proxytunnel *.o /lib/libcrypto.dll.a /lib/libssl.dll.a
To run, copy the required dll's from the cygwin-bin dir to the windows
system dir, or the proxytunnel directory (cygcrypto-0.9.8.dll,
cygssl-0.9.8.dll, cygwin1.dll )
Setproctitle doesn't work on cygwin (afaik)

59
INSTALL.md Normal file
View file

@ -0,0 +1,59 @@
# Short guide to installing proxytunnel
On most modern **unix systems**, use the normal Makefile, possibly uncommenting
the section related to your system (darwin/cygwin/solaris/openbsd)
If you want to enable setproctitle functionality, add a CFLAGS define
-DSETPROCTITLE (uncomment sample in Makefile)
to build simply run `make` and optionally `make install`.
If you manually want to install, copy proxytunnel to /usr/local/bin
and optionally the manual-page from the debian-subdirectory to your manpath
# msys2
To install msys2 with [chocolatey](https://chocolatey.org/install):
```
C:\> choco install -y msys2
```
To switch to msys2 shell:
```
C:\> C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start -msys2
me@mymachine MSYS ~
```
To install dependancy:
```
me@mymachine MSYS ~ pacman --sync --noconfirm --needed mingw-w64-x86_64-toolchain gcc make openssl openssl-devel zip xmlto asciidoc
```
To build with msys2 :
```
me@mymachine MSYS ~ make
```
To build docs with msys2 :
```
me@mymachine MSYS ~ make docs
```
To use `proxytunnel.exe` from windows, copy msys and openssl dll to the same directory as proxytunnel.exe(use `ldd` cmd to see what dll are used by `proxytunnel.exe`) cmd:
```
me@mymachine MSYS ~ cp /usr/bin/msys-2.0.dll /usr/bin/msys-crypto-1.1.dll /usr/bin/msys-ssl-1.1.dll /usr/bin/msys-z.dll .
```
# Cygwin :
Currently cygwin's openssl isn't in a compilable state, change md4.h and
md5.h in /usr/include
and replace 'size_t' with 'unsigned long'
To link the final executable:
gcc -o proxytunnel *.o /lib/libcrypto.dll.a /lib/libssl.dll.a
To run, copy the required dll's from the cygwin-bin dir to the windows
system dir, or the proxytunnel directory (cygcrypto-0.9.8.dll,
cygssl-0.9.8.dll, cygwin1.dll )
Setproctitle doesn't work on cygwin (afaik)

View file

@ -60,6 +60,7 @@ OBJ = proxytunnel.o \
io.o \
http.o \
basicauth.o \
globals.o \
readpassphrase.o \
messages.o \
cmdline.o \

View file

@ -60,6 +60,7 @@ OBJ = proxytunnel.o \
io.o \
http.o \
basicauth.o \
globals.o \
readpassphrase.o \
messages.o \
cmdline.o \

View file

@ -1,6 +1,7 @@
-----------
proxytunnel
-----------
[![Build Status](https://travis-ci.org/mcarbonneaux/proxytunnel.svg?branch=master)](https://travis-ci.org/mcarbonneaux/proxytunnel)
# Proxytunnel
Author: Jos Visser <josv@osp.nl>, Mark Janssen <maniac@maniac.nl>
@ -13,12 +14,14 @@ as an extension to SSH, to be able to SSH to my box at home. In
this file, I will describe the use with SSH. If you want to use it
with some other application, feel free, and let me know!
# Build docs is [her](INSTALL.md)
Usage:
# Usage (man page is [her](docs/proxytunnel.1.adoc)):
Proxytunnel is very easy to use, when running proxytunnel with the help
option it specifies it's command-line options.
```
$ ./proxytunnel --help
proxytunnel 1.9.9 Copyright 2001-2018 Proxytunnel Project
Usage: proxytunnel [OPTIONS]...
@ -58,23 +61,28 @@ Miscellaneous options:
-q, --quiet Suppress messages
-h, --help Print help and exit
-V, --version Print version and exit
```
To use this program with OpenSSH to connect to a host somewhere, create
a $HOME/.ssh/config file with the following content:
```
Host foobar
ProtocolKeepAlives 30
ProxyCommand /path/to/proxytunnel -p proxy:8080 -P username
-d mybox.athome.nl:443
```
With:
```
- foobar The symbolic name of the host you want to connect to
- proxy The host name of the proxy you want to connect through
- 8080 The port number where the proxy software listens to
- username Your proxy userid (password will be prompted)
- mybox.athome.nl The hostname of the box you want to connect to (ultimately)
- 443 The port number of the SSH daemon on mybox.athome.nl
```
If your proxy doesn't require the username and password for using it,
you can skip these options. If you don't provide the password on the
@ -111,27 +119,32 @@ connect to a process that understands SSL itself.
When all this is in place, execute an "ssh foobar" and you're in business!
Environment Variables
=====================
# Environment Variables
Proxytunnel can make use of the following environment variables:
```
PROXYUSER Username for the proxy-authentication
PROXYPASS Password for the proxy-authentication
REMPROXYUSER Username for remote proxy-authentication
REMPROXYPASS Password for remote proxy-authentication
REMPROXYUSER Username for remote proxy-authentication
REMPROXYPASS Password for remote proxy-authentication
HTTP_PROXY Primary proxy host and port information
Format: HTTP_PROXY=http://<host>:<port>/
Format: HTTP_PROXY=http://<host>:<port>/
```
Authentication File
===================
# Authentication File
Proxytunnel can read authentication data from a file (-F/--passfile)
The format for this file is:
```
<field> = <value>
<field> = <value>
etc
```
One entry per line, 1 space before and after the equal sign.
The accepted fields are:
* proxy_user
* proxy_passwd

18
buildwin.sh Normal file
View file

@ -0,0 +1,18 @@
# msys2 windows build script
echo "Build docs..."
make -C docs
echo "Build proxytunnel..."
make -f Makefile.ssl11
echo "Copy msys/openssl dll to build dir..."
cp /usr/bin/msys-2.0.dll /usr/bin/msys-crypto-1.1.dll /usr/bin/msys-ssl-1.1.dll /usr/bin/msys-z.dll .
echo "Generate proxytunnel.zip with docs, exe and msys/openssl dll..."
zip proxytunnel.zip proxytunnel.exe *.dll docs/proxytunnel.1 docs/proxytunnel.1.html docs/proxytunnel-paper.html
if [ ! -z "${TRAVIS_TAG}" ]; then
echo "Deploy proxytunnel.zip to github release tag:${TRAVIS_TAG}..."
/usr/bin/bash ./deploy.sh "proxytunnel.zip"
fi

82
deploy.sh Normal file
View file

@ -0,0 +1,82 @@
#!/usr/bin/bash
# Travis-CI Deploy script to github release.
#
# To use this script:
# - You must generate 'Personal access token' with repo scope of this repository.
# - You must add Variable GITHUB_UPLOAD_TOKEN in settings of your project in travis setting.
# - GITHUB_UPLOAD_TOKEN must contain the token.
# - You can create the token on 'machine user' in place of the 'owner user' of this repository for more security.
#
# https://developer.github.com/v3/guides/managing-deploy-keys/#machine-users
# https://developer.github.com/changes/2020-02-14-deprecating-password-auth/
# https://docs.github.com/en/rest/overview/resources-in-the-rest-api#authentication
# https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
#
# Syntax usage:
# ./deploy.sh <file name to upload to release>
echo "Start try upload asset to github release at $(date)..."
if [ -z "${GITHUB_UPLOAD_TOKEN}" ]; then
echo "GITHUB_UPLOAD_TOKEN are null, you must create Github Personal Access Token to use this script...";
exit 4;
fi
if [ -z "${TRAVIS_TAG}" ]; then
echo "TRAVIS_TAG is null!";
exit 4;
fi
if [ -z "${TRAVIS_REPO_SLUG}" ]; then
echo "TRAVIS_REPO_SLUG is null!";
exit 4;
fi
if [ ! -f $1 ]; then
echo "No file '$1' found...";
exit 3;
fi
echo "Git TAG:"$TRAVIS_TAG
echo "Github SLUG:"$TRAVIS_REPO_SLUG
echo "File to Upload:"$1
ASSETTAGID=$(curl --no-progress-meter -q -H "Authorization: token ${GITHUB_UPLOAD_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases/tags/${TRAVIS_TAG} | awk '/"assets": /{flag=1}/"id": /{sub(",$","",$2);id=$2;}/"name": /{sub("^\"","",$2); sub("\",$","",$2);name=$2; if (name=="'"$1"'") {print id;exit}}')
ASSETURL=$(curl --no-progress-meter -q -H "Authorization: token ${GITHUB_UPLOAD_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases/tags/${TRAVIS_TAG} | awk '/"assets_url": /{sub("^\"","",$2); sub("\",$","",$2); sub("^https://api[.]","https://uploads.",$2);print $2;exit}')
if [ -z "${ASSETURL}" ]; then
curl --no-progress-meter -q -H "Authorization: token ${GITHUB_UPLOAD_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases/tags/${TRAVIS_TAG}
echo "Tag : ${TRAVIS_TAG} not found on project: ${TRAVIS_REPO_SLUG} at $(date)..."
exit 3
fi
if [ ! -z "$ASSETTAGID" ]; then
echo "Asset $1 are already uploaded on Tag: ${TRAVIS_TAG}!"
echo "I must Delete $1 before upload..."
curl -H "Authorization: token ${GITHUB_UPLOAD_TOKEN}" \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases/assets/${ASSETTAGID}
if [ $? -eq 0 ]; then echo "Delete done!"
else echo "Delete failed at $(date)!"; exit 1; fi
fi
echo "Uploading asset $1 to ${TRAVIS_REPO_SLUG} on tag: ${TRAVIS_TAG}..."
curl --no-progress-meter -q -H "Authorization: token ${GITHUB_UPLOAD_TOKEN}" \
-X POST \
--data-binary @$1 \
-H "Content-Type: application/zip" \
-H "Accept: application/vnd.github.v3+json" \
$ASSETURL?name=$1 >response.json
if [ $? -eq 0 ]; then echo "Success upload of asset $1 to ${TRAVIS_REPO_SLUG} on tag: ${TRAVIS_TAG} at $(date)...";
else cat response.json; echo "Failed upload of upload asset $1 to ${TRAVIS_REPO_SLUG} on tag: ${TRAVIS_TAG} at $(date)..."; exit 2; fi
echo "End upload asset $1 to '${TRAVIS_REPO_SLUG}' on tag: '${TRAVIS_TAG}' at $(date)..."
exit 0;