Merge lp:~pedronis/ubuntu-push/acceptanceclient-flags into lp:ubuntu-push

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 46
Merged at revision: 44
Proposed branch: lp:~pedronis/ubuntu-push/acceptanceclient-flags
Merge into: lp:ubuntu-push
Prerequisite: lp:~pedronis/ubuntu-push/improve-coverage
Diff against target: 75 lines (+17/-5)
2 files modified
server/acceptance/acceptanceclient.go (+2/-0)
server/acceptance/cmd/acceptanceclient.go (+15/-5)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/acceptanceclient-flags
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+201651@code.launchpad.net

Commit message

-insecure (don't check certs) -reportPings=f (don't report pings) flags for acceptanceclient

Description of the change

lets control in acceptanceclient whether to

- check certs
- report Pings

using flags

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'server/acceptance/acceptanceclient.go'
2--- server/acceptance/acceptanceclient.go 2014-01-13 15:21:11 +0000
3+++ server/acceptance/acceptanceclient.go 2014-01-14 19:06:14 +0000
4@@ -39,6 +39,7 @@
5 CertPEMBlock []byte
6 ReportPings bool
7 Levels map[string]int64
8+ Insecure bool // don't verify certs
9 // connection
10 Connection net.Conn
11 }
12@@ -59,6 +60,7 @@
13 }
14 tlsConfig.RootCAs = cp
15 }
16+ tlsConfig.InsecureSkipVerify = sess.Insecure
17 sess.Connection = tls.Client(conn, tlsConfig)
18 return nil
19 }
20
21=== modified file 'server/acceptance/cmd/acceptanceclient.go'
22--- server/acceptance/cmd/acceptanceclient.go 2014-01-13 15:21:11 +0000
23+++ server/acceptance/cmd/acceptanceclient.go 2014-01-14 19:06:14 +0000
24@@ -18,6 +18,7 @@
25 package main
26
27 import (
28+ "flag"
29 "launchpad.net/ubuntu-push/config"
30 "launchpad.net/ubuntu-push/server/acceptance"
31 "log"
32@@ -25,6 +26,11 @@
33 "path/filepath"
34 )
35
36+var (
37+ insecureFlag = flag.Bool("insecure", false, "disable checking of server certificate and hostname")
38+ reportPingsFlag = flag.Bool("reportPings", true, "report each Ping from the server")
39+)
40+
41 type configuration struct {
42 // session configuration
43 PingInterval config.ConfigTimeDuration `json:"ping_interval"`
44@@ -35,14 +41,15 @@
45 }
46
47 func main() {
48- // xxx configure logging
49+ flag.Parse()
50+ narg := flag.NArg()
51 switch {
52- case len(os.Args) < 2:
53+ case narg < 1:
54 log.Fatal("missing config file")
55- case len(os.Args) < 3:
56+ case narg < 2:
57 log.Fatal("missing device-id")
58 }
59- configFName := os.Args[1]
60+ configFName := flag.Arg(0)
61 f, err := os.Open(configFName)
62 if err != nil {
63 log.Fatalf("reading config: %v", err)
64@@ -56,7 +63,10 @@
65 ExchangeTimeout: cfg.ExchangeTimeout.TimeDuration(),
66 PingInterval: cfg.PingInterval.TimeDuration(),
67 ServerAddr: cfg.Addr.HostPort(),
68- DeviceId: os.Args[2],
69+ DeviceId: flag.Arg(1),
70+ // flags
71+ ReportPings: *reportPingsFlag,
72+ Insecure: *insecureFlag,
73 }
74 session.CertPEMBlock, err = config.LoadFile(cfg.CertPEMFile, filepath.Dir(configFName))
75 if err != nil {

Subscribers

People subscribed via source and target branches