Skip to content

Commit 03c9570

Browse files
committed
Travis checks both examples
1 parent ca86280 commit 03c9570

File tree

5 files changed

+81
-3
lines changed

5 files changed

+81
-3
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ install:
88
- go get golang.org/x/mobile/cmd/gomobile
99

1010
script:
11-
- ./check-all.sh
11+
- ./check-all.sh $PWD/examples/desktop
12+
- ./check-all.sh $PWD/examples/ios
1213

1314
#we are not ready for deployment yet - gomobile depends on xcode, and we didn't test it yet on xgo image
1415
#before_deploy:

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ go get github.com/karalabe/xgo
1616
go get golang.org/x/mobile/cmd/gomobile
1717
```
1818

19-
* **Step 2.** Build example
19+
* **Step 2.** Build example (Desktop)
2020
```bash
2121
go run examples/desktop/main.go examples/profile.ovpn
2222
```
2323

24+
* **Step 3.** Build example (iOS)
25+
```bash
26+
./gomobile_example_ios.sh
27+
```
28+
2429
## Build
2530
* **Step 1.** Sanity check
2631
```bash

check-all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
xgo -x -v --image=mysteriumnetwork/xgo-1.9.2 --targets=linux/amd64,darwin/amd64,windows/amd64,ios-10.3/arm64,android-21/arm64 --out=build/test $PWD/examples
4+
xgo -x -v --image=mysteriumnetwork/xgo-1.9.2 --targets=linux/amd64,darwin/amd64,windows/amd64,ios-10.3/arm64,android-21/arm64 --out=build/test $@

examples/ios/application.go

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package ios
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/mysteriumnetwork/go-openvpn/openvpn3"
8+
)
9+
10+
type callbacks interface {
11+
openvpn3.Logger
12+
openvpn3.EventConsumer
13+
openvpn3.StatsConsumer
14+
}
15+
16+
type loggingCallbacks struct {
17+
}
18+
19+
func (lc *loggingCallbacks) Log(text string) {
20+
lines := strings.Split(text, "\n")
21+
for _, line := range lines {
22+
fmt.Println("Openvpn log >>", line)
23+
}
24+
}
25+
26+
func (lc *loggingCallbacks) OnEvent(event *openvpn3.Event) {
27+
fmt.Printf("Openvpn event >> %+v\n", event)
28+
}
29+
30+
func (lc *loggingCallbacks) OnStats(stats *openvpn3.Statistics) {
31+
fmt.Printf("Openvpn stats >> %+v\n", stats)
32+
}
33+
34+
var _ callbacks = &loggingCallbacks{}
35+
36+
type StdoutLogger func(text string)
37+
38+
func (lc StdoutLogger) Log(text string) {
39+
lc(text)
40+
}
41+
42+
func StartSession() {
43+
44+
var logger StdoutLogger = func(text string) {
45+
lines := strings.Split(text, "\n")
46+
for _, line := range lines {
47+
fmt.Println("Library check >>", line)
48+
}
49+
}
50+
openvpn3.SelfCheck(logger)
51+
52+
profile := ""
53+
profileCreds := openvpn3.Credentials{
54+
Username: "abc",
55+
Password: "def",
56+
}
57+
58+
session := openvpn3.NewMobileSession(&loggingCallbacks{}, &openvpn3.NoOpTunnelSetup{})
59+
session.Start(profile, &profileCreds)
60+
61+
err := session.Wait()
62+
if err != nil {
63+
fmt.Println("Openvpn3 error: ", err)
64+
} else {
65+
fmt.Println("Graceful exit")
66+
}
67+
68+
}

gomobile_example_ios.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
CGO_LDFLAGS_ALLOW="-fobjc-arc" \
4+
gomobile bind -target=ios/arm64 -o build/Example.framework -iosversion=10.3 -v github.com/mysteriumnetwork/go-openvpn/examples/ios

0 commit comments

Comments
 (0)