Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #195 from eduvpn/release/1.1b1
Browse files Browse the repository at this point in the history
Release/1.1b1
  • Loading branch information
johankool authored Jan 30, 2019
2 parents d685519 + 7a7c1b3 commit a955ab0
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 58 deletions.
2 changes: 1 addition & 1 deletion LetsConnect-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>4</string>
<string>5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion OpenVPNHelper/OpenVPNHelper-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.2</string>
<key>CFBundleVersion</key>
<string>7</string>
<string>20</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017-2018 eduVPN. All rights reserved.</string>
<key>SMAuthorizedClients</key>
Expand Down
133 changes: 103 additions & 30 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash
echo "Build Script for eduVPN (and derivatives)"

echo ""
echo "Which target do you want to build?"
echo "1. eduVPN"
echo "2. Let's Connect!"
read -p "0-9?" choice
read -p "1-2?" choice
case "$choice" in
1 ) TARGET="eduVPN"; PRODUCT="eduVPN.app";;
2 ) TARGET="LetsConnect"; PRODUCT="Let's Connect!.app";;
Expand All @@ -16,13 +15,30 @@ echo ""
echo "Which signing identity do you want to use?"
echo "1. SURFnet B.V. (ZYJ4TZX4UU)"
echo "2. Egeniq (E85CT7ZDJC)"
echo "3. Other"
read -p "0-9?" choice
echo "3. Other "
read -p "1-3?" choice

# Enter custom Team ID and Team Name
if [ "$choice" == 3 ]
then
echo "Your Team ID and Team Name must match exactly with the signing identity in your keychain."

read -p "Enter Team ID: " CUSTOMTEAMID
read -p "Enter Team Name: " CUSTOMTEAMNAME

# Simple Team ID Validation. Apple Team ID always consists of 10 characters
if ! [ "${#CUSTOMTEAMID}" == 10 ]
then
echo "Error: Team ID is not valid"
exit 1
fi
fi

case "$choice" in
1 ) TEAMID="ZYJ4TZX4UU"; SIGNINGIDENTITY="Developer ID Application: SURFnet B.V. ($TEAMID)";;
2 ) TEAMID="E85CT7ZDJC"; SIGNINGIDENTITY="Developer ID Application: Egeniq ($TEAMID)";;
3 ) echo "Please adjust the build script to add your signing identity."; exit 0;;
* ) echo "Invalid response."; exit 0;;
3 ) TEAMID="$CUSTOMTEAMID"; SIGNINGIDENTITY="Developer ID Application: $CUSTOMTEAMNAME ($TEAMID)";;
* ) echo "Invalid response."; exit 1;;
esac

BRANCH=$(git rev-parse --abbrev-ref HEAD)
Expand All @@ -31,9 +47,9 @@ echo "You are currently on branch $BRANCH."

if [[ $BRANCH != "release/"* ]]
then
echo ""
echo "You must always build from a release branch. Switch to the correct branch or ask the developer to create it for you."
exit
echo ""
echo "You must always build from a release branch. Switch to the correct branch or ask the developer to create it for you."
exit
fi

VERSION=$(git rev-parse --abbrev-ref HEAD | cut -d "/" -f 2)
Expand All @@ -43,13 +59,27 @@ read -p "Continue building $PRODUCT version $VERSION (using $SIGNINGIDENTITY) (y
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Invalid response."; exit 0;;
* ) echo "Invalid response."; exit 1;;
esac

FILENAME="$TARGET-$VERSION"

echo ""
echo "$(tput setaf 2)Bootstrapping dependencies using carthage$(tput sgr 0)"

# Check if Carthage is installed
if ! [ -x "$(command -v carthage)" ]; then
echo 'Carthage is not installed. Installing Carthage' >&2

# Check if Homebrew is installed
if ! [ -x "$(command -v brew)" ]; then
echo 'Error: Homebrew is not installed. Install Homebrew manually please from https://brew.sh' >&2
exit 1
fi

brew install carthage
fi

# This is a workaround for getting Carthage to work with Xcode 10
tee ${PWD}/Carthage/64bit.xcconfig <<-'EOF'
ARCHS = $(ARCHS_STANDARD_64_BIT)
Expand All @@ -68,32 +98,75 @@ xcodebuild -exportArchive -archivePath $FILENAME.xcarchive -exportPath $FILENAME

echo ""
echo "$(tput setaf 2)Re-signing up and down scripts$(tput sgr 0)"

DOWN=$(find $FILENAME -name "*.down.*.sh" -print)
codesign -f -s "$SIGNINGIDENTITY" "$DOWN"
UP=$(find $FILENAME -name "*.up.*.sh" -print)
codesign -f -s "$SIGNINGIDENTITY" "$UP"

echo ""
read -p "Create disk image (requires DropDMG license) (y/n)?" choice
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Invalid response."; exit 0;;
esac
echo "Which distribution format do you want to use?"
echo "1. None (recommended for local usage)"
echo "2. create-dmg (recommended for 3rd party distribution)"
echo "3. DropDMG (recomended for eduVPN distribution) "
read -p "1-3?" choice

echo ""
echo "$(tput setaf 2)Creating a disk image$(tput sgr 0)"
# The configuration eduVPN can be used for all products
echo "Using: dropdmg --config-name \"eduVPN\" --signing-identity=\"$SIGNINGIDENTITY\" \"$FILENAME/$PRODUCT\""
dropdmg --config-name "eduVPN" --signing-identity="$SIGNINGIDENTITY" "$FILENAME/$PRODUCT"
if [ "$choice" == 1 ]
then
echo ""
echo "Done!"
fi

echo ""
echo "$(tput setaf 2)Creating app cast XML$(tput sgr 0)"
DISTRIBUTIONPATH="../eduvpn-macos-distrib"
# Assumptions are being made about the location of this script
# Also, this often fails due to extended attribute
echo "Using: $DISTRIBUTIONPATH/generate_appcast $DISTRIBUTIONPATH/dsa_priv.pem $DISTRIBUTIONPATH/updates/"
$DISTRIBUTIONPATH/generate_appcast $DISTRIBUTIONPATH/dsa_priv.pem $DISTRIBUTIONPATH/updates/
if [ "$choice" == 2 ]
then
# Check if create-dmg is installed
if ! [ -x "$(command -v create-dmg)" ]; then
# Check if HomeBrew is installed
if ! [ -x "$(command -v brew)" ]; then
echo 'Error: Homebrew is not installed. Install Homebrew manually please from https://brew.sh' >&2
exit 1
fi

brew install create-dmg
fi

INSTALLERFILENAME="$FILENAME.dmg"

echo ""
echo "$(tput setaf 2)Creating a disk image$(tput sgr 0)"

create-dmg \
--volname "$TARGET" \
--window-pos 490 350 \
--window-size 490 350 \
--icon-size 100 \
--icon "$PRODUCT" 100 155 \
--hide-extension "$PRODUCT" \
--app-drop-link 370 155 \
$INSTALLERFILENAME \
$FILENAME"/$PRODUCT"
codesign -f -s "$SIGNINGIDENTITY" $INSTALLERFILENAME

echo ""
echo "Done!"
fi

echo ""
echo "Done! You can now upload the files in the updates folders to your file server. Also remember to merge the release branch into master and tag it."
if [ "$choice" == 3 ]
then
echo ""
echo "$(tput setaf 2)Creating a disk image$(tput sgr 0)"
# The configuration eduVPN can be used for all products
echo "Using: dropdmg --config-name \"eduVPN\" --signing-identity=\"$SIGNINGIDENTITY\" \"$FILENAME/$PRODUCT\""
dropdmg --config-name "eduVPN" --signing-identity="$SIGNINGIDENTITY" "$FILENAME/$PRODUCT"

echo ""
echo "$(tput setaf 2)Creating app cast XML$(tput sgr 0)"
DISTRIBUTIONPATH="../eduvpn-macos-distrib"
# Assumptions are being made about the location of this script
# Also, this often fails due to extended attribute
echo "Using: $DISTRIBUTIONPATH/generate_appcast $DISTRIBUTIONPATH/dsa_priv.pem $DISTRIBUTIONPATH/updates/"
$DISTRIBUTIONPATH/generate_appcast $DISTRIBUTIONPATH/dsa_priv.pem $DISTRIBUTIONPATH/updates/

echo ""
echo "Done! You can now upload the files in the updates folders to your file server. Also remember to merge the release branch into master and tag it."
fi
1 change: 0 additions & 1 deletion eduVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,6 @@
C7FA90271F0BA9A60037FF88 /* Controllers */,
C7FA902A1F0BA9F30037FF88 /* Resources */,
);
name = eduVPN;
path = eduVPN;
sourceTree = "<group>";
};
Expand Down
23 changes: 16 additions & 7 deletions eduVPN/AuthenticationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@ class AuthenticationService {
let configuration = OIDServiceConfiguration(authorizationEndpoint: info.authorizationURL, tokenEndpoint: info.tokenURL)

redirectHTTPHandler = OIDRedirectHTTPHandler(successURL: nil)
let redirectURL = URL(string: "callback", relativeTo: redirectHTTPHandler!.startHTTPListener(nil))!
let request = OIDAuthorizationRequest(configuration: configuration, clientId: "org.eduvpn.app.macos", clientSecret: nil, scopes: ["config"], redirectURL: redirectURL, responseType: OIDResponseTypeCode, additionalParameters: nil)
var redirectURL: URL?
if Thread.isMainThread {
redirectURL = redirectHTTPHandler!.startHTTPListener(nil)
} else {
DispatchQueue.main.sync {
redirectURL = redirectHTTPHandler!.startHTTPListener(nil)
}
}
redirectURL = URL(string: "callback", relativeTo: redirectURL!)!
let request = OIDAuthorizationRequest(configuration: configuration, clientId: "org.eduvpn.app.macos", clientSecret: nil, scopes: ["config"], redirectURL: redirectURL!, responseType: OIDResponseTypeCode, additionalParameters: nil)

let authenticateID: Any?
if #available(OSX 10.14, *) {
Expand All @@ -97,13 +105,14 @@ class AuthenticationService {
self.isAuthenticating = false

let success = authState != nil
if let authState = authState {
self.store(for: info.provider, authState: authState)
}
NotificationCenter.default.post(name: AuthenticationService.authenticationFinished, object: self, userInfo: ["success": success])

// Little delay to make sure authentication screen is dismissed
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.handlersAfterAuthenticating.forEach { handler in
if let authState = authState {
self.store(for: info.provider, authState: authState)
if authState != nil {
handler(.success(Void()))
} else if let error = error {
handler(.failure(error))
Expand All @@ -112,13 +121,13 @@ class AuthenticationService {
}
}
self.handlersAfterAuthenticating.removeAll()

if #available(OSX 10.14, *) {
os_signpost(.end, log: self.log, name: "Authenticate", signpostID: authenticateID as! OSSignpostID, success ? "Success" : "Fail")
}
}
}

DispatchQueue.main.async {
NotificationCenter.default.post(name: AuthenticationService.authenticationStarted, object: self)
}
Expand Down
24 changes: 18 additions & 6 deletions eduVPN/ConnectionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,21 @@ class ConnectionService: NSObject {
}
}
}


private var pendingDisconnectHandlers: [((Result<Void>) -> ())] = []

/// Describes current connection state
private(set) var state: State = .disconnected {
didSet {
if state == .connected {
didConnect()
}
if oldValue == .disconnecting && state == .disconnected && !pendingDisconnectHandlers.isEmpty {
for handler in pendingDisconnectHandlers {
handler(.success(Void()))
}
pendingDisconnectHandlers = []
}
if oldValue != state {
NotificationCenter.default.post(name: ConnectionService.stateChanged, object: self)
}
Expand Down Expand Up @@ -188,13 +196,20 @@ class ConnectionService: NSObject {
handler?(.success(Void()))
return
}


if let handler = handler {
pendingDisconnectHandlers.append(handler)
}

if self.state == .disconnecting {
return
}

self.state = .disconnecting

// Wait 6s before actually marking connection as disconnected
DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) {
self.state = .disconnected
handler?(.success(Void()))
}
}

Expand Down Expand Up @@ -320,8 +335,6 @@ class ConnectionService: NSObject {
return
}

state = .disconnecting

guard let helper = helperService.connection?.remoteObjectProxy as? OpenVPNHelperProtocol else {
self.state = .connected
handler(.failure(Error.noHelperConnection))
Expand Down Expand Up @@ -801,7 +814,6 @@ class ConnectionService: NSObject {
extension ConnectionService: ClientProtocol {

func taskTerminated(reply: @escaping () -> Void) {
state = .disconnecting
reply()
coolDown()
configURL = nil
Expand Down
2 changes: 1 addition & 1 deletion eduVPN/HelperService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ServiceManagement
/// Installs and connects helper
class HelperService {

static let helperVersion = "0.2-7"
static let helperVersion = "0.2-20"
static let helperIdentifier = "org.eduvpn.app.openvpnhelper"

enum Error: Swift.Error, LocalizedError {
Expand Down
2 changes: 1 addition & 1 deletion eduVPN/eduVPN-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>4</string>
<string>5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
14 changes: 4 additions & 10 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ case "$choice" in
* ) echo "Invalid response."; exit 0;;
esac

echo "Removing helper process"
sudo launchctl remove org.eduvpn.app.openvpnhelper

echo "Deleting /Library/LaunchDaemons/org.eduvpn.app.openvpnhelper.plist"
sudo rm -f /Library/LaunchDaemons/org.eduvpn.app.openvpnhelper.plist

Expand All @@ -22,13 +25,4 @@ rm -rf ~/Library/Caches/org.eduvpn.app/
echo "Deleting ~/Library/Preferences/org.eduvpn.app.plist"
rm -f ~/Library/Preferences/org.eduvpn.app.plist

echo "Uninstall completed. Reboot your machine for the uninstall to complete."
echo ""
echo "Do you want to reboot now?"
read -p "Reboot (y/n)?" choice
case "$choice" in
y|Y ) ;;
n|N ) echo "Not rebooting. Please reboot later."; exit 0;;
* ) echo "Invalid response. Not rebooting. Please reboot later."; exit 0;;
esac
sudo reboot
echo "Uninstall completed."

0 comments on commit a955ab0

Please sign in to comment.