Skip to content

Commit 8a3c103

Browse files
committed
“Update”
1 parent 63a8fd7 commit 8a3c103

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+46743
-0
lines changed

LICENSE

+674
Large diffs are not rendered by default.

README 2.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
openvpn-server-ios
2+
==================
3+
4+
Tethering the hard way.
5+
6+
It turns out that Apple doesn't allow you to use `<net/if_utun.h>` unless you pay them a lot of money. Unfortunately you can't use [tunemu](https://github.com/friedrich/hans/blob/master/src/tunemu.c) either.
7+
8+
Apple refuses to allow people to use the VPN framework unless they sign some sort of NDA: http://blog.michael.kuron-germany.de/2010/09/ios-4-1-undocumented-vpn-api-used-by-cisco-anyconnect/
9+
10+
## Setup
11+
12+
Install GNU libtool and automake:
13+
14+
$ brew install libtool automake
15+
16+
Generate a static key and place it in `/configuration`:
17+
18+
$ openvpn --genkey --secret static.key
19+
20+
Build the dependencies:
21+
22+
$ bash build-libssl.sh
23+
$ bash build-openvpn.sh
24+
25+
## Clean
26+
27+
To clean the `Submodules/openvpn` build folder:
28+
29+
$ cd /Submodules/openvpn
30+
$ git clean -f && git clean -f -X
31+
32+
## Configuration
33+
34+
Simplest OpenVPN setup: [Static Key Mini-HOWTO](http://openvpn.net/index.php/open-source/documentation/miscellaneous/78-static-key-mini-howto.html)
35+
36+
37+

build-libpcap.sh

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/bin/bash
2+
# Builds libpcap for all three current iPhone targets: iPhoneSimulator-i386,
3+
# iPhoneOS-armv6, iPhoneOS-armv7.
4+
#
5+
# Copyright 2012 Mike Tigas <[email protected]>
6+
#
7+
# Based on work by Felix Schulze on 16.12.10.
8+
# Copyright 2010 Felix Schulze. All rights reserved.
9+
#
10+
# Licensed under the Apache License, Version 2.0 (the "License");
11+
# you may not use this file except in compliance with the License.
12+
# You may obtain a copy of the License at
13+
#
14+
# http://www.apache.org/licenses/LICENSE-2.0
15+
#
16+
# Unless required by applicable law or agreed to in writing, software
17+
# distributed under the License is distributed on an "AS IS" BASIS,
18+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
# See the License for the specific language governing permissions and
20+
# limitations under the License.
21+
#
22+
###########################################################################
23+
# Choose your libpcap version and your currently-installed iOS SDK version:
24+
#
25+
VERSION="1.4.0"
26+
SDKVERSION="10.2"
27+
MINIOSVERSION="6.0"
28+
29+
###########################################################################
30+
#
31+
# Don't change anything under this line!
32+
#
33+
###########################################################################
34+
35+
# No need to change this since xcode build will only compile in the
36+
# necessary bits from the libraries we create
37+
ARCHS="i386 x86_64 armv7 armv7s arm64"
38+
39+
DEVELOPER=`xcode-select -print-path`
40+
#DEVELOPER="/Applications/Xcode.app/Contents/Developer"
41+
42+
cd "`dirname \"$0\"`"
43+
REPOROOT=$(pwd)
44+
45+
# Where we'll end up storing things in the end
46+
OUTPUTDIR="${REPOROOT}/dependencies"
47+
mkdir -p ${OUTPUTDIR}/include
48+
mkdir -p ${OUTPUTDIR}/lib
49+
50+
BUILDDIR="${REPOROOT}/build"
51+
52+
# where we will keep our sources and build from.
53+
SRCDIR="${BUILDDIR}/src"
54+
mkdir -p $SRCDIR
55+
# where we will store intermediary builds
56+
INTERDIR="${BUILDDIR}/built"
57+
mkdir -p $INTERDIR
58+
59+
########################################
60+
61+
cd $SRCDIR
62+
63+
# Exit the script if an error happens
64+
set -e
65+
66+
if [ ! -e "${SRCDIR}/libpcap-${VERSION}.tar.gz" ]; then
67+
echo "Downloading libpcap-${VERSION}.tar.gz"
68+
curl -O http://www.tcpdump.org/release/libpcap-${VERSION}.tar.gz
69+
fi
70+
echo "Using libpcap-${VERSION}.tar.gz"
71+
72+
tar zxf libpcap-${VERSION}.tar.gz -C $SRCDIR
73+
cd "${SRCDIR}/libpcap-${VERSION}"
74+
75+
echo "Copying <net/bpf.h>, <net/if_media.h> from iPhoneSimulator"
76+
mkdir -p ${OUTPUTDIR}/include/net
77+
cp ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/include/net/bpf.h ${OUTPUTDIR}/include/net/bpf.h
78+
cp ${DEVELOPER}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVERSION}.sdk/usr/include/net/if_media.h ${OUTPUTDIR}/include/net/if_media.h
79+
80+
81+
set +e # don't bail out of bash script if ccache doesn't exist
82+
CCACHE=`which ccache`
83+
if [ $? == "0" ]; then
84+
echo "Building with ccache: $CCACHE"
85+
CCACHE="${CCACHE} "
86+
else
87+
echo "Building without ccache"
88+
CCACHE=""
89+
fi
90+
set -e # back to regular "bail out on error" mode
91+
92+
for ARCH in ${ARCHS}
93+
do
94+
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] ; then
95+
PLATFORM="iPhoneSimulator"
96+
EXTRA_CONFIG="--host ${ARCH}-apple-darwin"
97+
EXTRA_CFLAGS=""
98+
EXTRA_LDFLAGS=""
99+
else
100+
PLATFORM="iPhoneOS"
101+
EXTRA_CONFIG="--host arm-apple-darwin"
102+
EXTRA_CFLAGS=""
103+
EXTRA_LDFLAGS=""
104+
fi
105+
106+
mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
107+
108+
./configure --disable-shared --enable-static --with-pcap=bpf --enable-ipv6 ${EXTRA_CONFIG} \
109+
--prefix="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" \
110+
CC="${CCACHE}${DEVELOPER}/usr/bin/gcc" \
111+
LDFLAGS="$LDFLAGS -arch ${ARCH} -fPIE -miphoneos-version-min=${MINIOSVERSION} ${EXTRA_LDFLAGS} -L${OUTPUTDIR}/lib" \
112+
CFLAGS="$CFLAGS -g -O0 -D__APPLE_USE_RFC_3542 -arch ${ARCH} -fPIE -miphoneos-version-min=${MINIOSVERSION} ${EXTRA_CFLAGS} -I${OUTPUTDIR}/include -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk" \
113+
114+
# Build the application and install it to the fake SDK intermediary dir
115+
# we have set up. Make sure to clean up afterward because we will re-use
116+
# this source tree to cross-compile other targets.
117+
make -j2
118+
make install
119+
120+
make clean
121+
done
122+
123+
########################################
124+
125+
echo "Build library..."
126+
OUTPUT_LIBS="libpcap.a"
127+
for OUTPUT_LIB in ${OUTPUT_LIBS}; do
128+
INPUT_LIBS=""
129+
for ARCH in ${ARCHS}; do
130+
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then
131+
PLATFORM="iPhoneSimulator"
132+
else
133+
PLATFORM="iPhoneOS"
134+
fi
135+
INPUT_ARCH_LIB="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/${OUTPUT_LIB}"
136+
if [ -e $INPUT_ARCH_LIB ]; then
137+
INPUT_LIBS="${INPUT_LIBS} ${INPUT_ARCH_LIB}"
138+
fi
139+
done
140+
# Combine the three architectures into a universal library.
141+
if [ -n "$INPUT_LIBS" ]; then
142+
lipo -create $INPUT_LIBS \
143+
-output "${OUTPUTDIR}/lib/${OUTPUT_LIB}"
144+
else
145+
echo "$OUTPUT_LIB does not exist, skipping (are the dependencies installed?)"
146+
fi
147+
done
148+
149+
for ARCH in ${ARCHS}; do
150+
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then
151+
PLATFORM="iPhoneSimulator"
152+
else
153+
PLATFORM="iPhoneOS"
154+
fi
155+
cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include/* ${OUTPUTDIR}/include/
156+
if [ $? == "0" ]; then
157+
# We only need to copy the headers over once. (So break out of forloop
158+
# once we get first success.)
159+
break
160+
fi
161+
done
162+
163+
echo "Building done."
164+
echo "Cleaning up..."
165+
rm -fr ${INTERDIR}
166+
rm -fr "${SRCDIR}/libpcap-${VERSION}"
167+
echo "Done."

build-libssl.sh

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#!/bin/bash
2+
# Builds openssl for all three current iPhone targets: iPhoneSimulator-i386,
3+
# iPhoneOS-armv6, iPhoneOS-armv7.
4+
#
5+
# Copyright 2012 Mike Tigas <[email protected]>
6+
#
7+
# Based on work by Felix Schulze on 16.12.10.
8+
# Copyright 2010 Felix Schulze. All rights reserved.
9+
#
10+
# Licensed under the Apache License, Version 2.0 (the "License");
11+
# you may not use this file except in compliance with the License.
12+
# You may obtain a copy of the License at
13+
#
14+
# http://www.apache.org/licenses/LICENSE-2.0
15+
#
16+
# Unless required by applicable law or agreed to in writing, software
17+
# distributed under the License is distributed on an "AS IS" BASIS,
18+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
# See the License for the specific language governing permissions and
20+
# limitations under the License.
21+
#
22+
###########################################################################
23+
# Choose your openssl version and your currently-installed iOS SDK version:
24+
#
25+
VERSION="1.0.2j"
26+
SDKVERSION="10.2"
27+
MINIOSVERSION="6.0"
28+
VERIFYGPG=false
29+
30+
###########################################################################
31+
#
32+
# Don't change anything under this line!
33+
#
34+
###########################################################################
35+
36+
# No need to change this since xcode build will only compile in the
37+
# necessary bits from the libraries we create
38+
ARCHS="i386 x86_64 armv7 armv7s arm64"
39+
40+
DEVELOPER=`xcode-select -print-path`
41+
#DEVELOPER="/Applications/Xcode.app/Contents/Developer"
42+
43+
cd "`dirname \"$0\"`"
44+
REPOROOT=$(pwd)
45+
46+
# Where we'll end up storing things in the end
47+
OUTPUTDIR="${REPOROOT}/dependencies"
48+
mkdir -p ${OUTPUTDIR}/include
49+
mkdir -p ${OUTPUTDIR}/lib
50+
51+
BUILDDIR="${REPOROOT}/build"
52+
53+
# where we will keep our sources and build from.
54+
SRCDIR="${BUILDDIR}/src"
55+
mkdir -p $SRCDIR
56+
# where we will store intermediary builds
57+
INTERDIR="${BUILDDIR}/built"
58+
mkdir -p $INTERDIR
59+
60+
########################################
61+
62+
cd $SRCDIR
63+
64+
# Exit the script if an error happens
65+
set -e
66+
67+
if [ ! -e "${SRCDIR}/openssl-${VERSION}.tar.gz" ]; then
68+
echo "Downloading openssl-${VERSION}.tar.gz"
69+
curl -O http://www.openssl.org/source/openssl-${VERSION}.tar.gz
70+
fi
71+
echo "Using openssl-${VERSION}.tar.gz"
72+
73+
# see https://www.openssl.org/about/,
74+
# up to you to set up `gpg` and add keys to your keychain
75+
if $VERIFYGPG; then
76+
if [ ! -e "${SRCDIR}/openssl-${VERSION}.tar.gz.asc" ]; then
77+
curl -O http://www.openssl.org/source/openssl-${VERSION}.tar.gz.asc
78+
fi
79+
echo "Using openssl-${VERSION}.tar.gz.asc"
80+
if out=$(gpg --status-fd 1 --verify "openssl-${VERSION}.tar.gz.asc" "openssl-${VERSION}.tar.gz" 2>/dev/null) &&
81+
echo "$out" | grep -qs "^\[GNUPG:\] VALIDSIG"; then
82+
echo "$out" | egrep "GOODSIG|VALIDSIG"
83+
echo "Verified GPG signature for source..."
84+
else
85+
echo "$out" >&2
86+
echo "COULD NOT VERIFY PACKAGE SIGNATURE..."
87+
exit 1
88+
fi
89+
fi
90+
91+
cd "${SRCDIR}/openssl-${VERSION}"
92+
93+
set +e # don't bail out of bash script if ccache doesn't exist
94+
CCACHE=`which ccache`
95+
if [ $? == "0" ]; then
96+
echo "Building with ccache: $CCACHE"
97+
CCACHE="${CCACHE} "
98+
else
99+
echo "Building without ccache"
100+
CCACHE=""
101+
fi
102+
set -e # back to regular "bail out on error" mode
103+
104+
export ORIGINALPATH=$PATH
105+
106+
for ARCH in ${ARCHS}
107+
do
108+
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then
109+
PLATFORM="iPhoneSimulator"
110+
else
111+
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
112+
PLATFORM="iPhoneOS"
113+
fi
114+
115+
mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
116+
117+
export PATH="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/usr/bin/:${DEVELOPER}/Toolchains/XcodeDefault.xct‌​oolchain/usr/bin:${DEVELOPER}/usr/bin:${ORIGINALPATH}"
118+
export CC="${CCACHE}`which gcc` -arch ${ARCH} -miphoneos-version-min=${MINIOSVERSION}"
119+
120+
if [ "${ARCH}" == "x86_64" ] || [ "${ARCH}" == "arm64" ]; then
121+
./configure BSD-generic64 no-asm enable-ec_nistp_64_gcc_128 \
122+
--openssldir="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
123+
else
124+
./configure BSD-generic32 no-asm \
125+
--openssldir="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
126+
fi
127+
128+
# add -isysroot to configure-generated CFLAGS
129+
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk !" "Makefile"
130+
131+
# Build the application and install it to the fake SDK intermediary dir
132+
# we have set up. Make sure to clean up afterward because we will re-use
133+
# this source tree to cross-compile other targets.
134+
make
135+
make install
136+
make clean
137+
done
138+
139+
########################################
140+
141+
echo "Build library..."
142+
OUTPUT_LIBS="libssl.a libcrypto.a"
143+
for OUTPUT_LIB in ${OUTPUT_LIBS}; do
144+
INPUT_LIBS=""
145+
for ARCH in ${ARCHS}; do
146+
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then
147+
PLATFORM="iPhoneSimulator"
148+
else
149+
PLATFORM="iPhoneOS"
150+
fi
151+
INPUT_ARCH_LIB="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/${OUTPUT_LIB}"
152+
if [ -e $INPUT_ARCH_LIB ]; then
153+
INPUT_LIBS="${INPUT_LIBS} ${INPUT_ARCH_LIB}"
154+
fi
155+
done
156+
# Combine the three architectures into a universal library.
157+
if [ -n "$INPUT_LIBS" ]; then
158+
lipo -create $INPUT_LIBS \
159+
-output "${OUTPUTDIR}/lib/${OUTPUT_LIB}"
160+
else
161+
echo "$OUTPUT_LIB does not exist, skipping (are the dependencies installed?)"
162+
fi
163+
done
164+
165+
for ARCH in ${ARCHS}; do
166+
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]; then
167+
PLATFORM="iPhoneSimulator"
168+
else
169+
PLATFORM="iPhoneOS"
170+
fi
171+
cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include/* ${OUTPUTDIR}/include/
172+
if [ $? == "0" ]; then
173+
# We only need to copy the headers over once. (So break out of forloop
174+
# once we get first success.)
175+
break
176+
fi
177+
done
178+
179+
echo "Building done."
180+
echo "Cleaning up..."
181+
rm -fr ${INTERDIR}
182+
echo "Done."

0 commit comments

Comments
 (0)