Просмотр исходного кода

Add support for private plugins

Rod Hynes 9 лет назад
Родитель
Сommit
aafca2909b

+ 5 - 4
ConsoleClient/make.bash

@@ -11,9 +11,10 @@ EXE_BASENAME="psiphon-tunnel-core"
 
 # The "OPENSSL" tag enables support of OpenSSL for use by IndistinguishableTLS.
 # This needs to be outside of prepare_build because it's used by go-get.
-WINDOWS_BUILD_TAGS="OPENSSL"
-LINUX_BUILD_TAGS=
-OSX_BUILD_TAGS=
+BUILD_TAGS="PRIVATE_PLUGINS"
+WINDOWS_BUILD_TAGS="OPENSSL ${BUILD_TAGS}"
+LINUX_BUILD_TAGS="${BUILD_TAGS}"
+OSX_BUILD_TAGS="${BUILD_TAGS}"
 
 prepare_build () {
   BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt"
@@ -29,7 +30,7 @@ prepare_build () {
   # - pipes to `xargs` again, specifiying `pkg` as the placeholder name for each item being operated on (which is the list of non standard library import paths from the previous step)
   #  - `xargs` runs a bash script (via `-c`) which changes to each import path in sequence, then echoes out `"<import path>":"<subshell output of getting the short git revision>",`
   # - this leaves a trailing `,` at the end, and no close to the JSON object, so simply `sed` replace the comma before the end of the line with `}` and you now have valid JSON
-  DEPENDENCIES=$(echo -n "{" && go list -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
+  DEPENDENCIES=$(echo -n "{" && go list -tags "${BUILD_TAGS}" -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
 
   LDFLAGS="\
   -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.buildDate=$BUILDDATE \

+ 26 - 0
ConsoleClient/privatePlugins.go

@@ -0,0 +1,26 @@
+// +build PRIVATE_PLUGINS
+
+/*
+ * Copyright (c) 2015, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package main
+
+import (
+	_ "github.com/Psiphon-Inc/psiphon-tunnel-core-private-plugins/common_plugins"
+)

+ 2 - 2
MobileLibrary/Android/make.bash

@@ -8,7 +8,7 @@ if [ ! -f make.bash ]; then
 fi
 
 # The "OPENSSL" tag enables support of OpenSSL for use by IndistinguishableTLS.
-BUILD_TAGS="OPENSSL"
+BUILD_TAGS="OPENSSL PRIVATE_PLUGINS"
 
 # Don't use '-u' to force updates because the docker builds always pull
 # the latest versions. Outside of Docker, be aware that these dependencies
@@ -38,7 +38,7 @@ GOMOBILEVERSION=$(gomobile version | perl -ne '/gomobile version (.*?) / && prin
 # - pipes to `xargs` again, specifiying `pkg` as the placeholder name for each item being operated on (which is the list of non standard library import paths from the previous step)
 #  - `xargs` runs a bash script (via `-c`) which changes to each import path in sequence, then echoes out `"<import path>":"<subshell output of getting the short git revision>",`
 # - this leaves a trailing `,` at the end, and no close to the JSON object, so simply `sed` replace the comma before the end of the line with `}` and you now have valid JSON
-DEPENDENCIES=$(cd ../psi && echo -n "{" && go list -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
+DEPENDENCIES=$(cd ../psi && echo -n "{" && go list -tags "${BUILD_TAGS}" -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
 
 LDFLAGS="\
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.buildDate=$BUILDDATE \

+ 1 - 1
MobileLibrary/iOS/build-psiphon-framework.sh

@@ -29,7 +29,7 @@ INTERMEDIATE_OUPUT_FILE="${FRAMEWORK}.framework"
 FRAMEWORK_BINARY="${INTERMEDIATE_OUPUT_DIR}/${INTERMEDIATE_OUPUT_FILE}/Versions/A/${FRAMEWORK}"
 
 # The "OPENSSL" tag enables support of OpenSSL for use by IndistinguishableTLS.
-BUILD_TAGS="OPENSSL IOS"
+BUILD_TAGS="OPENSSL IOS PRIVATE_PLUGINS"
 
 LIBSSL=${BASE_DIR}/OpenSSL-for-iPhone/lib/libssl.a
 LIBCRYPTO=${BASE_DIR}/OpenSSL-for-iPhone/lib/libcrypto.a

+ 26 - 0
MobileLibrary/psi/privatePlugins.go

@@ -0,0 +1,26 @@
+// +build PRIVATE_PLUGINS
+
+/*
+ * Copyright (c) 2015, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package psi
+
+import (
+	_ "github.com/Psiphon-Inc/psiphon-tunnel-core-private-plugins/common_plugins"
+)

+ 5 - 3
Server/make.bash

@@ -10,6 +10,8 @@ if [ ! -f make.bash ]; then
   exit 1
 fi
 
+BUILD_TAGS="PRIVATE_PLUGINS"
+
 prepare_build () {
   BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt"
   BUILDDATE=$(date -Iseconds)
@@ -24,7 +26,7 @@ prepare_build () {
   # - pipes to `xargs` again, specifiying `pkg` as the placeholder name for each item being operated on (which is the list of non standard library import paths from the previous step)
   #  - `xargs` runs a bash script (via `-c`) which changes to each import path in sequence, then echoes out `"<import path>":"<subshell output of getting the short git revision>",`
   # - this leaves a trailing `,` at the end, and no close to the JSON object, so simply `sed` replace the comma before the end of the line with `}` and you now have valid JSON
-  DEPENDENCIES=$(echo -n "{" && go list -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
+  DEPENDENCIES=$(echo -n "{" && go list -tags "${BUILD_TAGS}" -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
 
   LDFLAGS="\
   -linkmode external -extldflags \"-static\" \
@@ -47,14 +49,14 @@ prepare_build () {
 
 build_for_linux () {
   echo "Getting project dependencies (via go get) for Linux. Parameter is: '$1'"
-  GOOS=linux GOARCH=amd64 go get -d -v ./...
+  GOOS=linux GOARCH=amd64 go get -d -v -tags "${BUILD_TAGS}" ./...
   prepare_build
   if [ $? != 0 ]; then
     echo "...'go get' failed, exiting"
     exit $?
   fi
 
-  GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o psiphond main.go
+  GOOS=linux GOARCH=amd64 go build -tags "${BUILD_TAGS}" -ldflags "$LDFLAGS" -o psiphond main.go
   if [ $? != 0 ]; then
     echo "...'go build' failed, exiting"
     exit $?

+ 26 - 0
Server/privatePlugins.go

@@ -0,0 +1,26 @@
+// +build PRIVATE_PLUGINS
+
+/*
+ * Copyright (c) 2015, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package main
+
+import (
+	_ "github.com/Psiphon-Inc/psiphon-tunnel-core-private-plugins/common_plugins"
+)